pythonpython-3.xpyttsx

Python keyerror 'sapi5'


One question of this type is previously asked but is not very helpful. I am using version Python3.6 in Windows 10 OS. I am getting an error, KeyError: 'sapi5' and During handling of the above exception, another exception occurred. My code is:

import pyttsx3
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
print(voices)

And here is the stack trace:

 File "c:/Users/farhe/OneDrive/Desktop/PYTHON/jarvis/ai.py.py", line 2, in <module>
    engine = pyttsx3.init(sapi5)
NameError: name 'sapi5' is not defined

What should I do?


Solution

  • From the Github README:

    If you recieve errors such as No module named win32com.client, No module named win32, or No module named win32api, you will need to additionally install pypiwin32.