@[TOC](pyttsx3 pywintypes.com_error: (-2147221005, ‘无效的类字符串’, None, None))
系统环境
系统:win7
python版本:python 3.7.1 64位
与python版本的关系
通过多台电脑测试,此报错与python版本没有关系!
报错信息
Traceback (most recent call last):
File "E:\Program Files\DevelProgram\Python\envs\py3_venvs\lib\site-packages\pyttsx3\__init__.py", line 44, in init
eng = _activeEngines[driverName]
File "E:\Program Files\DevelProgram\Python\envs\py3_venvs\lib\weakref.py", line 137, in __getitem__
o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Program Files\DevelProgram\Python\envs\py3_venvs\lib\site-packages\win32com\client\dynamic.py", line 89, in _GetGoodDispatch
IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221005, '无效的类字符串', None, None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:/cyfAI/pro_ject/python/speech/speech.py", line 4, in <module>
engine = pyttsx3.init()
File "E:\Program Files\DevelProgram\Python\envs\py3_venvs\lib\site-packages\pyttsx3\__init__.py", line 46, in init
eng = Engine(driverName, debug)
File "E:\Program Files\DevelProgram\Python\envs\py3_venvs\lib\site-packages\pyttsx3\engine.py", line 52, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "E:\Program Files\DevelProgram\Python\envs\py3_venvs\lib\site-packages\pyttsx3\driver.py", line 77, in __init__
self._driver = self._module.buildDriver(weakref.proxy(self))
File "E:\Program Files\DevelProgram\Python\envs\py3_venvs\lib\site-packages\pyttsx3\drivers\sapi5.py", line 22, in buildDriver
return SAPI5Driver(proxy)
File "E:\Program Files\DevelProgram\Python\envs\py3_venvs\lib\site-packages\pyttsx3\drivers\sapi5.py", line 26, in __init__
self._tts = win32com.client.Dispatch('SAPI.SPVoice')
File "E:\Program Files\DevelProgram\Python\envs\py3_venvs\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "E:\Program Files\DevelProgram\Python\envs\py3_venvs\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "E:\Program Files\DevelProgram\Python\envs\py3_venvs\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221005, '无效的类字符串', None, None)
报错原因
通过打开讲述人,发现也是无法打开的,那么就有理由怀疑语音引擎有问题