B
B
Buhat2020-04-16 23:16:42
Python
Buhat, 2020-04-16 23:16:42

pyttsx3 not working?

i wanted to test pyttsx3 library
but error:
Traceback (most recent call last):
File "D:\Python38-32\lib\site-packages\pyttsx3\__init__.py", line 20, in init
eng = _activeEngines[driverName]
File "D:\Python38-32\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 "D:\Python38-32\lib\site-packages\pyttsx3\drivers\sapi5.py", line 3, in
from comtypes.gen import SpeechLib # comtypes
ImportError: cannot import name 'SpeechLib' from 'comtypes. gen' (D:\Python38-32\lib\site-packages\comtypes\gen\__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\Python38-32\lib\ctypes\__init__.py", line 123, in WINFUNCTYPE
return _win_functype_cache[(restype, argtypes, flags)]
KeyError: (, (, , , , ), 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "sayer.py", line 12, in
main()
File "sayer.py", line 10, in main
speak('Coronavirus')
File "sayer.py", line 5, in speak
engine = pyttsx3.init()
File "D:\Python38-32\lib\site-packages \pyttsx3\__init__.py", line 22,init
eng = Engine(driverName, debug)
File "D:\Python38-32\lib\site-packages\pyttsx3\engine.py", line 30, in init
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "D: \Python38-32\lib\site-packages\pyttsx3\driver.py", line 50, in init
self._module = importlib.import_module(name)
File "D:\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 "D:\Python38-32\lib\site-packages\pyttsx3\drivers\sapi5.py", line 6, in
engine = comtypes.client.CreateObject("SAPI.SpVoice")
File "D:\Python38-32 \lib\site-packages\comtypes\client\__init__.py", line 250, in CreateObject
return _manage(obj, clsid, interface=interface)
File "D:\Python38-32\lib\site-packages\comtypes\client \__init__.py", line 188, in _manage
obj = GetBestInterface(obj)
File "D:\Python38-32\lib\site-packages\comtypes\client\__init__.py", line 110, in GetBestInterface
mod = GetModule( tlib)
File "D:\Python38-32\lib\site-packages\comtypes\client\_generate.py", line 110, in GetModule
mod = _CreateWrapper(tlib, pathname)
File "D:\Python38-32\lib\site-packages\comtypes\client\_generate.py", line 184, in _CreateWrapper
mod = _my_import(fullname)
File "D:\Python38-32\lib\site-packages\ comtypes\client\_generate.py", line 24, in _my_import
return import(fullname, globals(), locals(), ['DUMMY'])
File "D:\Python38-32\lib\site-packages\comtypes\ gen\_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4.py", line 1068, in
ISpeechRecoGrammar._methods_ = [
File "D:\Python38-32\lib\site-packages\comtypes\__init__.py", line 329, in setattr self._make_methods
(value)
"D:\Python38-32\lib\site-packages\comtypes\__init__.py", line 698, in _make_methods
prototype = WINFUNCTYPE(restype,*argtypes)
File "D:\Python38-32\lib\ctypes\__init__.py", line 125, in WINFUNCTYPE
class WinFunctionType(_CFuncPtr):
TypeError: item 2 in _argtypes_ passes a union by value, which is unsupported.
Even though I installed everything.
The code was like this;

import pyttsx3
import time
import sys

def speak(what):
  engine = pyttsx3.init()
  engine.say(what)
  engine.runAndWait()

def main():
  speak('Коронавирус')
  time.sleep(1)
  input('Нажми ENTER чтоб выйти')
  sys.exit()
main()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-04-17
@LazyTalent

Try to install version 2.71
pip install pyttsx3==2.71

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question