双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

python文字转语音,pyttsx3里的问题

kenshi2856 kenshi2856 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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)
...全文
评论 8
收藏 已收藏
分享
返回顶部
kenshi2856
脚本语言 37,738 成员 34,208 内容