python的文本转语音_python 文本转语音问题

在尝试使用pyttsx库进行文本转语音时遇到了错误,具体表现为在调用'SAPI.SPVoice'时发生了com_error。可能是由于缺少必要的语音引擎或者Python环境配置问题导致的。
摘要由CSDN通过智能技术生成

import sys

reload(sys)

sys.setdefaultencoding('utf8')

import pyttsx

engine = pyttsx.init()

engine.say('hello world')

engine.runAndWait()

当我使用pyttsy 尝试转换输出语音是时 出现了这样的错误

C:\Python27\python.exe D:/python/ccc.py

Traceback (most recent call last):

File "D:/python/ccc.py", line 6, in

engine = pyttsx.init()

File "C:\Python27\lib\site-packages\pyttsx\__init__.py", line 39, in init

eng = Engine(driverName, debug)

File "C:\Python27\lib\site-packages\pyttsx\engine.py", line 45, in __init__

self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)

File "C:\Python27\lib\site-packages\pyttsx\driver.py", line 66, in __init__

self._driver = self._module.buildDriver(weakref.proxy(self))

File "C:\Python27\lib\site-packages\pyttsx\drivers\sapi5.py", line 37, in buildDriver

return SAPI5Driver(proxy)

File "C:\Python27\lib\site-packages\pyttsx\drivers\sapi5.py", line 41, in __init__

self._tts = win32com.client.Dispatch('SAPI.SPVoice')

File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch

dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)

File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName

return (_GetGoodDispatch(IDispatch, clsctx), userName)

File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch

IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)

pywintypes.com_error: (-2147221005, '\xce\xde\xd0\xa7\xb5\xc4\xc0\xe0\xd7\xd6\xb7\xfb\xb4\xae', None, None)

请问这是什么原因呢?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值