I haveintsalledpyttsx3 2.7vandpython 3.7vinpycharm
我的代码:说功能不返回音频输出
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
这很容易,我已经使用过 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()
不需要打印报表。