All apps · 0 apps
CosyVoice3-API
Docker app from hsiang's Repository
Overview
Readme
View on GitHubCosyVoice3-API
OpenAI-compatible Text-to-Speech API powered by CosyVoice 3 (Alibaba FunAudioLLM).
Zero-shot voice cloning with 3-second reference audio. Register voices once, use them forever. Supports RTX 50-series (Blackwell) GPUs.
Features
- OpenAI-compatible
/v1/audio/speechendpoint (JSON body) - Zero-shot voice cloning from any reference audio
- Voice registration — clone once, use by name afterwards
- Streaming output support (
"stream": truereturns raw PCM) - 9 languages, 18 Chinese dialects
- Supports RTX 50-series (Blackwell) and older GPUs
Quick Start
docker run -d --gpus all --shm-size=2g \
-p 8080:8080 \
-v /mnt/user/appdata/cosyvoice3-api/models:/root/.cache/models \
-e HF_ENDPOINT=https://huggingface.co \
--name cosyvoice3-api \
ghcr.io/hsiang-han/cosyvoice3-api:latest
First start downloads model files (~10GB) from HuggingFace. China users: set HF_ENDPOINT=https://hf-mirror.com for faster downloads.
Usage
Step 1: Register a voice (required for first use)
CosyVoice3 has no built-in voices. You need to register at least one voice from a reference audio:
curl -X POST http://localhost:8080/v1/voices/register \
-F "voice_id=my_voice" \
-F "prompt_text=这是参考音频中说的话的文字内容" \
-F "prompt_wav=@reference.wav"
Registered voices persist across container restarts.
Step 2: Generate speech
curl -X POST http://localhost:8080/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"input": "你好,世界", "voice": "my_voice"}' \
--output speech.wav
Streaming output
curl -X POST http://localhost:8080/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"input": "你好,世界", "voice": "my_voice", "stream": true}' \
--output speech.pcm
Returns raw PCM (16-bit, mono, 24000Hz). Headers include X-Sample-Rate, X-Channels, X-Bit-Depth.
Voice cloning (one-off, without registration)
curl -X POST http://localhost:8080/v1/audio/speech/clone \
-F "input=这是克隆的声音" \
-F "prompt_text=这是参考音频中说的话" \
-F "prompt_wav=@reference.wav" \
--output cloned.wav
List / delete voices
curl http://localhost:8080/v1/voices
curl -X DELETE http://localhost:8080/v1/voices/my_voice
API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/v1/audio/speech |
POST | Text-to-speech (JSON body, OpenAI-compatible) |
/v1/audio/speech/clone |
POST | One-off voice cloning (Form + file upload) |
/v1/voices/register |
POST | Register a voice from reference audio |
/v1/voices/{voice_id} |
DELETE | Delete a registered voice |
/v1/voices |
GET | List registered voices |
/v1/models |
GET | List models |
/health |
GET | Health check |
/docs |
GET | Swagger documentation |
Environment Variables
| Variable | Default | Description |
|---|---|---|
| MODEL_DIR | FunAudioLLM/Fun-CosyVoice3-0.5B-2512 | HuggingFace model ID or local path |
| HF_ENDPOINT | https://huggingface.co | HuggingFace mirror (China: https://hf-mirror.com) |
| FP16 | true | Half-precision inference. Reduces VRAM ~50% |
Hardware Requirements
- NVIDIA GPU with 4GB+ VRAM (FP16) or 8GB+ (FP32)
- NVIDIA driver 550+ (Ampere/Ada) or 570+ (Blackwell RTX 50-series)
- Docker with NVIDIA Container Toolkit
Credits
- CosyVoice by Alibaba FunAudioLLM — the model and inference framework
License
Apache-2.0 (same as upstream CosyVoice)
Install CosyVoice3-API on Unraid in a few clicks.
Find CosyVoice3-API in Community Apps on your Unraid server, review the template, and click Install. Unraid handles the Docker app or plugin setup from the published template.
Categories
Related apps
Explore more like this
Explore allDetails
ghcr.io/hsiang-han/cosyvoice3-api:latestRuntime arguments
- Web UI
http://[IP]:[PORT:8080]/docs- Network
bridge- Shell
bash- Privileged
- false
- Extra Params
--gpus all --shm-size=2g
Template configuration
OpenAI-compatible TTS API port. Swagger docs at /docs
- Target
- 8080
- Default
- 8080
- Value
- 8080
Model download cache. First run downloads ~10GB. Persists across container recreates.
- Target
- /root/.cache/models
- Default
- /mnt/user/appdata/cosyvoice3-api/models
- Value
- /mnt/user/appdata/cosyvoice3-api/models
ModelScope cache for wetext (text normalization). Small (~5MB), downloaded once.
- Target
- /root/.cache/modelscope/hub
- Default
- /mnt/user/appdata/cosyvoice3-api/modelscope
- Value
- /mnt/user/appdata/cosyvoice3-api/modelscope
HuggingFace model ID. Restart required after change.
- Target
- MODEL_DIR
- Default
- FunAudioLLM/Fun-CosyVoice3-0.5B-2512
- Value
- FunAudioLLM/Fun-CosyVoice3-0.5B-2512
HuggingFace download endpoint. China users: change to https://hf-mirror.com for faster downloads.
- Target
- HF_ENDPOINT
- Default
- https://huggingface.co
- Value
- https://huggingface.co
Half-precision inference. Reduces VRAM by ~50%. Disable (false) only if you experience quality issues.
- Default
- true
- Value
- true
GPU selection (all, 0, 1, etc.)
- Target
- NVIDIA_VISIBLE_DEVICES
- Default
- all
- Value
- all
NVIDIA driver capabilities
- Target
- NVIDIA_DRIVER_CAPABILITIES
- Default
- compute,utility
- Value
- compute,utility