gTTS (Google Text-to-Speech), a Python program and console program that uses speech output from the Google Translate API. The program converts text to an mp3 file (default), a data object byte string, or stdout. It can also use a text pre-processing program to correct the text for errors before speech output.
gTTS needs previously installed Python environment. The program works on Python 2.7 and Python 3.x.
It can be installed via the package manager pip (recommended). The package manager must be installed before.
pip install gTTS
The program can only be called from the console. It is also possible to automate the creation of speech output via shell scripts. Here are two examples how to call the program from the shell console. Also an example on how to use the program in a Python script.
Example: Outputting Text Directly in English
gtts-cli 'Hello. It is now 3 pm. We will close now. Thank you for visit.' --lang en --output information.mp3
Example: Outputting a Text File in English
gtts-cli -f /home/ubuntu/weather_forecast.txt -l 'en' -o audio.mp3
Call as Python module via a Python script
Output of the text "Hello" in English.
from gtts import gTTS tts = gTTS('hello', lang='en') tts.save('hello.mp3')
All commands of gTTS to use further functionalities of this program.
The program must be called in this order:
gtts-cli [OPTIONS] <text>
The text must be added as string or as path to the text file in <text>.
All OPTIONS commands:
Read from <file> instead of <text>.
Write to <file> instead of stdout.
IETF Language identifier. Language in which you can speak. All available languages can be output with this command: -all. Default: en]
Disable strict IETF language tag checking. Allow undocumented tags.
Print all documented available IETF language tags and exit.
Show debug information.
Show the version and exit.
All available languages and further information
The following languages are available as voice output:
German, English, French, Dutch, Spanish, Portuguese, Italian, Chinese Mandarin, Japanese, Korean, Turkish, and more.
All languages can be output with this command:
Further documentation on gTTS (official website) is available on this website: