DEV Community

Cover image for Text To Speech | gTTs Python Module
Anand Kumar
Anand Kumar

Posted on

Text To Speech | gTTs Python Module

Now a days TextToSpeech feature are used in various applications as android apps website and many more.
python has couple of module which help us to integrate in our application with minimum instruction and easy to use.

Python module for Text to Speech :

pyttsx3 2.90

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.

type below command in terminal to install pyttsx3.
pip install pyttsx3

pyttsx3 python module has it own advantage as it work offline but it's output voice a bit not like human it's like robotic.

for more information pyttsx3 Document

where as we have also alternative python module from Google.
That's called gTTs.

gTTS 2.2.3

gTTS (Google Text-to-Speech), a Python library and CLI tool to interface with Google Translate's text-to-speech API. Write spoken mp3 data to a file, a file-like object (bytestring) for further audio manipulation, or stdout. Or simply pre-generate Google Translate TTS request URLs to feed to an external program.

type below command in terminal to install gTTs
pip install gTTS

for more information gTTs Document

Let's try couple of examples...

Text to speech in English language | gTTs

Text to speech in English language | gTTs

Text to speech in Hindi language |gTTs

Text to speech in Hindi language |gTTs

                            Thank You!
Enter fullscreen mode Exit fullscreen mode

Top comments (0)