Universal Text-to-Speech System with Online and Offline Capabilities
By Anca Kovach
A software engineering thesis project implementing a text-to-speech library that supports multiple TTS engines and can operate in both online (Google TTS) and offline (espeak, Piper) modes.
Author: Anca Kovach Project Advisor: Aleksandr Pimenov Department of Computer Science 2025
This library provides a unified interface for various text-to-speech synthesis systems, enabling seamless switching between online and offline engines based on requirements and internet connectivity.
Key Features:
- Online synthesis through Google TTS
- Offline synthesis using espeak and Piper
- Unified interface for all engines
- Multi-language support
- Multiple audio output formats
- CLI and Python API
# System dependencies (Linux)
sudo apt install espeak espeak-data libespeak1 python3-pip
# Python dependencies
pip install -r requirements.txt# Google TTS (online)
python cli.py "Hello world"
# espeak (offline)
python cli.py "Hello world" --engine pyttsx3
# Another languages
python cli.py "Hola amigo!" --language es
# Save with automatic name
python cli.py "Hello world" --file
# Save to specific file
python cli.py "Hello world" --file output.mp3
# Google TTS (best quality)
python cli.py "Hello world" --engine gtts
# espeak (fast, offline)
python cli.py "Hello world" --engine pyttsx3
# Piper (high-quality offline)
python cli.py "Hello world" --engine pipertts
# Read from file
python cli.py -i input.txt
python cli.py -i input.txt --file output.mp3
# BytesIO
python cli.py "Hello world" --stdout | python3 play.py
# Multiple outputs
python cli.py "Hello world" --output play,file from libs.api import text_to_speech_file, text_to_speech_bytes
# Save to file
filename = text_to_speech_file("Hello world!", engine="gtts")
print(f"File created: {filename}")
# Get as bytes (for web apps)
audio_bytes = text_to_speech_bytes("Hello world!", engine="gtts")text-to-speech/
├── engines/
│ ├── gtts.py
│ ├── pyttsx3.py
│ ├── silerotts.py
│ ├── coquitts.py
│ └── piper.py
├── libs/
│ ├── api.py
│ ├── tools.py
│ ├── playback.py
│ └── exceptions.py
├── bin/
│ ├── install_pipertts.sh
│ ├── install_coquitts.sh
│ └── install_silerotts.sh
├── docs/
│ ├── COQUITTS.md
│ ├── ENGINES.md
│ ├── PIPERTTS.md
│ └── SILEROTTS.md
├── cli.py
├── test_tts.py
├── play.py
└── requirements.txt
Install runtime (user) dependencies:
pip install -r requirements.txtInstall developer tools (linters, type checkers, test tools):
pip install -r requirements-dev.txtMIT License