pip install pyttsx3

我在MacOSX上安装的,是python2, 有很多语音,需要找到对应的语音。

engine = pyttsx3.init()
voices = engine.getProperty('voices')
for voice in voices:
  if voice.languages == [u'zh_CN']:
    engine.setProperty('voice', voice.id)
    break

engine.say(u'The quick brown fox jumped over the lazy dog.中华人民共和
国。')
engine.say(u'我爱北京天安门,天安门上太阳升。')
engine.runAndWait()

标签: none 阅读量: 800

添加新评论