Uh, you should use engine.setProperty('voice', voice_id)
(with voice_id
being an ID of the voice in your system; you can grab the list of available voices from engine.getProperty('voices')
) as proposed in that example:
engine = pyttsx.init()
voices = engine.getProperty('voices')
for voice in voices:
engine.setProperty('voice', voice.id) # changes the voice
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()
You don't have to cycle, you can set voice id without a for
loop.
Just do it like that:
engine = pyttsx.init()
engine.setProperty('voice', voice_id) # use whatever voice_id you'd like
engine.say('The quick brown fox jumped over the lazy dog.')