Here is a little program which record the text to a wave file. I have tested
the similar Python code
import winim/com
#~ from comtypes.gen import SpeechLib
var obj = CreateObject("SAPI.SpVoice")
obj.speak "Nim is a statically typed, imperative programming language."
var stream = CreateObject("Sapi.SpFileStream")
#~ stream.Open "r:/record.wav", SpeechLib.SSFMCreateForWrite, False
stream.Open r"r:\record.wav", 3, False
var temp_stream = obj.AudioOutputStream
obj.AudioOutputStream = stream
obj.speak("Hello World")
obj.WaitUntilDone(-1)
stream.Close()
obj.AudioOutputStream = temp_stream
Run
question 1: what can we do the pyhon code from comtypes.gen import SpeechLib in
Nim? I have tried obj.SSFMCreateForWrite, but it is wrong:
Error: unhandled exception: unsupported method: SSFMCreateForWrite
[COMError]
Run
question 2: when the above program runs, it fails and says
Error: unhandled exception: invoke method failed: AudioOutputStream
[COMError]
Run
so any fix? Thanks