Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can save the output of pyttsx to a wav file in windows, but the process suspended #15

Open
hick opened this issue Aug 23, 2013 · 2 comments
Milestone

Comments

@hick
Copy link

hick commented Aug 23, 2013

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') after self._tts = win32com.client.Dispatch('SAPI.SPVoice') to create a file stream .

and in the function say , add some code around self._tts.Speak(unicode(text), 19) :

self._stream.Open("test.wav", 3) 
self._tts.AudioOutputStream = self._stream
self._tts.Speak(unicode(text), 19)

it worked, but, my python script never stopped, just suspended, I had try to edit the say function and runAndWait 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.

@hick
Copy link
Author

hick commented Aug 23, 2013

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

@hick
Copy link
Author

hick commented Aug 26, 2013

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant