**
** Text转wav
** test.prg
**
Text2Wav("你好,Hello World", 0) && 0号语音库
RETURN
FUNCTION Text2Wav(cWord, nLanNo)
WAIT WINDOW "Text转wav文件,请稍等......" NOWAIT AT SROWS()/2, SCOLS()-14
cWavFile = "test.wav"
oSFS = CREATEOBJECT("SAPI.SpFileStream")
oSFS.Format.Type = 10
oSFS.Open(cWavFile, 3, .F.)
oSV = CREATEOBJECT("SAPI.SpVoice")
oSV.AllowAudioOutputFormatChangesOnNextSet = .F.
oSV.AudioOutputStream = oSFS
oSV.Voice = oSV.GetVoices.Item(nLanNo)
oSV.Speak(cWord)
oSV.WaitUntilDone(-1)
oSV.AudioOutput = oSV.GetAudioOutputs().Item(0)
oSV.AllowAudioOutputFormatChangesOnNextSet = .F.
oSV.AudioOutputStream.Format.Type = 10
oSV.AudioOutputStream = oSV.AudioOutputStream
oSFS.Close()
RELEASE oSFS
oSFS = NULL
RELEASE oSV
WAIT CLEAR
oSV = NULL
SET BELL TO "test.wav"
? CHR(7)
SET BELL TO
MESSAGEBOX("Text转wav文件完成")
ENDFUNC
[此贴子已经被作者于2017-1-20 16:03编辑过]