0

那么这是我的简单代码:

from comtypes.client import CreateObject
engine = CreateObject("SAPI.SpVoice")
#stream = CreateObject("SAPI.SpFileStream")

而这么多的错误来了。

回溯(最后一次调用):文件“E:\Python\lib\ctypes_init _.py ”,第 123 行,在 WINFUNCTYPE return win_functype_cache[(restype, argtypes, flags)] KeyError: (<class 'ctypes.HRESULT' >, (<class 'comtypes.automation.tagVARIANT'>, <class 'ctypes.wintypes.LP_c_long'>), 0) 在处理上述异常的过程中,又发生了一个异常: Traceback (last last call last): File "E :\Python\cv2_tutorials\Text to Speech\text2speech.py​​",第 2 行,在引擎 = CreateObject("SAPI.SpVoice") 文件 "E:\Python\lib\site-packages\comtypes\client_init .py ",第 250 行,在 CreateObject return manage(obj, clsid, interface=interface) File "E:\Python\lib\site-packages\comtypes\ client_init。py",第 188 行,在管理 obj = GetBestInterface(obj) 文件“E:\Python\lib\site-packages\comtypes\client_init .py”,第 110 行, GetBestInterface mod = GetModule(tlib) 文件“E:\Python\lib\site- packages\comtypes\client_generate.py”,第 118 行,在 GetModule mod = _CreateWrapper(tlib, pathname) 文件“E:\Python\lib\site-packages\comtypes\client_generate.py”,第 198 行,在 _CreateWrapper mod = my_import (全名)文件“E:\Python\lib\site-packages\comtypes\client_generate.py”,第 19 行,在my_import 返回导入(全名,globals(),locals(),['DUMMY'])文件“E :\Python\lib\site-packages\comtypes\gen_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4.py”,第 438 行,在 ISpeechBaseStream 中。方法= [文件“E:.py”,第 323 行,在setattr self.make_methods (value) 文件“E:\Python\lib\site-packages\comtypes_init .py ”,第 692 行,在make_methods 原型 = WINFUNCTYPE(restype, *argtypes) 文件中“ E:\Python\lib\ctypes_init .py ",第 125 行,在 WINFUNCTYPE 类 WinFunctionType(_CFuncPtr) 中:TypeError:argtypes中的项目 1按值传递联合,这是不受支持的。

我知道一件事是非常简单的错误,但我找不到。

4

1 回答 1

0

好吧,我得到了我自己问题的答案,答案非常简单:- **只需卸载 pyttsx3 和 comtypes :**

pip uninstall pyttsx3
pip uninstall comtypes

**然后通过键入以下内容重新安装它们:**

pip install comtypes
pip install -Iv pyttsx3==2.6 -U

会解决问题的,稍后谢谢

于 2021-01-31T14:42:03.460 回答