【问题标题】:Pyttsx3 not working, process finished with exit code 0Pyttsx3 不工作,进程以退出代码 0 结束
【发布时间】:2021-12-30 09:15:39
【问题描述】:

我正在制作一个人工智能 (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

如何解决??

【问题讨论】:

    标签: python speech-recognition pyttsx3


    【解决方案1】:

    您忘记使用该功能。使用此代码:

    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')
    

    希望它有效!

    【讨论】:

      猜你喜欢
      • 2017-01-19
      • 2015-05-23
      • 2018-05-29
      • 2013-04-19
      • 2021-02-20
      • 2014-01-04
      • 2017-11-03
      • 2020-01-04
      • 1970-01-01
      相关资源
      最近更新 更多