2013-12-10 100 views

回答

3

您可以將SAPI輸出保存到一個.wav文件如下:

  1. 創建和使用SpFileStream.Open方法打開一個.wav文件作爲流。

  2. 將此文件流指定給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 
+1

在我來說,我需要添加'oVoice.WaitUntilDone(10000)''後否則.Speak'的文件將被立即關閉。我也用'oVoice.Speak「Hello world」,3' – alexandroid

相關問題