我有以下VBScript代码用于文本转语音:
我有以下VBScript代码用于文本转语音:
Set objVoice = CreateObject("SAPI.SpVoice")
objVoice.Speak Inputbox("Enter Text")
我想将演讲保存为音频文件。我该怎么做?
我有以下VBScript代码用于文本转语音:
Set objVoice = CreateObject("SAPI.SpVoice")
objVoice.Speak Inputbox("Enter Text")
我想将演讲保存为音频文件。我该怎么做?
使用SpFileStream.Open
方法创建和打开一个.WAV文件流。
将此文件流分配给SpVoice.AudioStream
属性。
Const SAFT48kHz16BitStereo = 39
Const SSFMCreateForWrite = 3 ' Creates file even if file exists and so destroys or overwrites the existing file
Dim oFileStream, oVoice
Set oFileStream = CreateObject("SAPI.SpFileStream")
oFileStream.Format.Type = SAFT48kHz16BitStereo
oFileStream.Open "C:\Work\Sample.wav", SSFMCreateForWrite
Set oVoice = CreateObject("SAPI.SpVoice")
Set oVoice.AudioOutputStream = oFileStream
oVoice.Speak "Hello world"
oFileStream.Close
.Speak
后添加oVoice.WaitUntilDone(10000)
,否则文件会立即关闭。我还使用了oVoice.Speak "Hello world", 3
。 - alexandroid