我一直在尝试使用这个视频在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:
我已经解决了这个问题一个星期了,有了它,我无法继续前进。如果有人帮助,那将是值得赞赏的。
你无法执行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)