RapidWareTech / pyttsx

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

I can't change the gender..., what i'm doing wrong? #25

Closed rainfuse closed 10 years ago

rainfuse commented 10 years ago

Hi, first awesome lib! I'm using under linux and was preety easy to start, but now I want to change the speech to female... I'm trying with the code below without success... can you please help me?

import pyttsx

def say(text): print "{}".format(text) engine = pyttsx.init() voices = engine.getProperty('voices') for voice in voices: print voice.gender engine.setProperty('female', voice.gender) print "change: {}".format(voice.gender) engine.say(text) engine.runAndWait()

Thanks

parente commented 10 years ago

The gender is a read-only property on a voice. To speak in a female voice, find a voice that has gender=female and use engine.setPropert('voice', voice.id) to set the engine to use that female voice.

There's an example here in the documentation:

http://pyttsx.readthedocs.org/en/latest/engine.html#changing-voices