A modular, highly efficient infrastructure for fine-tuning both Chatterbox TTS (Standart) and Chatterbox Turbo models with your own dataset and generating high-quality speech synthesis.
This kit is specially designed to support new languages and voices by intelligently extending the model's vocabulary. With the newly added LoRA (Low-Rank Adaptation) support, you can now train high-quality voices faster and with significantly less VRAM.
You can train both the Standart and Turbo models using either Full Fine-Tuning or LoRA.
If you are aiming to fine-tune the Turbo model, you may want to try a Full Fine-Tune first. However, the Turbo architecture's weights can sometimes be quite stubborn to adapt. If you start hearing static noise, hallucinations, or meaningless sounds during training (which you can easily monitor via the automatic
inference_callbackaudio samples), we strongly recommend switching to LoRA (is_lora = True).I have personally trained the Turbo model using LoRA and achieved highly successful, stable results! The LoRA matrices act as a great stabilizer for the base model.
The Ultimate Workflow: Train your model with LoRA, test the adapter directly using
inference.py, and once you are 100% satisfied with the voice quality, runpython merge_lora.py. This will bake the LoRA weights into the base model and give you a single, standalone.safetensorsfile ready for production!
This repository allows you to choose your training strategy using the is_lora flag in src/config.py.
- What is it? LoRA (Low-Rank Adaptation) freezes the massive base model and only trains tiny adapter layers alongside the new language embeddings.
- Best for: Datasets that are 10 hours or less in total duration (which covers 95% of custom voice cloning use cases).
- Benefits: Prevents the model from forgetting its base knowledge (catastrophic forgetting), trains significantly faster, prevents overfitting on small datasets, and uses ~60% less VRAM.
- Output: Saves a lightweight adapter to the
new_lang_adapterfolder instead of a multi-gigabyte model file.
- What is it? Unfreezes and updates every single weight inside the T3 Transformer model.
- Best for: Massive, studio-grade datasets that are strictly larger than 10 hours where you want to completely overwrite the model's fundamental acoustic understanding.
- Drawbacks: Requires massive GPU VRAM, takes much longer to train, and risks ruining the base model's voice quality if the dataset is too small.
This repository operates in two distinct modes, controlled by the is_turbo setting in src/config.py. Please decide which mode you need before you begin.
- Architecture: Llama-based.
- Tokenizer: Grapheme (character) based. The
tokenizer.jsondownloaded bysetup.pycontains a small, efficient vocabulary (~2,454 tokens) covering 23 languages. - Best for: Training a model with full control over a specific language from a more fundamental level.
- Architecture: GPT-2 based.
- Tokenizer: BPE-based. It starts with a large, powerful English vocabulary (~50,000+ tokens).
- Smart Merging: When you run
setup.py, this large vocabulary is automatically extended with our multi-language grapheme set. - Best for: Leveraging a strong English base for faster, high-quality fine-tuning on other languages.
If you plan to switch between Standard Mode (is_turbo = False) and Turbo Mode (is_turbo = True), you MUST completely delete the pretrained_models directory and the preprocessed_dir directory created with the preprocess = True operation before running the setup.py file again.
The setup script replaces the token files in place. If you run the setup for Standard mode after setting up for Turbo (or vice versa), the token files will become corrupted and cause errors that are difficult to debug during training.
Correct Workflow for Changing Modes:
- DELETE the entire
pretrained_modelsfolder.
# On Linux or macOS
rm -rf pretrained_models
# On Windows (in Command Prompt)
rmdir /s /q pretrained_models-
Update the
src/config.pyfile, setting theis_turboflag to your desired new mode and settingpreprocess = Trueif it is False. -
RUN setup.py again to download and prepare the correct files for the new mode.
python setup.py- Update the
new_vocab_sizevalue in thesrc/config.pyfile with the new value provided by the setup script. Also ensurepreprocess = True.
This repository uses an offline preprocessing strategy to maximize training speed. This script processes all audio files, extracts speaker embeddings and acoustic tokens, and saves them as .pt files.
Chatterbox uses a grapheme-based (character-level) tokenizer. The tokenizer.json file downloaded by setup.py includes support for 23 languages from the original Chatterbox repository, covering most common characters across multiple languages.
- Default Support: The provided tokenizer already includes characters for English, Turkish, French, German, Spanish, and 18+ other languages
- When to customize: If your target language has special characters not covered in the default tokenizer, you can create a custom
tokenizer.json - Examples of special characters by language:
- Turkish:
Γ§, Δ, Ε, ΓΆ, ΓΌ, Δ± - French:
Γ©, Γ¨, Γͺ, Γ , ΓΉ, Γ§ - German:
Γ€, ΓΆ, ΓΌ, Γ - Spanish:
Γ±, Γ‘, Γ©, Γ, Γ³, ΓΊ
- Turkish:
- Critical: The
new_vocab_sizevariable insrc/config.pymust exactly match the total number of tokens in yourtokenizer.jsonfile - Default vocab size: Check the downloaded
tokenizer.jsonto see the exact token count, then setnew_vocab_sizeaccordingly.
- Training (Input): Chatterbox's encoder and T3 module work with 16,000 Hz (16kHz) audio. Even if your dataset uses different rates,
dataset.pyautomatically resamples to 16kHz. - Output (Inference): The model's vocoder generates audio at 24,000 Hz (24kHz).
chatterbox-finetune/
βββ pretrained_models/ # setup.py downloads required models here
βββ MyTTSDataset/ # Your custom dataset in LJSpeech format
βββ FileBasedDataset/ # Your custom dataset in File-Based format
βββ speaker_reference/ # Speaker reference audio files
βββ src/
β βββ config.py # All settings and hyperparameters
β βββ dataset.py # Data loading and processing
β βββ model.py # Model weight transfer and training wrapper
β βββ inference_callback.py # Callbacks for checking audio during training
β βββ preprocess_*.py # Preprocessing scripts (LJSpeech, JSON, etc.)
β βββ utils.py # Logger and VAD utilities
βββ train.py # Main training script (Handles LoRA & Full)
βββ inference.py # Smart speech synthesis script
βββ merge_lora.py # Bakes LoRA weights into the base model
βββ setup.py # Setup script for downloading models
βββ requirements.txt # Required dependencies
βββ README.md # This file
Requires Python 3.8+ and GPU (recommended):
Install FFmpeg (Required):
# on Ubuntu or Debian
sudo apt update && sudo apt install ffmpeg
# on Arch Linux
sudo pacman -S ffmpeg
# on MacOS using Homebrew (https://brew.sh/)
brew install ffmpeg
# on Windows using Chocolatey (https://chocolatey.org/)
choco install ffmpeg
# on Windows using Scoop (https://scoop.sh/)
scoop install ffmpegInstall Python Dependencies:
git clone https://github.com/gokhaneraslan/chatterbox-finetuning.git
cd chatterbox-finetuning
pip install -r requirements.txtThis multi-step process prepares all necessary files based on your chosen mode. This script downloads the necessary base models (ve, s3gen, t3) and default tokenizer. Must be run before training.
Step 2.1: Choose Your Mode
Open src/config.py and set the is_turbo variable to True or False.
Step 2.2: Run the Setup Script This command will download the correct model files. If Turbo mode is enabled, it will also automatically merge the tokenizers for you.
python setup.pyStep 2.3: Update Config (Turbo Mode ONLY)
If you ran the setup in Turbo mode, the script will output a final message like this:
Please update the 'new_vocab_size' in 'src/config.py' to the following value: 52260
Copy this exact number and paste it into the new_vocab_size variable in src/config.py. Do not skip this step!
During training, the script loads the original model weights, intelligently resizes them for the new vocabulary size, and initializes new tokens using mean initialization from existing tokens for faster adaptation.
We recommend using the TTS Dataset Generator tool to automatically create high-quality datasets from audio or video files.
Quick Start:
# Install the dataset generator
git clone https://github.com/gokhaneraslan/tts-dataset-generator.git
cd tts-dataset-generator
pip install -r requirements.txt
# Generate dataset from your audio/video file
python main.py --file your_audio.mp4 --model large --language en --ljspeech TrueThis will automatically segment audio, transcribe it via Whisper AI, and format it for the MyTTSDataset/ folder.
Your dataset should follow the LJSpeech format with a CSV file (filename|raw_text|normalized_text).
Dataset Quality Requirements:
- Sample rate: 16kHz, 22.05kHz, or 44.1kHz (will be resampled to 16kHz automatically)
- Format: WAV (mono or stereo - will be converted to mono automatically)
- Duration: 3-10 seconds per segment (optimal for TTS)
- Minimum total duration: 30+ minutes for basic training
- Audio quality: Clean, minimal background noise
Most Important Settings:
# In src/config.py
# --- Model Selection ---
is_turbo: bool = True # True for Turbo, False for Normal.
# --- Training Strategy (NEW) ---
is_lora: bool = True # True: Efficient LoRA training (Recommended for < 10h data)
# False: Full Fine-Tune (High VRAM, for massive datasets)
# If is_lora = True, these settings apply:
lora_r: int = 64
lora_alpha: int = 128
lora_target_modules = ["c_attn", "c_proj", "c_fc", "spkr_enc"]
lora_modules_to_save = ["text_emb", "text_head"] # Auto-trains new vocab embeddings
# --- Vocabulary ---
new_vocab_size: int = 52260 if is_turbo else 2454
# --- Dataset Format ---
ljspeech = False # True for metadata.csv format
json_format = True # True for JSON formatted datasets
preprocess = True # Set to False ONLY if you already preprocessed the datasetpython train.py- If
is_lora = True, your trained model will be saved insidechatterbox_output/new_lang_adapter/. - If
is_lora = False, your trained model will be saved aschatterbox_output/t3_turbo_finetuned.safetensors(ort3_finetuned).
The inference script is smart. Based on your src/config.py settings, it will automatically detect whether you trained a LoRA adapter or a Full model and merge the weights on-the-fly.
Place a clean, 3-10 second reference .wav file in speaker_reference/reference.wav.
Edit inference.py to set your desired text:
TEXT_TO_SAY = "Merhaba, sesimi geliΕtirmem oldukΓ§a uzun zaman aldΔ± ve Εimdi sahip olduΔuma gΓΆre, sessiz kalmayacaΔΔ±m."
AUDIO_PROMPT = "./speaker_reference/2.wav"Run inference:
python inference.pyThe output will be saved as output.wav (24kHz). The script automatically handles sentence splitting, concatenates pauses, and uses Silero VAD to trim silence/hallucinations at the end of generated audio.
Once you have tested your LoRA using inference.py and are completely satisfied with the results, you should pack (merge) it into a single file for deployment or sharing.
python merge_lora.pyThis process takes your base model and bakes the trained LoRA adapter directly into it. It will generate a standalone t3_turbo_finetuned_merged.safetensors file that you can use in production without needing PEFT or adapter folders anymore!
Original Chatterbox training pipelines often process audio "on-the-fly" (resampling, feature extraction) during training. This causes the GPU to wait for the CPU, slowing down training significantly.
By running preprocess.py, we:
- Extract Speaker Embeddings (Voice Encoder)
- Extract Acoustic Tokens (S3Gen)
- Tokenize Text
- Save everything as optimized PyTorch tensors (
.pt) This allows thedataset.pyto simply load tensors, maximizing GPU utilization.
Turbo Model Tokenizer (Smart Vocab Extension):
Turbo mode uses GPT-2's powerful BPE tokenizer as a base. The setup.py script performs a "Vocab Extension": it intelligently adds all unique characters from our 23-language grapheme set to the GPT-2 vocabulary. This process ensures that:
- The model retains its powerful knowledge of English words and structures.
- Special characters from other languages (e.g.,
Δ, Ε, Δ±for Turkish;Γ©, Γ , Γ§for French) are recognized as single, whole tokens, dramatically improving learning efficiency. - You do not need to create a custom tokenizer manually. The setup is fully automated.
During inference, inference.py uses Silero VAD to prevent hallucinations and sentence-ending elongations. This automatically trims unwanted silence and noise from generated audio.
All audio processing uses FFmpeg for professional-quality results:
- Input: Automatic conversion to mono (1 channel)
- Resampling: Automatic resampling to required sample rates
- Training: 16kHz processing
- Output: 24kHz, 16-bit PCM WAV format
Error: RuntimeError: Error(s) in loading state_dict for T3... size mismatch
- Solution:
new_vocab_sizein config doesn't match the token count intokenizer.json. Count the tokens in your json and update the config file.
Error: FileNotFoundError: ... ve.safetensors
- Solution: You haven't downloaded base models. Run
python setup.py.
Error: CUDA out of memory
- Solution: Enable
is_lora = True. If still OOM, reduceBATCH_SIZEinsrc/config.pyand increasegrad_accum. Gradient Checkpointing is already enabled by default.
Poor Quality Output:
- Check reference audio quality (should be clean, at least 5 seconds).
- Ensure adequate training data (minimum 30 minutes recommended).
- If training the Turbo model, switch to LoRA as it is much more stable than Full Fine-Tuning.
Based on the Chatterbox TTS model architecture. Special thanks to the original authors and contributors.
For issues and questions, please review src/config.py options or open an issue on GitHub with detailed error logs.