How to change the voice in pyttsx3?
You can try this code:
import pyttsx3
engine = pyttsx3.init()
voices = engine.getProperty('voices')
for voice in voices:
print(voice, voice.id)
engine.setProperty('voice', voice.id)
engine.say("Hello World!")
engine.runAndWait()
engine.stop()
Then instead of the for loop, just pick up your preferred voice.id
I have just noticed. To set the language⇓ This is just my default language setting is 'ja_JP'.
import pyttsx3
engine = pyttsx3.init()
voices = engine.getProperty('voices')
for voice in voices:
print voice
if voice.languages[0] == u'en_US':
engine.setProperty('voice', voice.id)
break
engine.say('Hello World')
engine.runAndWait()
or
voice.name == 'Alex'