首页 > 解决方案 > 我想修复一个 pyttsx3 程序

问题描述

我最近安装了 pyttsx3 并使用以下代码:

import pyttsx3
engine = pyttsx3.init()
engine.say("I will speak this text")
engine.runAndWait()

但是当我运行这个程序时,我遇到了一些问题: 在此处输入图像描述

我不知道如何处理这个:(

标签: python-3.xpyttsx

解决方案


试试这个程序。我对此有一些经验。

engine = pyttsx3.init('sapi5')<--- Sapi5 is Win 10 only. Find the one for your system.
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)

def speak(audio):
    engine.say(audio)
    engine.runAndWait()

那么这就是你让它说话的方式:

speak("I am speaking this right now")

推荐阅读