CosyVoice3-API

CosyVoice3-API

Docker app from hsiang's Repository

Overview

OpenAI-compatible Text-to-Speech API powered by CosyVoice 3 (Alibaba FunAudioLLM). State-of-the-art Chinese TTS with 18 dialects and 9 languages. NOTE: This model has NO built-in voices. You must register a voice first by uploading a 3-second reference audio via the /v1/voices/register endpoint, or use /v1/audio/speech/clone for one-off cloning. CUDA 12.8 (Blackwell/Ada/Ampere). First start downloads model files (~10GB) from HuggingFace. Supports RTX 50-series GPUs. China users: set HF_ENDPOINT to https://hf-mirror.com for faster downloads. Requires NVIDIA GPU with driver 550+.

CosyVoice3-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/speech endpoint (JSON body)
  • Zero-shot voice cloning from any reference audio
  • Voice registration — clone once, use by name afterwards
  • Streaming output support ("stream": true returns 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.

Open the Apps tab on your Unraid server Search Community Apps for CosyVoice3-API Review the template variables and paths Click Install

Related apps

Details

Repository
ghcr.io/hsiang-han/cosyvoice3-api:latest
Last Updated2026-06-23
First Seen2026-06-08

Runtime arguments

Web UI
http://[IP]:[PORT:8080]/docs
Network
bridge
Shell
bash
Privileged
false
Extra Params
--gpus all --shm-size=2g

Template configuration

API PortPorttcp

OpenAI-compatible TTS API port. Swagger docs at /docs

Target
8080
Default
8080
Value
8080
Model CachePathrw

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 CachePathrw

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
Model IDVariable

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 EndpointVariable

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
FP16Variable

Half-precision inference. Reduces VRAM by ~50%. Disable (false) only if you experience quality issues.

Default
true
Value
true
NVIDIA Visible DevicesVariable

GPU selection (all, 0, 1, etc.)

Target
NVIDIA_VISIBLE_DEVICES
Default
all
Value
all
NVIDIA Driver CapabilitiesVariable

NVIDIA driver capabilities

Target
NVIDIA_DRIVER_CAPABILITIES
Default
compute,utility
Value
compute,utility