我在 pycharm
中具有 intsalle d pyttsx3 2.7v 和 python 3.7v我的代码:说话功能未返回音频输出
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 programe is runniing perfectly")
print("End")
输出
On
Rex:This programe is runniing perfectly
End
Process finished with exit code 0
答案 0 :(得分:0)
这很容易,我曾与Pyttsx3合作。请尝试以下程序。
import pyttsx3
engine = pyttsx3.init('sapi5') # <--- sapi 5 is for Windows
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id) # <--- voice id can be male(0) or female(1)
def speak(audio):
engine.say(audio)
engine.runAndWait()
不需要打印语句。