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. An application invokes the pyttsx3.init() factory function to get a reference to a pyttsx3. Engine instance. it is a very easy to use tool which converts the entered text into speech.
The pyttsx3 module supports two voices first is female and the second is male which is provided by “sapi5” for windows.
It supports three TTS engines :
- sapi5 – SAPI5 on Windows
- nsss – NSSpeechSynthesizer on Mac OS X
- espeak – eSpeak on every other platform
To install the pyttsx3 module, first of all, you have to open the terminal and write
pip install pyttsx3
If you receive errors such as No module named win32com.client, No module named win32, or No module named win32api, you will need to additionally install pypiwin32.
It can work on any platform. Now we are all set to write a program for conversion of text to speech.
Code : Python program to convert text to speech
The output of the above program would be a voice saying,
'Hello sir, how may I help you, sir.'
- Python: Convert Speech to text and text to Speech
- Speech Recognition in Python using Google Speech API
- Convert Text to Speech in Python using win32com.client
- Text to speech GUI convertor using Tkinter in Python
- Speech To Text using IBM Watson Studio
- Convert Text to Speech in Python
- Text-To-Speech changing voice in Python
- Python Text To Speech | pyttsx module
- Python | Convert image to text and then to speech
- Part of Speech Tagging with Stop words using NLTK in python
- Python | Part of Speech Tagging using TextBlob
- Python - Get Today's Current Day using Speech Recognition
- Python | Speech recognition on large audio files
- NLP | Part of Speech - Default Tagging
- NLP | Part of speech tagged - word corpus
- Restart your Computer with Speech Recognition
- Convert Text and Text File to PDF using Python
- Formatted text in Linux Terminal using Python
- Tokenize text using NLTK in python
- Python | Tokenize text using TextBlob
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.