mirror of
https://github.com/remsky/Kokoro-FastAPI.git
synced 2025-08-05 16:48:53 +00:00
Dockerized FastAPI wrapper for Kokoro-82M text-to-speech model w/CPU ONNX and NVIDIA GPU PyTorch support, handling, and auto-stitching
fastapihuggingface-spaceskokorokokoro-ttsonnxonnxruntimeopenai-compatible-apiopenwebuipytorchsillytavernttstts-apiuv
![]() - Set up FastAPI application with TTS service - Define API endpoints for TTS generation and voice listing - Implement Pydantic models for request and response schemas - Add Dockerfile and docker-compose.yml for containerization - Include example usage and benchmark results in README |
||
---|---|---|
api/src | ||
examples | ||
.gitignore | ||
docker-compose.yml | ||
Dockerfile | ||
README.md |
Kokoro TTS API
FastAPI wrapper for Kokoro TTS with voice cloning. Runs inference on GPU.
Quick Start
# Start the API (will automatically download model on first run)
docker compose up --build
# From host terminal, test it out with some API calls
python examples/test_tts.py "Hello world" --voice af_bella
API Endpoints
GET /tts/voices # List voices
POST /tts # Generate speech
GET /tts/{request_id} # Check status
GET /tts/file/{request_id} # Get audio file
Example Usage
List voices:
python examples/test_tts.py
Generate speech:
# Default voice
python examples/test_tts.py "Your text here"
# Specific voice
python examples/test_tts.py --voice af_bella "Your text here"
# Just get file path (no download)
python examples/test_tts.py --no-download "Your text here"
Generated files in examples/output/
(or in src/output/ of API if --no-download)
Requirements
- Docker
- NVIDIA GPU + CUDA
- nvidia-container-toolkit