DEV Community

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

Posted on

7 1

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

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay