我正在使用 Visual Studio 2017 并创建一个 Python 应用程序。我在 python 中使用 pyttsx3 收到“未找到成员”错误。前几次成功调用该方法,然后调用错误,我无法进一步调用该方法。有人可以帮忙吗?我尝试在 Python 3.6(64 位)和 Python 3.7(32 位)环境中更新 pyttsx3 模块。我还尝试了“未找到 win32com 模块”问题中的答案。我仍然收到错误def Say(text): try: speechEngine = pyttsx3.init() speechEngine.setProperty('rate', 150) print("{0} | Lola: {1}".format(TimeOfDay(), text)) speechEngine.say(text) speechEngine.runAndWait() logging.info("Spoken words ({0})".format(text)) except Exception as e: logging.error("Exception occurred", exc_info=True) print("{0} | Lola: {1}".format(TimeOfDay(),"I have come across an error in my code. See the log for details"))预期的结果是它应该说出输出文本。但是,我收到以下错误:我收到以下错误:Exception occurred Traceback (most recent call last): File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\pyttsx3\__init__.py", line 44, in init eng = _activeEngines[driverName] File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\weakref.py", line 137, in __getitem__ o = self.data[key]() KeyError: None在处理上述异常的过程中,又发生了一个异常: Traceback (most recent call last): File "C:\Users\IllyS\OneDrive\Programming\My Programs\GitHub\Lola-Mark-II\Lola\Lola.py", line 23, in Say speechEngine = pyttsx3.init() File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\pyttsx3\__init__.py", line 46, in init eng = Engine(driverName, debug) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\pyttsx3\engine.py", line 52, in __init__ self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\pyttsx3\driver.py", line 77, in __init__ self._driver = self._module.buildDriver(weakref.proxy(self))
1 回答

函数式编程
TA贡献1807条经验 获得超9个赞
我修复了错误。这是因为我打电话speechEngine = pyttsx3.init()
,并speechEngine.setProperty('rate', 150)
在该方法中一遍又一遍(我有一个,而循环中调用此方法)。我把它们搬到外面,它奏效了。目前在任何时间后都没有看到错误。将看到它的进展......
添加回答
举报
0/150
提交
取消