返回列表 发帖

[原创] 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!"COPY

win7可用+1

TOP

返回列表