flozi00/Chatterbox-Multilingual-TTS
0
Phone Announcements TTS Engine
A modular text-to-speech engine for generating professional phone announcements with support for 23 languages and voice cloning.
Features
- ๐๏ธ Standard Voices (Default): Local voice prompts from
.wavfiles invoices/ - ๐ 23 Languages: German, English, French, Spanish, Italian, and many more
- ๐ญ Voice Cloning: Uses Chatterbox Multilingual + reference audio
- ๐ Modular Architecture: Easy to swap TTS backends
- ๐ต Background Music: Optional background music mixing
- ๐พ Caching: Local and HuggingFace Hub caching support
Quick Start
# Install dependencies
pip install -r requirements.txt
# Run the application
python app.pyArchitecture
The engine uses a modular backend system that allows easy swapping of TTS providers:
engine/
โโโ __init__.py # Main exports
โโโ tts_engine.py # Core TTS Engine
โโโ audio_processor.py # Post-processing (music, fades)
โโโ cache.py # Caching system
โโโ backends/
โโโ base.py # Abstract backend interface
โโโ chatterbox_backend.py # Default: Chatterbox Multilingual
Usage
Simple Usage
from engine import TTSEngine
# Create engine with defaults
engine = TTSEngine()
# Generate a sample announcement (default)
audio = engine.generate("Welcome to our service.")
# Generate with specific language
audio = engine.generate(
"Welcome to our customer service.",
language="en"
)Voice Cloning
# Clone a voice from reference audio
audio = engine.generate(
"Welcome!",
language="de",
voice_audio="path/to/reference.wav"
)Switch Backend
This project currently ships with the Chatterbox backend.
With Background Music
# Add background music (place .mp3 files in engine/data/assets/)
audio = engine.generate(
"Please wait.",
background_music="hold_music"
)Creating a Custom Backend
To add a new TTS backend, inherit from TTSBackend:
from engine.backends.base import TTSBackend, TTSResult, BackendConfig
class MyCustomBackend(TTSBackend):
@property
def name(self) -> str:
return "My Custom TTS"
@property
def supports_voice_cloning(self) -> bool:
return False
@property
def supported_languages(self) -> dict[str, str]:
return {"en": "English", "de": "German"}
def load(self) -> None:
# Load your model
self._is_loaded = True
def unload(self) -> None:
# Cleanup
self._is_loaded = False
def generate(self, text: str, language: str = "de", **kwargs) -> TTSResult:
# Generate audio
audio = your_tts_function(text, language)
return TTSResult(audio=audio, sample_rate=22050)
# Register the backend
from engine import TTSEngine
TTSEngine.register_backend("my_custom", MyCustomBackend)Configuration
Engine Configuration
from engine.tts_engine import TTSEngine, EngineConfig
config = EngineConfig(
default_backend="chatterbox",
device="cuda", # or "cpu", "mps", "auto"
default_language="de",
enable_cache=True,
local_cache_dir="./cache",
)
engine = TTSEngine(config)Environment Variables
HF_TOKEN: HuggingFace token for model downloads (Chatterbox)PHONE_SPEAKER_TTS_VOICES_DIR: Override the default voices folder (defaults to./voices)
Default Voices Folder
Put .wav files into voices/ (or the folder pointed to by PHONE_SPEAKER_TTS_VOICES_DIR). The file name (without extension) becomes the voice name.
Example: voices/flozi.wav โ voice flozi.
If the folder contains no .wav files, the UI will force Voice cloning and require an uploaded reference sample.
Supported Languages
License
MIT License
