You are here: Home » NewsFeeds » Text to speech in Python

Text to speech in Python

We can make the computer speak with Python. Given a text string, it will speak the written words in the English language. This process is called Text To Speech or shortly TTS.

You may like: Data Science and Machine Learning with Python – Hands On!Installation
You need to install one of these two modules: pyttsx or gTTS.Install using pyenv, pipenv or virtualenv.If you are feeling brave, install with pip:

sudo pip install pyttsx
sudo pip install gTTS

Text to speech
Pyttsx text to speechPytsx is a cross-platform text-to-speech wrapper. Underlying it uses different speech engines based on your operating system:
nsss – NSSpeechSynthesizer on Mac OS X 10.5 and higher
sapi5 – SAPI5 on Windows XP, Windows Vista, and (untested) Windows 7
espeak – eSpeak on any distro / platform that can host the shared library (e.g., Ubuntu / Fedora Linux)
Example:

import pyttsx
engine = pyttsx.init()
engine.say(‘Good morning.’)
engine.runAndWait()

gTTS text to speechgTTS is a module and command line utility to save spoken text


 

Original article