标题: [原创] vbs 文字本转语音 [打印本页]
作者: CrLf 时间: 2014-11-7 18:04 标题: vbs 文字本转语音
朋友说手机安不了阅读软件,就帮他折腾了个这个- Const [速度] = 0
- Const [音量] = 100
- Const [TXT] = "新建文本文档.txt"
-
- Dim fso,SpV,SpFS,output,text
-
- Set fso = CreateObject("Scripting.FileSystemObject")
- If Not (fso.FileExists([TXT]) And LCase(fso.GetExtensionName([TXT]))="txt") Then
- MsgBox "文件不存在或不是 .txt"
- WScript.Quit
- End If
-
- output = fso.GetBaseName([TXT])&".wav"
- text = fso.OpenTextFile([TXT],1).ReadAll()
- text = Replace(text,vbCr,"。")
- text = Replace(text,vbLf,"。")
-
- Set SpV = CreateObject("SAPI.SpVoice")
- SpV.GetAudioOutputs
- SpV.Rate = [速度]
- SpV.Volume = [音量]
-
- Set SpFS = CreateObject("SAPI.SpFileStream")
- SpFS.Open output,3,False
-
- Set SpV.AudioOutputStream = SpFS
- SpV.Speak text
- Do : Loop Until SpV.WaitUntilDone(100)
- SpFS.Close
-
- MsgBox "Bingo!"
复制代码
作者: 李安阳 时间: 2014-11-7 20:54
win7可用+1
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |