python - Python pyttsx3 在启动时抛出错误
问题描述
蟒蛇 3.6
有一个代码:
import pyttsx3
engine = pyttsx3.init()
engine.say("Hello World!")
engine.runAndWait()
在启动时,它给出了一个错误:
Traceback (most recent call last):
File "C:\Users\andre\PycharmProjects\Ilona\venv\lib\site-packages\pyttsx3\__init__.py", line 20, in init
eng = _activeEngines[driverName]
File "C:\Users\andre\AppData\Local\Programs\Python\Python36\lib\weakref.py", line 131, in __getitem__
o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/andre/PycharmProjects/Ilona/main.py", line 2, in <module>
engine = pyttsx3.init()
File "C:\Users\andre\PycharmProjects\Ilona\venv\lib\site-packages\pyttsx3\__init__.py", line 22, in init
eng = Engine(driverName, debug)
File "C:\Users\andre\PycharmProjects\Ilona\venv\lib\site-packages\pyttsx3\engine.py", line 30, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\Users\andre\PycharmProjects\Ilona\venv\lib\site-packages\pyttsx3\driver.py", line 52, in __init__
self._driver = self._module.buildDriver(weakref.proxy(self))
File "C:\Users\andre\PycharmProjects\Ilona\venv\lib\site-packages\pyttsx3\drivers\sapi5.py", line 30, in buildDriver
return SAPI5Driver(proxy)
File "C:\Users\andre\PycharmProjects\Ilona\venv\lib\site-packages\pyttsx3\drivers\sapi5.py", line 47, in __init__
self.setProperty('voice', self.getProperty('voice'))
File "C:\Users\andre\PycharmProjects\Ilona\venv\lib\site-packages\pyttsx3\drivers\sapi5.py", line 100, in setProperty
token = self._tokenFromId(value)
File "C:\Users\andre\PycharmProjects\Ilona\venv\lib\site-packages\pyttsx3\drivers\sapi5.py", line 80, in _tokenFromId
tokens = self._tts.GetVoices()
_ctypes.COMError: (-2147200967, None, (None, None, None, 0, None))
安装了 Pywin32、pypiwin32 和 pyttsx3 模块。
使用 PyCharm。
该怎么办?
解决方案
pip uninstall pyttsx3
pip install -u pipenv
pipenv install pyttsx3
希望这有效
推荐阅读
- java - 关于如何并行化此处理(Java8 Futures)的想法?
- blockchain - 如何创建白名单作为智能资产?
- ruby-on-rails - 无法在 Ruby on Rails 上打开 Rails 控制台
- centos - scp 上传后挂起
- laravel - Laravel API Illuminate\Foundation\Testing\TestResponse 空数组时期望单个对象
- javascript - 不分离在同一个弹出框中显示全部的数据库值
- google-cloud-platform - 谷歌云数据流工作神秘中断
- python - 如何修复 Sagemath 中函数 mod 的错误?
- java - 使用 2D 数组测试用例编写 Java 问题的 Codingbat
- javascript - babel-loader 错误 - TypeError: val is not a function