gTTS connects to Google Translate’s text-to-speech API from Python or the command line. It writes spoken MP3 bytes to files, streams, or stdout for further use.
Overview
gTTS (Google Text-to-Speech) is a Python package and companion CLI that requests speech audio through Google Translate’s undocumented TTS capability. It is not affiliated with Google Cloud Text-to-Speech, and upstream behavior can change without notice.
You pass text and receive MP3 audio suitable for saving, piping, or loading into other audio tools. Output can go to a path, a file-like object, or standard output.
The library includes configurable sentence tokenization for long passages while handling abbreviations, decimals, and similar cases, plus optional text pre-processors such as pronunciation tweaks. Documentation covers module usage, the gtts-cli command, language helpers, and tokenizer customization.
Install from PyPI with pip. Typical workflows use either gtts-cli for one-off generation or the gTTS class in application code.
Key features
- Google Translate text-to-speech API client
- MP3 output to file, buffer, or stdout
- Configurable speech sentence tokenizer
- Customizable text pre-processors
- Command-line gtts-cli tool
- Python module API
- Language and accent helpers
Use cases
- Generate speech MP3 from scripts
- CLI quick TTS for short phrases
- Embed TTS in Python applications
- Long-form text with custom tokenization