5

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?

Erik Cederstrand
  • 9,643
  • 8
  • 39
  • 63
Utpal Gaurav
  • 105
  • 1
  • 1
  • 12

2 Answers2

3

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.

shriakhilc
  • 2,922
  • 2
  • 12
  • 17
0

check if pipiwin32 is installed if not do install it and even though u have installed pipwin32 and the error still persists then try these following commands in cmd as admin

pip uninstall pyttsxx3

pip install pyttsx3==2.7

this worked for me.

and in case if your error is still erupting then try uninstalling pipiwin32 and install an older version of it.

Jai advith
  • 614
  • 3
  • 5