文本到语音(pyttsx3)模块不工作

2024-09-28 22:20:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我为我的windows计算机安装了上面提到的软件包,但pyttsx3不工作。我按照建议安装了pypiwin32和pywin32模块。我还将python包的版本从64位更改为32位,甚至重新安装了windows,但收效甚微。我反复得到以下错误消息。有什么建议吗

Traceback (most recent call last):
  File "C:\Users\manas\AppData\Local\Programs\Python\Python38\lib\site-packages\pyttsx3\__init__.py", line 20, in init
    eng = _activeEngines[driverName]
  File "C:\Users\manas\AppData\Local\Programs\Python\Python38\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\manas\AppData\Local\Programs\Python\Python38\lib\site-packages\pyttsx3\drivers\sapi5.py", line 3, in <module>
    from comtypes.gen import SpeechLib  # comtypes
ImportError: cannot import name 'SpeechLib' from 'comtypes.gen' (C:\Users\manas\AppData\Local\Programs\Python\Python38\lib\site-packages\comtypes\gen\__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\manas\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 123, in WINFUNCTYPE
    return _win_functype_cache[(restype, argtypes, flags)]
KeyError: (<class 'ctypes.HRESULT'>, (<class 'comtypes.automation.tagVARIANT'>, <class 'comtypes.automation.LP_BSTR'>), 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\manas\OneDrive\Desktop\Manu's Python Scripts\1_Mastercode.py", line 8, in <module>
    engine = pyttsx3.init()
  File "C:\Users\manas\AppData\Local\Programs\Python\Python38\lib\site-packages\pyttsx3\__init__.py", line 22, in init
    eng = Engine(driverName, debug)
  File "C:\Users\manas\AppData\Local\Programs\Python\Python38\lib\site-packages\pyttsx3\engine.py", line 30, in __init__
    self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
  File "C:\Users\manas\AppData\Local\Programs\Python\Python38\lib\site-packages\pyttsx3\driver.py", line 50, in __init__
    self._module = importlib.import_module(name)
  File "C:\Users\manas\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module

Tags: inpyinitlibpackageslocallinesite
1条回答
网友
1楼 · 发布于 2024-09-28 22:20:25

我刚想出来!这个pip似乎是最近更新的,由于某种原因,更新后的版本对我不起作用(尝试了所有的方法,包括不同的PC、windows重新安装、python版本更改等)。尽管如此,pyttsx3的旧版本对我来说仍然可以正常工作

我的解决方案:

python -m pip install pyttsx3==2.71

相关问题 更多 >