Sign inSign up

thorstenvoice/cosyvoice-tts

By thorstenvoice

•Updated 3 months ago

Image
Internet of things
Machine learning & AI
Content management system
0

2.1K

thorstenvoice/cosyvoice-tts repository overview

⁠Thorsten-Voice · CosyVoice TTS Server

German Text-to-Speech in a Docker container, powered by CosyVoice3⁠ and fine-tuned on the Thorsten-Voice⁠ dataset.

Send a text via HTTP and get a WAV audio file back. That's it.

⁠Quickstart

docker run -p 8000:8000 \
  -v cosyvoice_models:/app/CosyVoice/pretrained_models \
  thorstenvoice/cosyvoice-tts

First start: the models are downloaded automatically (~8.5 GB). This takes 5–15 minutes depending on your connection. Subsequent starts are fast (~30 seconds) since the models are cached in the volume.

Once you see Uvicorn running on http://0.0.0.0:8000, the server is ready.

⁠Generate audio

curl -X POST http://localhost:8000/tts \
     -F "text=Hallo, ich bin Thorsten. Schön, dass du da bist." \
     --output thorsten.wav

That's all — thorsten.wav contains the synthesized speech.

⁠Options

Adjust speaking speed (0.5 = slow, 1.0 = normal, 2.0 = fast):

curl -X POST http://localhost:8000/tts \
     -F "text=Das hier wird etwas langsamer gesprochen." \
     -F "speed=0.85" \
     --output output.wav

Synthesize multiple sentences into one file:

curl -X POST http://localhost:8000/tts_batch \
     -F $'texts=Erster Satz.\nZweiter Satz.\nDritter Satz.' \
     --output batch.wav

Check if the server is running:

curl http://localhost:8000/health
# {"status":"ok","model":"CosyVoice3-Thorsten"}

Create a docker-compose.yml:

services:
  cosyvoice-tts:
    image: thorstenvoice/cosyvoice-tts:cosyvoice3
    ports:
      - "8000:8000"
    volumes:
      - cosyvoice_models:/app/CosyVoice/pretrained_models
    restart: unless-stopped

volumes:
  cosyvoice_models:

Then:

docker compose up

⁠GPU support (Linux + NVIDIA only)

Add the deploy section to your docker-compose.yml:

services:
  cosyvoice-tts:
    image: thorstenvoice/cosyvoice-tts:cosyvoice3
    ports:
      - "8000:8000"
    volumes:
      - cosyvoice_models:/app/CosyVoice/pretrained_models
    restart: unless-stopped
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]

volumes:
  cosyvoice_models:

⁠Change the port

docker run -p 9000:9000 \
  -e PORT=9000 \
  -v cosyvoice_models:/app/CosyVoice/pretrained_models \
  thorstenvoice/cosyvoice-tts

⁠Performance

Benchmarked with these two test texts:

Short (~8 words):

"Hallo, hier ist Thorsten. Schön, dass Du da bist."

Long (~80 words):

"Für mich sind alle Menschen gleich, unabhängig von Geschlecht, sexueller Orientierung, Religion, Hautfarbe oder Geokoordinaten der Geburt. Ich glaube an eine globale Welt, wo jeder überall willkommen ist und freies Wissen und Bildung kostenfrei für jeden zur Verfügung steht. Ich habe meine Stimme der Allgemeinheit gespendet, in der Hoffnung darauf, dass sie in diesem Sinne genutzt wird."

HardwareShort textLong text
MacBook Air M1 (CPU)47s4:30 min
QNAP NAS Intel (CPU)50s—
RunPod RTX 4090 (GPU)2.9s12.9s

GPU is ~16x faster than CPU. Even a mid-range GPU will significantly outperform CPU inference.

⁠Model

This container uses the Thorsten-Voice/CosyVoice3⁠ model, fine-tuned from FunAudioLLM/Fun-CosyVoice3-0.5B-2512⁠ on the Thorsten-Voice 2022.10⁠ dataset.

Tag summary

Content type

Image

Digest

sha256:f4f879664…

Size

6.8 GB

Last updated

3 months ago

docker pull thorstenvoice/cosyvoice-tts