Skip to content

Latest commit

Β 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

VoxForge πŸŽ™οΈ

Real-Time Multi-Speaker Neural TTS System

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.


Architecture

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.


Project Phases

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

Phase 1 β€” Baseline Pipeline

Modules

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

Phase 1 Benchmark (RTX 3050, CUDA 11.8)

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 Timing Breakdown

Stage Time
Text normalization less than 2ms
Sentence chunking less than 14ms
TTS inference 95%+ of total
Audio save less than 170ms

Phase 2 β€” Voice Cloning

How It Works

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

New Modules

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

Phase 2 Benchmark (RTX 3050, reference audio 27.79s, voice ratio 85%)

Stage Time
VAD + validation ~50ms
DeepFilterNet3 denoising ~1.2s
Speaker embedding extraction ~800ms
Synthesis RTF 1.46x
Cache hit (repeat request) 0ms preprocessing

Voice Cloning β€” Known Limitations

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.


Setup

Requirements

  • 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)

Installation

# 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)"

Running

# 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-reprocess

Available built-in speakers: Ana Florence, Claribel Dervla, Daisy Studious, Gracie Wise, Tammie Ema, Alison Dietlinde, Craig Gutsy, Damien Black

Reference Audio Guidelines

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-denoise if recording in a clean environment

Running Tests

python tests/test_normalizer.py
python tests/test_chunker.py
python tests/test_speaker_cache.py

Repository Structure

voxforge/
β”œβ”€β”€ 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

Stack

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)

Roadmap

  • 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

About

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.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages