Skip to content
ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

516 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

English | ็ฎ€ไฝ“ไธญๆ–‡ | ็น้ซ”ไธญๆ–‡ | ๆ—ฅๆœฌ่ชž

๐ŸŽ™๏ธ CosyVoice All-in-One Docker

Docker Pulls Docker Image Version License GitHub Stars

Production-ready Text-to-Speech service based on Fun-CosyVoice3-0.5B

One Docker command to get Web UI + REST API + Voice Cloning

Quick Start โ€ข Features โ€ข API Docs โ€ข Performance


๐Ÿ“ธ Screenshot

Web UI

โœจ Features

Feature Description
๐ŸŽฏ Fun-CosyVoice3-0.5B Latest & best TTS model from Alibaba
๐ŸŽค Fun-ASR-Nano Auto speech recognition (replaces Whisper)
๐Ÿ”Œ OpenAI Compatible API Drop-in replacement for /v1/audio/speech
๐Ÿ‘ค Custom Voice Management Upload once, use by voice_id
โšก Real Streaming Output PCM chunk-by-chunk, ~1.2s TTFB
๐Ÿš€ Embedding Cache 53% faster after first use
๐ŸŒ Web UI Beautiful interface with download button
๐ŸŒ Multi-language Chinese, English, Japanese, Korean + 18 dialects

๐Ÿš€ Quick Start

docker run -d \
  --name cosyvoice \
  --gpus '"device=0"' \
  -p 8188:8188 \
  -v cosyvoice-data:/data/voices \
  neosun/cosyvoice:latest

Then open http://localhost:8188 ๐ŸŽ‰

๐Ÿ“ฆ Installation

Prerequisites

  • Docker 20.10+
  • Docker Compose v2.0+ (optional)
  • NVIDIA GPU with 8GB+ VRAM
  • NVIDIA Container Toolkit

Docker Run

# Pull the image
docker pull neosun/cosyvoice:v3.4.0

# Run with GPU
docker run -d \
  --name cosyvoice \
  --gpus '"device=0"' \
  -p 8188:8188 \
  -v /path/to/voices:/data/voices \
  --restart unless-stopped \
  neosun/cosyvoice:v3.4.0

Docker Compose

# docker-compose.yml
services:
  cosyvoice:
    image: neosun/cosyvoice:v3.4.0
    container_name: cosyvoice
    restart: unless-stopped
    ports:
      - "8188:8188"
    volumes:
      - ./voices:/data/voices
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              device_ids: ["0"]
              capabilities: [gpu]
docker compose up -d

Health Check

curl http://localhost:8188/health
# {"status":"healthy","gpu":{"model_loaded":true,...}}

โš™๏ธ Configuration

Environment Variables

Variable Default Description
PORT 8188 Service port
MODEL_DIR pretrained_models/Fun-CosyVoice3-0.5B TTS model path

Volume Mounts

Path Description
/data/voices Custom voice storage (persistent)

๐Ÿ“ก API Reference

Endpoints

Endpoint Method Description
/v1/audio/speech POST Text-to-Speech (OpenAI compatible)
/v1/voices/create POST Create custom voice
/v1/voices/custom GET List custom voices
/v1/voices/{id} GET/DELETE Get/Delete voice
/v1/models GET List models
/health GET Health check
/docs GET Swagger UI

Create Custom Voice

# With text
curl -X POST http://localhost:8188/v1/voices/create \
  -F "audio=@voice.wav" \
  -F "name=MyVoice" \
  -F "text=Reference text content"

# Auto transcribe (using Fun-ASR-Nano)
curl -X POST http://localhost:8188/v1/voices/create \
  -F "audio=@voice.wav" \
  -F "name=MyVoice"

# Response: {"voice_id": "abc123", "text": "auto transcribed text", ...}

Text-to-Speech

# WAV format
curl http://localhost:8188/v1/audio/speech \
  -H "Content-Type: application/json" \
  -d '{"input": "Hello world", "voice": "abc123"}' \
  -o output.wav

# PCM streaming (lowest latency)
curl http://localhost:8188/v1/audio/speech \
  -H "Content-Type: application/json" \
  -d '{"input": "Hello world", "voice": "abc123", "response_format": "pcm"}' \
  -o output.pcm

# Convert PCM to WAV
ffmpeg -f s16le -ar 24000 -ac 1 -i output.pcm output.wav

Python Example

import requests

# Create voice
with open("voice.wav", "rb") as f:
    resp = requests.post(
        "http://localhost:8188/v1/voices/create",
        files={"audio": f},
        data={"name": "MyVoice"}
    )
    voice_id = resp.json()["voice_id"]

# Generate speech
resp = requests.post(
    "http://localhost:8188/v1/audio/speech",
    json={"input": "Hello world", "voice": voice_id}
)
with open("output.wav", "wb") as f:
    f.write(resp.content)

๐Ÿ“Š Performance Benchmarks

Test Environment: NVIDIA L40S GPU

First Token Latency (TTFB)

Text Length TTFB Total Time Audio Duration RTF
Short (4 chars) 1.20s 1.55s 1.88s 0.82x
Short (10 chars) 1.34s 1.75s 2.28s 0.77x
Medium (30 chars) 1.24s 4.98s 6.88s 0.72x
Medium (50 chars) 1.27s 12.52s 17.12s 0.73x
Long (80 chars) 1.24s 17.91s 23.68s 0.76x
Long (120 chars) 1.35s 19.08s 25.32s 0.75x

RTF (Real-Time Factor) < 1.0 means generation is faster than playback

Embedding Cache Effect

Scenario TTFB Note
First use (no cache) ~3.5s Extract + cache to GPU
Cached ~1.2s Direct from cache
Improvement -53%

ASR (Fun-ASR-Nano) Benchmark

Audio Language Duration Recognition Time Result
Voice sample Chinese ~7s 0.40s ๅธŒๆœ›ไฝ ไปฅๅŽ่ƒฝๅคŸๅš็š„ๆฏ”ๆˆ‘่ฟ˜ๅฅฝๅ“Ÿใ€‚
Voice sample Chinese ~7s 0.83s ๅฏน๏ผŒ่ฟ™ๅฐฑๆ˜ฏๆˆ‘ไธ‡ไบบๆ•ฌไปฐ็š„ๅคชไน™็œŸไบบ...
zh.mp3 Chinese ~3s 0.40s ๅผ€ๆ”พๆ—ถ้—ดๆ—ฉไธŠไน็‚น่‡ณไธ‹ๅˆไบ”็‚นใ€‚
en.mp3 English ~5s 0.70s The tribal chieftain called for the boy...
ja.mp3 Japanese ~5s 0.84s ใ†ใกใฎไธญๅญฆใฏๅผๅฝ“ๅˆถใง...

Average recognition time: 0.4-0.8s per audio file

๐Ÿ—ฃ๏ธ Supported Languages

TTS (Fun-CosyVoice3)

  • Main: Chinese, English, Japanese, Korean
  • European: German, Spanish, French, Italian, Russian
  • Chinese Dialects: Cantonese, Sichuan, Dongbei, Shanghai, Minnan + 18 more

ASR (Fun-ASR-Nano)

  • Languages: Chinese, English, Japanese + auto detection
  • Dialects: 7 major Chinese dialects + 26 regional accents
  • Features: High-noise recognition, lyric recognition

๐Ÿ› ๏ธ Tech Stack

๐Ÿ“‹ Changelog

Version Date Changes
v3.4.0 2024-12-18 Fun-ASR-Nano replaces Whisper
v3.3.0 2024-12-18 UI: streaming default, download button, timer
v3.2.1 2024-12-18 Auto preload all voices on startup
v3.2.0 2024-12-18 Embedding cache (-53% TTFB)
v3.1.0 2024-12-18 Polling optimization + model preload
v3.0.0 2024-12-18 All-in-One Docker base version

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

๐Ÿ™ Acknowledgments


โญ Star History

Star History Chart

๐Ÿ“ฑ Follow Us

WeChat

About

๐ŸŽ™๏ธ CosyVoice All-in-One Docker - Production-ready TTS with Web UI, REST API & Voice Cloning

Resources

Code of conduct

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages