VoxForge is a production-grade neural text-to-speech system built as an ML systems engineering project. It generates high-quality speech from text, supports voice cloning from short reference audio, and is designed for low-latency streaming deployment.
Focus: Pipeline design, inference optimization, and production engineering β not model training.
Raw Text
β
βΌ
ββββββββββββββββββββ
β Text Normalizer β numbers, currency, abbreviations, years
ββββββββββ¬ββββββββββ
β
βΌ
ββββββββββββββββββββ
β Sentence Chunkerβ boundary detection, merge short, split long
ββββββββββ¬ββββββββββ
β
βΌ
ββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββ
β TTS Engine βββββββ Speaker Embedding β
β (XTTS-v2) β β β
ββββββββββ¬ββββββββββ β Built-in speaker β
β β OR β
βΌ β Reference Audio β VAD β Denoise β
WAV Audio Output β β XTTS Encoder β Cache β
ββββββββββββββββββββββββββββββββββββββ
Model: XTTS-v2 β zero-shot multi-speaker TTS built on VITS. Supports 16 languages and voice cloning from a single reference clip.
| Phase | Description | Status |
|---|---|---|
| 1 | Baseline pipeline β text to speech, single speaker | β Complete |
| 2 | Voice cloning via speaker embeddings | β Complete |
| 3 | Inference optimization β ONNX, FP16, streaming | π Next |
| 4 | REST API + Docker deployment | β³ Planned |
| 5 | Evaluation β latency, quality, benchmarks | β³ Planned |
| Module | Description |
|---|---|
voxforge/normalizer.py |
Converts raw text to TTS-ready form. Expands currency ($2M β two million dollars), numbers, years (2023 β twenty twenty-three), abbreviations (Dr. β doctor), strips unsupported characters |
voxforge/chunker.py |
Splits text into synthesis-safe chunks using pysbd sentence boundary detection. Merges short sentences, splits overlong ones at punctuation |
voxforge/engine.py |
Low-level XTTS-v2 inference engine. Loads model once, runs GPU warm-up, synthesizes per-chunk with per-stage timing |
voxforge/pipeline.py |
Wires all stages end-to-end. Accepts raw text, returns WAV file and full timing breakdown |
synthesize.py |
CLI entry point |
| Input | Chunks | Audio | Inference | RTF |
|---|---|---|---|---|
| Short sentence | 1 | 2.87s | 2.04s | 1.41x |
| Medium (numbers + abbreviations) | 2 | 10.86s | 9.59s | 1.13x |
| Long (2 sentences) | 2 | 14.94s | 9.35s | 1.61x |
RTF = Real-Time Factor. RTF above 1.0 means faster than real-time. All tests run post GPU warm-up. Model load time (~27s) is a one-time startup cost, eliminated in Phase 4 when the model stays loaded in a server process.
| Stage | Time |
|---|---|
| Text normalization | less than 2ms |
| Sentence chunking | less than 14ms |
| TTS inference | 95%+ of total |
| Audio save | less than 170ms |
Voice cloning works by extracting a speaker embedding from a short reference audio clip and conditioning the TTS model on it. No model fine-tuning required β XTTS-v2 supports zero-shot cloning natively.
reference_audio/my_voice.wav
β
βΌ
βββββββββββββββββββββββ
β AudioProcessor β VAD β duration check β optional denoising
ββββββββββ¬βββββββββββββ
β
βΌ
βββββββββββββββββββββββ
β SpeakerCache β SHA256 hash lookup β shelve cache
ββββββββββ¬βββββββββββββ (skips re-extraction on repeat requests)
β
βΌ
βββββββββββββββββββββββ
β XTTS-v2 Encoder β extracts gpt_cond_latent + speaker_embedding
ββββββββββ¬βββββββββββββ
β
βΌ
Synthesis in cloned voice
| Module | Description |
|---|---|
voxforge/audio_processor.py |
Validates and preprocesses reference audio. Runs WebRTC VAD (rejects clips below 30% voiced), checks duration (3β30s), optionally applies DeepFilterNet3 neural denoising |
voxforge/speaker_cache.py |
Persistent embedding cache using Python shelve. SHA256 file hash as key. Survives restarts. Cache hit skips the entire preprocessing and extraction pipeline |
| Stage | Time |
|---|---|
| VAD + validation | ~50ms |
| DeepFilterNet3 denoising | ~1.2s |
| Speaker embedding extraction | ~800ms |
| Synthesis RTF | 1.46x |
| Cache hit (repeat request) | 0ms preprocessing |
XTTS-v2 is a zero-shot voice cloner β it has never seen your voice during training. It reliably clones pitch, timbre, and speaking pace. Accent and regional dialect require fine-tuning, which is outside the scope of this project.
Best results with reference audio that is 8β15 seconds, expressive (not flat monotone), and recorded in a quiet environment. For already-clean recordings use --no-denoise to skip denoising.
- Python 3.10 or 3.11 (not 3.12)
- NVIDIA GPU with CUDA support (CPU works but is slow)
- ~2.5 GB disk space for XTTS-v2 model weights
- ~500 MB for DeepFilterNet3 weights (downloaded on first use)
# 1. Clone the repo
git clone https://github.com/YOUR_USERNAME/voxforge.git
cd voxforge
# 2. Create and activate virtual environment
python -m venv venv
# Windows
.\venv\Scripts\activate
# Linux / Mac
source venv/bin/activate
# 3. Install PyTorch with CUDA (adjust cu118 to match your CUDA version)
pip install torch==2.1.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu118
# 4. Install remaining dependencies
pip install -r requirements.txt
# 5. Download XTTS-v2 weights β first run only, around 1.8 GB
python -c "from TTS.api import TTS; TTS('tts_models/multilingual/multi-dataset/xtts_v2', agree=True)"# Built-in speaker (Phase 1 mode)
python synthesize.py "Hello, this is VoxForge speaking."
# Custom output path
python synthesize.py "Your text here." --output outputs/my_audio.wav
# Different built-in speaker
python synthesize.py "Your text here." --speaker "Craig Gutsy"
# Voice cloning from reference audio (Phase 2 mode)
python synthesize.py "Your text here." --reference reference_audio/my_voice.wav
# Voice cloning without denoising (recommended for clean recordings)
python synthesize.py "Your text here." --reference reference_audio/my_voice.wav --no-denoise
# Force re-extract embedding even if cached
python synthesize.py "Your text here." --reference reference_audio/my_voice.wav --force-reprocessAvailable built-in speakers: Ana Florence, Claribel Dervla, Daisy Studious, Gracie Wise, Tammie Ema, Alison Dietlinde, Craig Gutsy, Damien Black
For best voice cloning results:
- Duration: 8β15 seconds (sweet spot), minimum 3s, maximum 30s
- Content: natural expressive speech, not flat monotone
- Environment: quiet room, consistent volume, no background music
- Format: WAV or MP3, any sample rate (resampled automatically)
- Use
--no-denoiseif recording in a clean environment
python tests/test_normalizer.py
python tests/test_chunker.py
python tests/test_speaker_cache.pyvoxforge/
βββ voxforge/ # Core package
β βββ __init__.py
β βββ normalizer.py # Text normalization
β βββ chunker.py # Sentence chunking
β βββ engine.py # XTTS-v2 inference engine
β βββ pipeline.py # End-to-end pipeline
β βββ audio_processor.py # Reference audio preprocessing (Phase 2)
β βββ speaker_cache.py # Persistent embedding cache (Phase 2)
βββ tests/ # Unit tests
β βββ test_normalizer.py
β βββ test_chunker.py
β βββ test_speaker_cache.py
βββ reference_audio/ # Reference clips for voice cloning (git-ignored)
βββ outputs/ # Synthesized audio (git-ignored)
βββ models/ # Speaker cache + model overrides (git-ignored)
βββ synthesize.py # CLI entry point
βββ requirements.txt
βββ CHANGELOG.md
βββ README.md
| Component | Library |
|---|---|
| TTS Model | coqui-tts β XTTS-v2 |
| Deep Learning | PyTorch 2.1 + CUDA 11.8 |
| Text Normalization | num2words, inflect |
| Sentence Splitting | pysbd |
| Audio I/O | soundfile, torchaudio |
| Voice Activity Detection | webrtcvad-wheels |
| Neural Denoising | deepfilternet (DeepFilterNet3) |
| Embedding Cache | Python shelve (Phase 4 β Redis) |
- Phase 3: ONNX export, FP16 inference, chunked streaming, latency profiling
- Phase 4: FastAPI REST endpoints, Docker container, streaming response, Redis cache
- Phase 5: Full benchmark report β latency, throughput, UTMOS quality scores, speaker similarity analysis