I want to use pyttsx3 in my code but I always have that error:
Traceback (most recent call last):
File "C:\Users\Romain\AppData\Local\Programs\Python\Python38\lib\site-packages\pyttsx3\__init__.py", line 20, in init
eng = _activeEngines[driverName]
File "C:\Users\Romain\AppData\Local\Programs\Python\Python38\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 "test3.py", line 3, in <module>
engine = pyttsx3.init()
File "C:\Users\Romain\AppData\Local\Programs\Python\Python38\lib\site-packages\pyttsx3\__init__.py", line 22, in init
eng = Engine(driverName, debug)
File "C:\Users\Romain\AppData\Local\Programs\Python\Python38\lib\site-packages\pyttsx3\engine.py", line 30, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\Users\Romain\AppData\Local\Programs\Python\Python38\lib\site-packages\pyttsx3\driver.py", line 52, in __init__
self._driver = self._module.buildDriver(weakref.proxy(self))
File "C:\Users\Romain\AppData\Local\Programs\Python\Python38\lib\site-packages\pyttsx3\drivers\sapi5.py", line 30, in buildDriver
return SAPI5Driver(proxy)
File "C:\Users\Romain\AppData\Local\Programs\Python\Python38\lib\site-packages\pyttsx3\drivers\sapi5.py", line 35, in __init__
self._tts = comtypes.client.CreateObject('SAPI.SPVoice')
File "C:\Users\Romain\AppData\Local\Programs\Python\Python38\lib\site-packages\comtypes\client\__init__.py", line 250, in CreateObject
return _manage(obj, clsid, interface=interface)
File "C:\Users\Romain\AppData\Local\Programs\Python\Python38\lib\site-packages\comtypes\client\__init__.py", line 188, in _manage
obj = GetBestInterface(obj)
File "C:\Users\Romain\AppData\Local\Programs\Python\Python38\lib\site-packages\comtypes\client\__init__.py", line 112, in GetBestInterface
interface = getattr(mod, itf_name)
AttributeError: module 'comtypes.gen.SpeechLib' has no attribute 'ISpeechVoice'
And my code:
import pyttsx3
engine = pyttsx3.init()
engine.say("This is a test")
engine.runAndWait()
Can you please help me ? (using Python 3.8.3 and Studio code)