RapidWareTech / pyttsx

Cross-platform text-to-speech wrapper
Other
370 stars 134 forks source link

Phrase not spoken on second call to runAndWait() #36

Open jbflowers opened 8 years ago

jbflowers commented 8 years ago

Hey there! So I installed your library from pip and started playing around with it. There's a weird bug I'm encountering on Ubuntu 15.04 with Python 2.7.9. When I run this for the first time:

   engine.say('The quick brown fox jumped over the lazy dog.')
   engine.runAndWait()

it works correctly, but when I run the exact same code again in a program the voice cuts off after saying the beginning of the phrase (I'd say one or two characters in). I noticed this running your Changing voices example.

channon1 commented 8 years ago

try to set a value like a = engine.runAndWait() this seemed to work for me

I defined a function

    def say(s):
        engine = pyttsx.init()
        rate = engine.getProperty('rate')
        engine.setProperty('rate', rate)
        voices= engine.getProperty('voices')
        #for voice in voices:                                                                                    
        engine.setProperty('voice', 'english-us')
        #print voice.id                                                                                          
        engine.say(s)
        a = engine.runAndWait() #blocks     

    say('The slow red weasel jumped under the active cat')
jbflowers commented 8 years ago

Seems to work with those changes!

manjuhere commented 8 years ago

Thank you! This works.