Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: item 1 in _argtypes_ passes a union by value, which is unsupported. #107

Open
davisia opened this issue Apr 11, 2020 · 1 comment

Comments

@davisia
Copy link

davisia commented Apr 11, 2020

I am getting an error for below code. Moreover, this error only happens if I use Pycharm but not in Visual Code, were sapi5 is recognized without problem, any tips? thanks

`import pyttsx3

engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
print(voices)
engine.setProperty('voices', voices[1].id)`

I am using python 3.8.2 in windows 10.

##Error:

`Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\pyttsx3_init_.py", line 20, in init
eng = _activeEngines[driverName]
File "C:\ProgramData\Anaconda3\lib\weakref.py", line 137, in getitem
o = self.datakey
KeyError: 'sapi5'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\pyttsx3\drivers\sapi5.py", line 3, in
from comtypes.gen import SpeechLib # comtypes
ImportError: cannot import name 'SpeechLib' from 'comtypes.gen' (C:\ProgramData\Anaconda3\lib\site-packages\comtypes\gen_init_.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\ctypes_init_.py", line 121, in WINFUNCTYPE
return _win_functype_cache[(restype, argtypes, flags)]
KeyError: (<class 'ctypes.HRESULT'>, (<class 'comtypes.BSTR'>, <class 'comtypes.automation.tagVARIANT'>), 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/david/OneDrive/Escritorio/repository1desk/gpt-2-simple/main_en.py", line 16, in
engine = pyttsx3.init("sapi5")
File "C:\ProgramData\Anaconda3\lib\site-packages\pyttsx3_init_.py", line 22, in init
eng = Engine(driverName, debug)
File "C:\ProgramData\Anaconda3\lib\site-packages\pyttsx3\engine.py", line 30, in init
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\ProgramData\Anaconda3\lib\site-packages\pyttsx3\driver.py", line 50, in init
self.module = importlib.import_module(name)
File "C:\ProgramData\Anaconda3\lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in call_with_frames_removed
File "C:\ProgramData\Anaconda3\lib\site-packages\pyttsx3\drivers\sapi5.py", line 6, in
engine = comtypes.client.CreateObject("SAPI.SpVoice")
File "C:\ProgramData\Anaconda3\lib\site-packages\comtypes\client_init
.py", line 250, in CreateObject
return manage(obj, clsid, interface=interface)
File "C:\ProgramData\Anaconda3\lib\site-packages\comtypes\client_init
.py", line 188, in manage
obj = GetBestInterface(obj)
File "C:\ProgramData\Anaconda3\lib\site-packages\comtypes\client_init
.py", line 110, in GetBestInterface
mod = GetModule(tlib)
File "C:\ProgramData\Anaconda3\lib\site-packages\comtypes\client_generate.py", line 110, in GetModule
mod = _CreateWrapper(tlib, pathname)
File "C:\ProgramData\Anaconda3\lib\site-packages\comtypes\client_generate.py", line 184, in _CreateWrapper
mod = _my_import(fullname)
File "C:\ProgramData\Anaconda3\lib\site-packages\comtypes\client_generate.py", line 24, in my_import
return import(fullname, globals(), locals(), ['DUMMY'])
File "C:\ProgramData\Anaconda3\lib\site-packages\comtypes\gen_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4.py", line 73, in
( ['out', 'retval'], POINTER(BSTR), 'ValueName' )),
File "C:\ProgramData\Anaconda3\lib\site-packages\comtypes_init
.py", line 329, in setattr
self.make_methods(value)
File "C:\ProgramData\Anaconda3\lib\site-packages\comtypes_init
.py", line 698, in make_methods
prototype = WINFUNCTYPE(restype, *argtypes)
File "C:\ProgramData\Anaconda3\lib\ctypes_init
.py", line 123, in WINFUNCTYPE
class WinFunctionType(_CFuncPtr):
TypeError: item 2 in argtypes passes a union by value, which is unsupported.

Similar to an error by @DebarunMitra, without issue. #6 (comment)

@davisia davisia changed the title ## I am getting the same error for below code, TypeError: item 1 in _argtypes_ passes a union by value, which is unsupported. Apr 11, 2020
@olavomendes
Copy link

I fixed it temporary installing 2.7 version
pip install pyttsx3==2.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants