嗯,您应该按照该示例中的建议使用engine.setProperty('voice', voice_id)
(voice_id
作为系统中语音的ID;您可以从中获取可用语音的列表engine.getProperty('voices')
):
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()
您不必循环,可以设置语音ID而无需for
循环。 像这样做:
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.')