the code below works, but unfortunately only once. As soon as I call the function FKTSpeakToFile()
a second time, there is an error message. If I want to call the function a second time
I have to restart the whole program. Where is the error?
Code: Select all
FKTSpeakToFile()
{
strText := "This is a simple sentence, spoken in English"
strWav := "Audio.wav"
SpVoice := ComObjCreate("SAPI.SpVoice")
spVoice.Volume := 100
spVoice.Rate := -2
oVoice.AllowAudioOutputFormatChangesOnNextSet := 1
SpStream := ComObjCreate("SAPI.SpFileStream")
SpStream.Open(strWav,3) ; ErrorMessage here, as soon as I call the function a second time
SpVoice.AudioOutputStream := SpStream
SpVoice.voice := SpVoice.GetVoices().Item(5)
SpVoice.Speak(strText)
SpStream.Close()
}