Open hick opened 10 years ago
I had tried to Close the stream in function "say" after runAndWait
like this, it did not work
self._tts.Speak(unicode(text), 19)
self._tts.runAndWait() # also not work for self.runAndWait()
self._stream.Close()
I found the function runAndWait , but just did not know how to close
I have found a ugly way to record in windows(tested in windows xp), you can see it in the https://github.com/hick/pyttsx 。
if the output wav file is not full, try to modify some code in pyttsx/drivers/sapi5.py, just search this string: "if you wav file is not full, change 5 in the line below to small number for more time to loop"
by Hick
sorry for I just have a little knowledge about both Python and win32 API.
but I had tried the old PYTTS package and some other code from google, and finnaly can save the wav file, by editing the pyttsx/drivers/sapi5.py as the following:
insert a line
self._stream = win32com.client.Dispatch('SAPI.SpFileStream')
afterself._tts = win32com.client.Dispatch('SAPI.SPVoice')
to create a file stream .and in the function
say
, add some code aroundself._tts.Speak(unicode(text), 19)
:it worked, but, my python script never stopped, just suspended, I had try to edit the
say
function andrunAndWait
function, failed with my poor knowledge,maybe somebody can help me? or maybe some other way to record the tts 's output to wav or mp3 files---I tried to record by pyaudio, but it always recorded the microphone directly.