feat: Add Kokoro TTS FastAPI template (#353) (#403)

* feat: Add Kokoro TTS FastAPI template (#353)  - Add CPU-optimized docker-compose.yml with source build - Add GPU-optimized docker-compose-gpu.yml for NVIDIA support - Add comprehensive template.toml with OpenAI-compatible API docs - Add kokoro-tts.svg logo and meta.json entry - Support streaming audio, timestamps, and multi-language TTS - Resolves #353

* updated the meta.json for the build errors

* removed the docker-compose-gpu.yml file

* Update docker-compose.yml

---------

Co-authored-by: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com>
This commit is contained in:
Harikrishnan Dhanasekaran
2025-12-14 11:10:48 +05:30
committed by GitHub
parent aa48af7856
commit 0aad2a0231
4 changed files with 126 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
services:
kokoro-tts:
build:
context: https://github.com/remsky/Kokoro-FastAPI.git#master
dockerfile: docker/cpu/Dockerfile
restart: unless-stopped
ports:
- 8880
environment:
- MODEL_PATH=/app/models
- DEVICE=${DEVICE:-cpu}
- HOST=0.0.0.0
- PORT=8880
volumes:
- kokoro-models:/app/models
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8880/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
volumes:
kokoro-models:

View File

@@ -0,0 +1,12 @@
<svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="64" height="64" rx="12" fill="#3B82F6"/>
<path d="M16 24C16 20.6863 18.6863 18 22 18H42C45.3137 18 48 20.6863 48 24V40C48 43.3137 45.3137 46 42 46H22C18.6863 46 16 43.3137 16 40V24Z" fill="white"/>
<path d="M24 28H40V32H24V28Z" fill="#3B82F6"/>
<path d="M24 34H36V38H24V34Z" fill="#3B82F6"/>
<circle cx="32" cy="42" r="2" fill="#3B82F6"/>
<path d="M20 22L44 22" stroke="#3B82F6" stroke-width="2" stroke-linecap="round"/>
<path d="M20 26L44 26" stroke="#3B82F6" stroke-width="2" stroke-linecap="round"/>
<path d="M20 30L44 30" stroke="#3B82F6" stroke-width="2" stroke-linecap="round"/>
<path d="M20 34L44 34" stroke="#3B82F6" stroke-width="2" stroke-linecap="round"/>
<path d="M20 38L44 38" stroke="#3B82F6" stroke-width="2" stroke-linecap="round"/>
</svg>

After

Width:  |  Height:  |  Size: 885 B

View File

@@ -0,0 +1,72 @@
[variables]
main_domain = "${domain}"
device = "cpu"
[config]
env = [
"DEVICE=${device}",
"MODEL_PATH=/app/models",
"HOST=0.0.0.0",
"PORT=8880",
"PYTHONUNBUFFERED=1",
"UV_SYSTEM_PYTHON=1"
]
[[config.domains]]
serviceName = "kokoro-tts"
port = 8880
host = "${main_domain}"
path = "/"
[[config.mounts]]
filePath = "README.md"
content = """# Kokoro TTS FastAPI
This template provides a Dockerized FastAPI wrapper for the Kokoro-82M text-to-speech model.
## Features
- Multi-language support (English, Japanese, Chinese)
- OpenAI-compatible speech endpoint
- CPU and GPU support
- Web interface for monitoring
- RESTful API with comprehensive documentation
- Streaming audio generation
- Word-level timestamps and phonemes
## Usage
- **Web Interface**: Access the web UI at `https://${main_domain}/web`
- **API Documentation**: Available at `https://${main_domain}/docs`
- **Health Check**: Monitor service health at `https://${main_domain}/health`
## Configuration
The service runs on port 8880 and supports both CPU and GPU inference.
For GPU support, ensure your Dokploy instance has NVIDIA GPU support enabled.
## API Endpoints
- `POST /v1/audio/speech` - Generate speech from text (OpenAI compatible)
- `POST /dev/captioned_speech` - Generate speech with timestamps
- `POST /dev/phonemize` - Convert text to phonemes
- `POST /dev/generate_from_phonemes` - Generate audio from phonemes
- `GET /health` - Health check endpoint
- `GET /docs` - Interactive API documentation
- `GET /web` - Web interface
## Model Information
- Model: Kokoro-82M
- License: Apache-2.0
- Repository: https://github.com/remsky/Kokoro-FastAPI
- HuggingFace Model: https://huggingface.co/hexgrad/Kokoro-82M
## Notes
- This template builds the image from source during deployment
- Uses CPU-optimized Dockerfile by default
- Initial build may take several minutes due to model download
- Ensure sufficient disk space for model storage
- For GPU support, change dockerfile path to `docker/gpu/Dockerfile` in docker-compose.yml
"""

View File

@@ -3195,6 +3195,25 @@
"personal"
]
},
{
"id": "kokoro-tts",
"name": "Kokoro TTS",
"version": "latest",
"description": "Dockerized FastAPI wrapper for the Kokoro-82M text-to-speech model with multi-language support and OpenAI-compatible endpoints.",
"logo": "kokoro-tts.svg",
"links": {
"github": "https://github.com/remsky/Kokoro-FastAPI",
"website": "https://github.com/remsky/Kokoro-FastAPI",
"docs": "https://github.com/remsky/Kokoro-FastAPI#readme"
},
"tags": [
"text-to-speech",
"ai",
"voice",
"fastapi",
"openai-compatible"
]
},
{
"id": "kokoro-web",
"name": "Kokoro Web",