我正在做人工智能(AI)助理,我写这个是为了让它说话:
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voices', voices[0].id)
def speak(audio):
engine.say(audio)
print(audio)
engine.runAndWait()
它不说话,也不表明:
Process finished with exit code 0
怎么修??
发布于 2021-12-30 01:15:39
你忘了使用这个函数了。使用以下代码:
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voices', voices[0].id)
def speak(audio):
engine.say(audio)
print(audio)
engine.runAndWait()
# what you are missing
# use your function to say something
speak('Hello')
希望它能起作用!
https://stackoverflow.com/questions/70517848
复制相似问题