以前曾提出过此类问题,但帮助不大。我在Windows 10操作系统中使用Python3.6版本。我收到错误 KeyError: 'sapi5' 并且在处理上述异常期间,发生了另一个异常。我的代码是:
import pyttsx3
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
print(voices)
Run Code Online (Sandbox Code Playgroud)
这是堆栈跟踪:
File "c:/Users/farhe/OneDrive/Desktop/PYTHON/jarvis/ai.py.py", line 2, in <module>
engine = pyttsx3.init(sapi5)
NameError: name 'sapi5' is not defined
Run Code Online (Sandbox Code Playgroud)
我应该怎么办?