- Python 3.10+
- CUDA 12.x (for GPU) or CPU-only mode
- ffmpeg (for audio format conversion)
- 4-8GB VRAM (GPU) or 8-16GB RAM (CPU)
GPU Setup:
# Clone repository
git clone https://github.com/your-repo/Qwen3-TTS-FastAPI.git
cd Qwen3-TTS-FastAPI
# Copy environment file
cp .env.example .env
# Edit .env to configure model and settings
nano .env
# Build and run
docker-compose up -dCPU Setup:
docker-compose -f docker-compose.cpu.yml up -d# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# or: venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Install ffmpeg
# Ubuntu/Debian:
sudo apt install ffmpeg
# macOS:
brew install ffmpeg
# Windows: Download from https://ffmpeg.org/download.html
# Copy and configure environment
cp .env.example .env
nano .env
# Run server
cd app
python server.pyEdit .env file:
# Model Selection
MODEL_NAME=0.6B # Options: 0.6B, 1.7B, or full HuggingFace path
# Full paths:
# - Qwen/Qwen3-TTS-12Hz-0.6B-Base
# - Qwen/Qwen3-TTS-12Hz-0.6B-CustomVoice
# - Qwen/Qwen3-TTS-12Hz-1.7B-Base
# - Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice
# - Qwen/Qwen3-TTS-12Hz-1.7B-VoiceDesign
# Device
DEVICE=cuda:0 # cuda:0, cuda:1, or cpu
# Server
HOST=0.0.0.0
PORT=8880
# Defaults
DEFAULT_VOICE=aiden
DEFAULT_FORMAT=mp3
DEFAULT_LANGUAGE=English
# Paths (Docker uses /app paths)
VOICES_DIR=/app/voices
CACHE_DIR=/app/cache| Model | VRAM | Features |
|---|---|---|
0.6B (0.6B-CustomVoice) |
~2GB | Preset speakers, voice cloning |
1.7B (1.7B-CustomVoice) |
~4GB | Preset speakers, voice cloning, style instruction |
Qwen/Qwen3-TTS-12Hz-0.6B-Base |
~2GB | Voice cloning only (no presets) |
Qwen/Qwen3-TTS-12Hz-1.7B-VoiceDesign |
~4GB | All features + voice design from text |
Default internal port is 8880. Docker maps this to external ports:
# docker-compose.yml
ports:
- "8005:8880" # Access at localhost:8005curl http://localhost:8880/healthExpected response:
{
"status": "healthy",
"model": "Qwen/Qwen3-TTS-12Hz-0.6B-CustomVoice",
"device": "cuda:0",
"has_preset_speakers": true,
"supports_voice_design": false,
"supports_voice_cloning": true,
"supports_streaming": true,
"supports_style_instruction": false
}curl -X POST http://localhost:8880/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"input": "Hello, this is a test.", "voice": "aiden"}' \
--output test.mp3
# Play the audio
ffplay test.mp3Open browser: http://localhost:8880/web/
Open browser: http://localhost:8880/docs
- Use a smaller model (
MODEL_NAME=0.6B) - Use CPU mode (
DEVICE=cpu) - Close other GPU applications
Warning: flash-attn is not installed
This is normal for CPU mode. Flash Attention is GPU-only and not required.
Install ffmpeg:
# Ubuntu/Debian
sudo apt install ffmpeg
# macOS
brew install ffmpeg
# Docker images include ffmpegModels are downloaded from HuggingFace on first run. Set cache directory:
export HF_HOME=/path/to/cacheOr in Docker, mount a volume:
volumes:
- ./hf_cache:/root/.cache/huggingfacechmod 755 voices/
# Or in Docker, check volume permissionsA separate Gradio interface is available:
cd ui
pip install gradio requests
python app.pyOr with Docker:
docker-compose --profile ui up -dAccess at: http://localhost:7860
Configure TTS in Open WebUI settings:
- TTS Engine: OpenAI
- API Base URL:
http://localhost:8880/v1 - API Key: (leave empty or any value)
- Model:
tts-1 - Voice:
aiden(or any available voice)