A powerful Python-based text-to-speech generator leveraging Silero TTS models, designed for versatile and high-quality speech synthesis:
- 🌐 Multiple language support (Russian, English, German)
- 📝 Advanced SSML text processing
- 🔊 Intelligent noise reduction
- 💻 GPU/CPU compatibility
- 🎭 Flexible speaker selection
- 🌪️ Tornado-based API server for remote TTS generation
__main__.py
: 🚀 Example script demonstrating local TTS usagesilero_tts_processor.py
: 🧠 Core TTS processor classtts_server.py
: 🌐 Tornado-based API server for remote TTS generationtest_request.sh
: 🧪 Bash script for testing the TTS APIrequirements.txt
: 📦 Project dependencies
- 🐍 Python 3.8+
- 🚀 CUDA (optional, for GPU acceleration)
- 🌐
curl
for API testing (optional) - 📊
jq
for JSON parsing (optional)
- Clone the repository:
git clone https://github.com/semyenov/silero-tts-generator.git
cd silero-tts-generator
- Create a virtual environment:
python3 -m venv .venv
source .venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
from silero_tts_processor import SileroTTSProcessor
# Create TTS processor
tts = SileroTTSProcessor(
language_id="ru",
model_id="v4_ru",
)
# Generate speech
audio = tts.generate_speech(
"<speak>Привет, мир</speak>",
speaker_id="xenia",
enhance_noise=True,
output_filename="output.wav"
)
tts.play_audio(audio)
Start the Tornado API server:
python tts_server.py
A convenient bash script test_request.sh
is provided to test the TTS API:
# Basic usage
./test_request.sh -t "Привет, мир"
# Advanced usage with custom parameters
./test_request.sh \
-t "<speak>Привет, мир</speak>" \
-s xenia
Script options:
-t
: Text to convert to speech (required)-s
: Speaker (default: xenia)-h
: Show help message
POST /tts
Request Body:
{
"text": "<speak>Текст для синтеза речи</speak>",
"speaker": "xenia",
"enhance_noise": true
}
Response:
{
"success": true,
"filename": "generated_audio_file.wav"
}
GET /audio/{filename}
Retrieves the generated audio file.
- Russian
- English
- German
- ...
Full list of supported languages and models can be found here.
- Ensure you have the latest version of PyTorch
- Check CUDA compatibility if using GPU
- Verify audio device settings
- Make sure
curl
andjq
are installed for API testing
MIT License
Pull requests are welcome. For major changes, please open an issue first.