我的python版本是3.7,Pyaudio版本是2.7 程序在引擎初始化期间完全运行,但我不能使用 sipas5 for windows 所以我使用了 dummy
import pyttsx3
engine = pyttsx3.init("dummy")
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)
def speak(text):
print('Rex:' + text)
engine.say(text)
engine.runAndWait()
print("On")
speak("This program is running perfectly")
print("End")
输出
On
Rex:This program is running perfectly
End
Process finished with exit code 0
Dummy 不是语音引擎。它的tk只是测试。 pyttsx3 有 3 种类型。 Sapi5、nsss 和 espeak。这就是你放在 init () 中的内容。这是带有信息的官方 python 包的链接。
字面意思就是做对 pip3 install pyttxs3 = 2.71