The program below is giving me an error. This is my program:
import pyttsx3 as tts
def speak(text):
engine = tts.init("sapi5")
engine.say(text)
engine.runandwait()
speak('Hello user this is a test message.')
This is the error message I am getting:
Traceback (most recent call last):
File "c:\Users\SIDDHESH\Projects\test.py", line 6, in <module>
speak('Hello user this is a test message.')
File "c:\Users\SIDDHESH\Projects\test.py", line 5, in speak
engine.runandwait()
AttributeError: 'Engine' object has no attribute 'runandwait'
I would like to point out that my variable is called engine
but the error message says something about a variable 'Engine'
. I would also like to point out that I am using Visual Studio Code to run my code.
Looks like you need to write engine.runAndWait()
, starting every new word with an uppercase letter. Remember that python is case sensitive, it means that runandwait
and runAndWait
are different attributes.