Error coming in this CreateObject from com types?

636 Views Asked by At

Well here is my Simple Code:

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

And this much errors comes.

Traceback (most recent call last): File "E:\Python\lib\ctypes_init_.py", line 123, in WINFUNCTYPE return win_functype_cache[(restype, argtypes, flags)] KeyError: (<class 'ctypes.HRESULT'>, (<class 'comtypes.automation.tagVARIANT'>, <class 'ctypes.wintypes.LP_c_long'>), 0) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "E:\Python\cv2_tutorials\Text to Speech\text2speech.py", line 2, in engine = CreateObject("SAPI.SpVoice") File "E:\Python\lib\site-packages\comtypes\client_init.py", line 250, in CreateObject return manage(obj, clsid, interface=interface) File "E:\Python\lib\site-packages\comtypes\client_init.py", line 188, in manage obj = GetBestInterface(obj) File "E:\Python\lib\site-packages\comtypes\client_init.py", line 110, in GetBestInterface mod = GetModule(tlib) File "E:\Python\lib\site-packages\comtypes\client_generate.py", line 118, in GetModule mod = _CreateWrapper(tlib, pathname) File "E:\Python\lib\site-packages\comtypes\client_generate.py", line 198, in _CreateWrapper mod = my_import(fullname) File "E:\Python\lib\site-packages\comtypes\client_generate.py", line 19, in my_import return import(fullname, globals(), locals(), ['DUMMY']) File "E:\Python\lib\site-packages\comtypes\gen_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4.py", line 438, in ISpeechBaseStream.methods = [ File "E:\Python\lib\site-packages\comtypes_init.py", line 323, in setattr self.make_methods(value) File "E:\Python\lib\site-packages\comtypes_init.py", line 692, in make_methods prototype = WINFUNCTYPE(restype, *argtypes) File "E:\Python\lib\ctypes_init.py", line 125, in WINFUNCTYPE class WinFunctionType(_CFuncPtr): TypeError: item 1 in argtypes passes a union by value, which is unsupported.

I know one thing that it is very simple mistake but i can't find it.

1

There are 1 best solutions below

0
On

Well I got the Answer of my Own Question and the Answer is very Simple :- **Just Uninstall the pyttsx3 and comtypes : **

pip uninstall pyttsx3
pip uninstall comtypes

**and Then Reinstall Them by typing this : **

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

It'll solve the problem ,thank me later