nateshmbhat / pyttsx3

Offline Text To Speech synthesis for python
Mozilla Public License 2.0
2.11k stars 331 forks source link

engine = pyttsx3.init('sapi5') causeing error #94

Open NasaHari opened 4 years ago

NasaHari commented 4 years ago

Traceback (most recent call last): File "C:\Users\kvvinod\PycharmProjects\textToSpeech\venv\lib\site-packages\pyttsx3__init__.py", line 20, in init eng = _activeEngines[driverName] File "C:\Users\kvvinod\AppData\Local\Programs\Python\Python38-32\lib\weakref.py", line 131, in getitem o = self.data[key]() KeyError: 'sapi5'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\kvvinod\PycharmProjects\textToSpeech\venv\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:\Users\kvvinod\PycharmProjects\textToSpeech\venv\lib\site-packages\comtypes\gen__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\kvvinod\AppData\Local\Programs\Python\Python38-32\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.LP_POINTER(ISpeechRecoGrammar)'>), 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:/Users/kvvinod/PycharmProjects/textToSpeech/venv/app.py", line 2, in engine = pyttsx3.init('sapi5') File "C:\Users\kvvinod\PycharmProjects\textToSpeech\venv\lib\site-packages\pyttsx3__init.py", line 22, in init eng = Engine(driverName, debug) File "C:\Users\kvvinod\PycharmProjects\textToSpeech\venv\lib\site-packages\pyttsx3\engine.py", line 30, in init self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug) File "C:\Users\kvvinod\PycharmProjects\textToSpeech\venv\lib\site-packages\pyttsx3\driver.py", line 50, in init self._module = importlib.import_module(name) File "C:\Users\kvvinod\AppData\Local\Programs\Python\Python38-32\lib\importlib__init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked File "", line 783, in exec_module File "", line 219, in _call_with_frames_removed File "C:\Users\kvvinod\PycharmProjects\textToSpeech\venv\lib\site-packages\pyttsx3\drivers\sapi5.py", line 6, in engine = comtypes.client.CreateObject("SAPI.SpVoice") File "C:\Users\kvvinod\PycharmProjects\textToSpeech\venv\lib\site-packages\comtypes\client__init__.py", line 250, in CreateObject return _manage(obj, clsid, interface=interface) File "C:\Users\kvvinod\PycharmProjects\textToSpeech\venv\lib\site-packages\comtypes\client__init__.py", line 188, in _manage obj = GetBestInterface(obj) File "C:\Users\kvvinod\PycharmProjects\textToSpeech\venv\lib\site-packages\comtypes\client\init__.py", line 110, in GetBestInterface mod = GetModule(tlib) File "C:\Users\kvvinod\PycharmProjects\textToSpeech\venv\lib\site-packages\comtypes\client_generate.py", line 110, in GetModule mod = _CreateWrapper(tlib, pathname) File "C:\Users\kvvinod\PycharmProjects\textToSpeech\venv\lib\site-packages\comtypes\client_generate.py", line 184, in _CreateWrapper mod = _my_import(fullname) File "C:\Users\kvvinod\PycharmProjects\textToSpeech\venv\lib\site-packages\comtypes\client_generate.py", line 24, in _my_import return import(fullname, globals(), locals(), ['DUMMY']) File "C:\Users\kvvinod\PycharmProjects\textToSpeech\venv\lib\site-packages\comtypes\gen_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4.py", line 937, in ISpeechRecoContext.methods = [ File "C:\Users\kvvinod\PycharmProjects\textToSpeech\venv\lib\site-packages\comtypes\init.py", line 329, in setattr self._make_methods(value) File "C:\Users\kvvinod\PycharmProjects\textToSpeech\venv\lib\site-packages\comtypes\init.py", line 698, in _make_methods prototype = WINFUNCTYPE(restype, *argtypes) File "C:\Users\kvvinod\AppData\Local\Programs\Python\Python38-32\lib\ctypes\init__.py", line 125, in WINFUNCTYPE class WinFunctionType(_CFuncPtr): TypeError: item 1 in argtypes passes a union by value, which is unsupported.

IllyShaieb commented 4 years ago

I am getting a similar error.

Traceback (most recent call last): File "E:\Software\sarina-env\lib\site-packages\pyttsx3__init__.py", line 20, in init eng = _activeEngines[driverName] File "E:\Software\sarina-env\lib\weakref.py", line 137, in getitem o = self.data[key]() KeyError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "E:\Software\sarina-env\lib\site-packages\pyttsx3\drivers\sapi5.py", line 3, in from comtypes.gen import SpeechLib # comtypes ImportError: cannot import name 'SpeechLib' from 'comtypes.gen' (E:\Software\sarina-env\lib\site-packages\comtypes\gen__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "e:/Software/sarina-env/sarina/sarina.py", line 14, in from sarina.speech import query, synthesiser File "e:\Software\sarina-env\sarina\sarina\speech\query.py", line 18, in from sarina.speech import synthesiser File "e:\Software\sarina-env\sarina\sarina\speech\synthesiser.py", line 7, in text_to_speech_engine = pyttsx3.init() File "E:\Software\sarina-env\lib\site-packages\pyttsx3__init.py", line 22, in init eng = Engine(driverName, debug) File "E:\Software\sarina-env\lib\site-packages\pyttsx3\engine.py", line 30, in init self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug) File "E:\Software\sarina-env\lib\site-packages\pyttsx3\driver.py", line 50, in init self._module = importlib.import_module(name) File "E:\Software\sarina-env\lib\importlib__init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "E:\Software\sarina-env\lib\site-packages\pyttsx3\drivers\sapi5.py", line 6, in engine = comtypes.client.CreateObject("SAPI.SpVoice") File "E:\Software\sarina-env\lib\site-packages\comtypes\client__init__.py", line 250, in CreateObject return _manage(obj, clsid, interface=interface) File "E:\Software\sarina-env\lib\site-packages\comtypes\client__init__.py", line 188, in _manage obj = GetBestInterface(obj) File "E:\Software\sarina-env\lib\site-packages\comtypes\client\init__.py", line 110, in GetBestInterface mod = GetModule(tlib) File "E:\Software\sarina-env\lib\site-packages\comtypes\client_generate.py", line 110, in GetModule mod = _CreateWrapper(tlib, pathname) File "E:\Software\sarina-env\lib\site-packages\comtypes\client_generate.py", line 172, in _CreateWrapper generate_module(tlib, ofi, pathname) File "E:\Software\sarina-env\lib\site-packages\comtypes\tools\tlbparser.py", line 750, in generate_module gen.generate_code(list(items.values()), filename=pathname) File "E:\Software\sarina-env\lib\site-packages\comtypes\tools\codegenerator.py", line 241, in generate_code self.generate_all(items) File "E:\Software\sarina-env\lib\site-packages\comtypes\tools\codegenerator.py", line 189, in generate_all self.generate(item) File "E:\Software\sarina-env\lib\site-packages\comtypes\tools\codegenerator.py", line 185, in generate mth(item) File "E:\Software\sarina-env\lib\site-packages\comtypes\tools\codegenerator.py", line 701, in ComInterface self.generate(itf.get_head()) File "E:\Software\sarina-env\lib\site-packages\comtypes\tools\codegenerator.py", line 185, in generate mth(item) File "E:\Software\sarina-env\lib\site-packages\comtypes\tools\codegenerator.py", line 722, in ComInterfaceHead self.generate(base.get_head()) File "E:\Software\sarina-env\lib\site-packages\comtypes\tools\codegenerator.py", line 185, in generate mth(item) File "E:\Software\sarina-env\lib\site-packages\comtypes\tools\codegenerator.py", line 629, in External comtypes.client.GetModule(ext.tlib) File "E:\Software\sarina-env\lib\site-packages\comtypes\client_generate.py", line 110, in GetModule mod = _CreateWrapper(tlib, pathname) File "E:\Software\sarina-env\lib\site-packages\comtypes\client_generate.py", line 184, in _CreateWrapper mod = _my_import(fullname) File "E:\Software\sarina-env\lib\site-packages\comtypes\client_generate.py", line 24, in _my_import return import__(fullname, globals(), locals(), ['DUMMY']) ModuleNotFoundError: No module named 'comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0'

rkent commented 4 years ago

I also go this error, reverted to version 2.71 and the problem went away.

nateshmbhat commented 4 years ago

Does this error occur on the latest build ( v2.84 ) ?

AEydi commented 4 years ago

no, in all versions use comtypes

pawaneshyadav commented 2 years ago

I am getting same type of error . Please solve it soon.

ShaneKaranepilaye commented 1 year ago

L'erreur peut provenir du fait que vous avez nommé votre fichier Python pyttsx3.py, ce qui peut causer des conflits avec l'importation de la bibliothèque pyttsx3 dans votre fichier. Pour éviter ce genre de conflits, il est recommandé de ne pas nommer vos fichiers avec le même nom que les bibliothèques Python que vous utilisez. Pour résoudre ce problème, vous pouvez renommer votre fichier Python en utilisant un autre nom, puis exécuter à nouveau votre code. Cela devrait vous permettre d'initialiser la bibliothèque pyttsx3 sans erreurs.