Python Text to Speech
Method 1: Using pyttsx3
Pyttsx3 is an offline cross-platform Test-to-Speech library which is compatible with both Python 3 and Python 2 and supports multiple TTS engines
To use pyttsx3, first we have to download and install it. In order to install it open your command prompt or terminal and type this command.
pip install pyttsx3
If you’re using windows operating system then you also have to install “pypiwin32” to make it work. To install pypiwin32 again type this command and hit enter in command prompt.
python -m pip install pypiwin32
Make sure you’ve internet connection while running both of the command. It is one time process, after you’ve installed pyttsx3 now to use it, the program will be as shown below.
engine = pyttsx3.init()
engine.say(“Welcome to CsePathway“)
In this program, in first Line we’re initializing pyttsx3 for use then we’re passing the text in method say().
After it we’re setting some properties like volume and rate of the voice.
Here we’re passing 120 as rate, which means it will speak 120 words per minute and
last line of above program will be produce an audio saying “Welcome to CsePathway”.