pyttsx3 is a text-to-speech conversion library in Python. Unlike alternative libraries, it works offline, and is compatible with both Python 2 and 3.
First you have to install pyttsx3 in your system.
You can do it by typing “pip install pyttsx3” in command prompt .
Now, code for text to speech conversion is here.
engine = pyttsx3.init()
text = input("Enter text to speak : ")
now, if you are using windows, you will write
engine = pyttsx3.init(‘sapi5’)
for MAC users,
engine = pyttsx3.init(‘nsss’)
for Linux users,
engine = pyttsx3.init(‘espeak’)
If you get stuck or will have any error performing the same, then plz contact me here.
For detail study on pyttsx3 you can read here.