Use this command to install:
pip install pyttsx3
First we need to import the library and then initialize it using the
init () function. This function can take 2 arguments.
init (driverName string, debug bool)
After initialization, we will force the program to speak the text using the
say () function. This method can also take 2 arguments.
say (text unicode, name string)
Finally, we use
runAndWait () to start the speech. All
say () texts will not be spoken unless the interpreter will encounter
runAndWait () .
Code # 1: Speaking text
Code # 2: listening for events p>
It works offline , unlike other text libraries. Instead of saving the text as an audio file, Pyttsx actually says it there. This makes it more reliable for use in voice projects.