我一直在尝试使用以下视频在PyCharm中进行AI项目:https://www.youtube.com/watch?time_continue=179&v=rU_ppVsyJu8
代码如下:
import sys
print(sys.path)
import speech_recognition as sr
import pyttsx3
try:
engine = pyttsx3.init()
except ImportError:
print("Driver not found")
except RuntimeError:
print("Driver fails to init")
voices = engine.getProperty("voices")
for voice in voices:
print(voice.id)
有一个错误:
即使它说没有找到驱动程序,我还是在这里安装了pyttsx3:
我已经解决了这个问题一个星期,因此我无法继续前进。如果有人帮助,将不胜感激。
答案 0 :(得分:1)
您无法执行engine = pyttsx3.init()
。这就是为什么它无法识别引擎对象。试试下面的代码。您将从Exception收到错误消息。尝试解决该错误。
import sys
print(sys.path)
import speech_recognition as sr
import pyttsx3
try:
engine = pyttsx3.init()
**except Exception as e:
print(e)**
except ImportError:
print("Driver not found")
except RuntimeError:
print("Driver fails to init")
voices = engine.getProperty("voices")
for voice in voices:
print(voice.id)