-
-
Notifications
You must be signed in to change notification settings - Fork 142
XTTS Model Finetuning Guide (Simple Version)
- Quick Start Guide
- Core Concepts
- Technical Deep Dives
- Troubleshooting & Optimization
- Deploying Your Model
- Hardware: Nvidia GPU with at least 12GB VRAM (Windows) or 16GB VRAM (Linux)
- Software: CUDA 11.8 toolkit
- Data: Minimum 2 minutes of clean voice samples (MP3, WAV, or FLAC)
- Storage: 18GB of free disk space
-
Prepare Environment:
- Install and launch AllTalk.
- Ensure CUDA toolkit is correctly installed.
- Close any GPU-intensive applications.
-
Prepare Audio:
- Place audio files in
/finetune/put-voice-samples-in-here/
. - Ensure audio is clear, free of background noise, and contains a variety of phrases.
-
Note: During training, temporary files are stored in
finetune/tmp-trn
, and Gradio (if used) manages temporary files infinetune/gradio_temp
.
- Place audio files in
-
Run Finetuning:
- Launch the finetuning script:
# For standalone AllTalk: cd alltalk_tts ./start_finetune.sh # (Linux) start_finetune.bat # (Windows)
- Follow the interface steps:
- Step 1: Generate dataset
- Step 2: Train model
- Step 3: Test results
- Step 4: Export model
- Launch the finetuning script:
-
After Training:
- Save your model.
- Optionally delete training data to free up space.
- Out of Memory: Reduce batch size or use gradient accumulation.
- Poor Quality Output: Verify audio quality and consider increasing training epochs.
- Training Errors: Ensure CUDA is installed and GPU is available.
- Slow Training: Adjust batch size and worker threads for efficiency.
-
Model Detection Issues: Ensure all required files (
config.json
,model.pth
,mel_stats.pth
,speakers_xtts.pth
,vocab.json
,dvae.pth
) are present in themodels/xtts/
folder.
Finetuning is the process of adjusting a pre-trained model using new, specific voice data to better capture unique vocal characteristics. This is useful for creating personalized voice models that retain the base model's general abilities while improving on the nuances of your specific dataset.
When to Finetune:
- Base model doesn’t capture desired vocal qualities.
- Adaptation needed for accents, unique voices, or specific speaking styles.
- Custom voices for particular applications.
- Duration: Minimum of 2 minutes, 5–10 minutes recommended.
- Content: Clear, noise-free, and consistent volume. Avoid background sounds or music.
- Format: MP3, WAV, or FLAC. Any sample rate works, and stereo or mono is supported.
Tips:
- Use varied sentence lengths, tones, and speaking speeds.
- Pre-process to remove background noise, split long files if needed, and ensure content quality.
-
Dataset Generation:
- Audio is segmented and transcribed.
- Dataset split into training and evaluation sets.
-
Model Training:
- Set training parameters and monitor progress. Model learns to emulate the target voice.
- Validation Paths: Paths for validation data and Whisper model transcription are used to validate and monitor quality. Customize these paths if you want to specify a different dataset for validation.
-
Testing:
- Run tests with different text inputs to evaluate quality, pronunciation, and emotional range.
-
Model Export:
- Compact model, save essential files, and clean up training artifacts.
An epoch is a full pass through the dataset. Choose the number of epochs based on the desired outcome:
- Standard voices: 10–20 epochs
- Highly unique voices or accents: 40+ epochs
- Complex voices or new languages: May require 100+ epochs.
Tip: Monitor loss values to avoid overfitting. See Overtraining.
- Small Batch Size (4–8): Lower memory use, more frequent updates.
- Large Batch Size (32–64): Faster processing, requires more memory.
Gradient Accumulation: If VRAM is limited, simulate larger batch sizes with gradient accumulation:
batch_size = 8
gradient_accumulation_steps = 4 # Effective batch size = 32
Controls how quickly the model learns:
- 1e-6 to 5e-6: Stable, slow learning.
- 1e-5: Balanced, suitable for most cases.
- 1e-3 and higher: Fast but can be unstable.
Schedulers: Use learning rate scheduling (e.g., cosine annealing or exponential decay) for better results over long training runs.
- Windows: Can use system RAM as extended VRAM.
- Linux: Limited to physical VRAM, requiring higher VRAM for reliable operation.
Optimization Strategies:
- Lower batch size or increase gradient accumulation if memory is limited.
- Adjust worker threads and limit audio length for efficiency.
- Signal Handling: Use the GUI’s stop option or standard interrupts to safely halt training without corrupting model state.
The script uses Byte-Pair Encoding (BPE) tokenization, which helps the model handle complex text, diverse languages, accents, and dialects more effectively. This feature allows the model to better manage unique vocabularies and speech patterns.
-
Signs of Good Training Progression:
- Loss values consistently decrease over epochs. Example:
Text Loss: 0.02 -> 0.015 -> 0.012 Mel Loss: 4.5 -> 3.8 -> 3.2 Average Loss: 4.0 -> 3.5 -> 3.0
- Model saves as "BEST MODEL" at new performance milestones.
- Loss values consistently decrease over epochs. Example:
-
Recognizing Overtraining:
- Loss values plateau or start increasing, e.g.,:
Epoch 5: Text Loss = 0.009, Mel Loss = 2.9 Epoch 7: Text Loss = 0.010, Mel Loss = 3.1 # Performance worsening
- Solutions: Implement early stopping, reduce training epochs, or lower learning rate.
- Loss values plateau or start increasing, e.g.,:
-
Hardware:
- Adjust batch size based on GPU capability.
- Optimize worker count and monitor VRAM.
-
Configuration:
- Use efficient settings, e.g., float16 precision if supported.
- Regularly monitor memory and processing efficiency.
- Adjust
gradient_accumulation_steps
for limited VRAM.
-
Progress Monitoring:
- The Gradio interface shows a
refresh_symbol
(🔄) to indicate ongoing processes, making it easier to track training progress.
- The Gradio interface shows a
After finetuning, export and organize the model files:
-
Essential Files:
-
model.pth
: Main model -
config.json
: Configuration settings -
vocab.json
: Tokenizer vocabulary -
speakers_xtts.pth
: Speaker embeddings
-
-
Storage Requirements:
- Model size: ~1.5GB
- Reference audio varies based on content.
Folder Structure:
models/
└── xtts/
└── your_model_name/
├── model.pth
├── config.json
├── vocab.json
└── speakers_xtts.pth
Performance Tuning:
- Optimize batch size, VRAM usage, and inference parameters for production.