Overview
The Qwen3-TTS repository includes comprehensive example scripts demonstrating various use cases and model types. All examples are available in the examples/ directory on GitHub.Available Examples
CustomVoice Model
Test CustomVoice model with 9 premium speakers and instruction control
VoiceDesign Model
Generate voices from natural language descriptions
Base Model (Voice Clone)
3-second voice cloning with reference audio
Tokenizer Usage
Encode and decode audio with Qwen3-TTS-Tokenizer
Example Details
test_model_12hz_custom_voice.py
Demonstrates usage of the CustomVoice model with predefined speakers. Features:- Single and batch inference
- Language selection (Chinese, English, etc.)
- Speaker selection from 9 premium voices
- Instruction-based control (tone, emotion, style)
test_model_12hz_voice_design.py
Shows how to design custom voices using natural language descriptions. Features:- Voice creation from text descriptions
- Single and batch generation
- Multilingual voice design
- Emotional and stylistic control
test_model_12hz_base.py
Comprehensive voice cloning examples with the Base model. Features:- Voice cloning from reference audio
- Single and batch voice cloning
- Reusable voice clone prompts
- X-vector only mode
- Multiple clone modes (ICL and x-vector)
test_tokenizer_12hz.py
Demonstrates audio encoding and decoding with the tokenizer. Features:- Single and batch audio encoding
- Audio decoding from codes
- Multiple input formats (URLs, paths, numpy arrays)
- Dict and list payload handling
Common Patterns
Model Initialization
All examples use a consistent pattern for loading models:Batch Processing
All generation methods support batch inference:Saving Output
All examples usesoundfile for saving audio:
Running Examples
Prerequisites
Clone Repository
Run Examples
Examples will automatically download model weights on first run. Ensure you have sufficient disk space and a stable internet connection.
Advanced Usage
For more advanced usage patterns, including:- Voice design then clone workflow
- Reusable voice prompts
- Custom generation parameters
- Streaming generation
Troubleshooting
CUDA out of memory
CUDA out of memory
Try reducing batch size or using a smaller model variant (0.6B instead of 1.7B).
FlashAttention installation fails
FlashAttention installation fails
FlashAttention is optional but improves performance. If installation fails:
Model download is slow
Model download is slow
Use ModelScope for faster downloads in Mainland China:Then load from local path: