首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >python -使用pyttsx的错误

python -使用pyttsx的错误
EN

Stack Overflow用户
提问于 2016-06-21 00:33:21
回答 2查看 1.4K关注 0票数 0

当我直接从网站运行这段代码时

代码语言:javascript
复制
import pyttsx
engine = pyttsx.init()
engine.say('Greetings!')
engine.say('How are you today?')
engine.runAndWait()

我知道这个错误:

代码语言:javascript
复制
Traceback (most recent call last):
  File "C:\Users\Aymen\Desktop\AI.py", line 2, in <module>
    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 56, in __init__
    self.setProperty('voice', self.getProperty('voice'))
  File "C:\Python27\lib\site-packages\pyttsx\drivers\sapi5.py", line 87, in getProperty
    return self._tts.Voice.Id
  File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 466, in __getattr__
    return self._ApplyTypes_(*args)
  File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 459, in _ApplyTypes_
    self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args),
com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147221164), None)

使用python 2.7在windows 10上的im

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-10-31 15:49:04

然后安装pywin32,确保pywinypes27.dll位于C:\Windows\System32 32目录中。

票数 1
EN

Stack Overflow用户

发布于 2017-06-26 04:14:32

如果您使用的是python3,请使用pyttsx3库而不是pyttsx。

pip install pyttsx3

据我所测试,它没有任何错误。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37933874

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档