python文字转语音,pyttsx3里的问题
import sys
import importlib
import pyttsx3
import pythoncom
pythoncom.CoInitialize()
importlib.reload(sys)
engine=pyttsx3.init()
engine.say('hello world')
engine.runAndWait()
这段代码在别人电脑上可以运行,在我电脑上却报下面这样的错误,重装系统都不行,求大神指教,这个问题困扰了我好几天了、、、、
Traceback (most recent call last):
File "D:\Python\Python36\lib\site-packages\pyttsx3\__init__.py", line 44, in init
eng = _activeEngines[driverName]
File "D:\Python\Python36\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 "D:\Python\Python36\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 "<pyshell#1>", line 1, in <module>
e=pyttsx3.init()
File "D:\Python\Python36\lib\site-packages\pyttsx3\__init__.py", line 46, in init
eng = Engine(driverName, debug)
File "D:\Python\Python36\lib\site-packages\pyttsx3\engine.py", line 52, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "D:\Python\Python36\lib\site-packages\pyttsx3\driver.py", line 77, in __init__
self._driver = self._module.buildDriver(weakref.proxy(self))
File "D:\Python\Python36\lib\site-packages\pyttsx3\drivers\sapi5.py", line 22, in buildDriver
return SAPI5Driver(proxy)
File "D:\Python\Python36\lib\site-packages\pyttsx3\drivers\sapi5.py", line 26, in __init__
self._tts = win32com.client.Dispatch('SAPI.SPVoice')
File "D:\Python\Python36\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "D:\Python\Python36\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "D:\Python\Python36\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)