我正在使用 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))
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\pyttsx3\drivers\sapi5.py", line 22, in buildDriver
return SAPI5Driver(proxy)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\pyttsx3\drivers\sapi5.py", line 41, in __init__
self.setProperty('voice', self.getProperty('voice'))
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\pyttsx3\drivers\sapi5.py", line 72, in getProperty
return self._tts.Voice.Id
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\win32com\client\__init__.py", line 474, in __getattr__
return self._ApplyTypes_(*args)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\win32com\client\__init__.py", line 467, in _ApplyTypes_
self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args),
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, 'Member not found.', None, 0, -2147201001), None)