Logo
Deploy Now

Stars

5,369

Forks

881

Watchers

36

Developer links

Kokoro FastAPI

Kokoro-FastAPI turns text into natural-sounding speech across eight languages by serving the 82-million-parameter Kokoro-82M model through an OpenAI-compatible REST API, so any existing OpenAI SDK client can generate audio by just changing the base URL. With over 5,300 GitHub stars since December 2024, the fully Dockerized FastAPI server covers American English, British English, Spanish, French, Hindi, Italian, Japanese, Brazilian Portuguese, and Mandarin Chinese with language-specific phoneme processing. Inline voice mixing blends multiple profiles using weighted ratios like af_bella(2)+af_heart(1), automatically normalizing weights and caching combined voicepacks as PyTorch tensor files for reuse. Audio streams in real time over HTTP with configurable chunk sizes, or generates complete files in MP3, WAV, OPUS, FLAC, AAC, or PCM formats with speed control from 0.25x to 4.0x. Per-word timestamped captions with speaker-tagged voice labels enable subtitle generation for podcasts, audiobooks, and accessibility workflows. Pre-built Docker images support NVIDIA GPU acceleration via CUDA, experimental AMD GPU inference via ROCm, and CPU-only deployment on linux/amd64 and linux/arm64 architectures, with Apple Silicon MPS support available through direct UV execution. The integrated web interface at port 8880 provides browser-based speech generation, while the Swagger UI at /docs exposes the full API reference. Debug endpoints report system statistics for monitoring inference load. Running on a dedicated VPS on RepoCloud with guaranteed CPU, RAM, and SSD, full root SSH access, and a browser serial console. Apache 2.0 licensed.

Kokoro FastAPI
Kokoro FastAPI

Benefits

  • OpenAI API Drop-In Replacement
  • Implements the OpenAI /v1/audio/speech endpoint specification exactly, allowing existing OpenAI SDK clients, Open WebUI, and third-party integrations to switch to self-hosted TTS with only a base URL change.
  • Weighted Voice Mixing and Blending
  • Combine multiple voice profiles using weighted ratios like af_bella(2)+bf_emma(1), with automatic normalization and persistent caching of generated voicepacks as PyTorch tensor files.
  • Multi-Platform GPU and CPU Support
  • Pre-built Docker images for NVIDIA CUDA, AMD ROCm, and CPU-only inference on linux/amd64 and linux/arm64 architectures, with Apple Silicon MPS support via direct UV execution.
  • Real-Time Streaming with Timestamps
  • Stream audio chunks over HTTP with configurable sizes and per-word timestamped captions carrying speaker voice labels for subtitle generation, podcast production, and accessibility.

Features

  • Eight-Language TTS
  • Generate speech in American English, British English, Spanish, French, Hindi, Italian, Japanese, Brazilian Portuguese, and Mandarin Chinese with language-specific phoneme processing.
  • Voice Combination API
  • Blend voices with additive and subtractive operators, apply custom weights, and save combined voicepacks as persistent .pt tensor files for reuse across requests.
  • Multiple Audio Formats
  • Output speech in MP3, WAV, OPUS, FLAC, AAC, or PCM with adjustable speed from 0.25x to 4.0x and optional download link headers.
  • Integrated Web Interface
  • Browser-based speech generation UI at port 8880/web with Swagger API documentation at /docs and debug endpoints for real-time system statistics monitoring.
  • Docker Deployment
  • Pre-built multi-architecture images at ghcr.io/remsky/kokoro-fastapi with GPU, CPU, and ROCm variants, models baked in, and pinnable release tags for production stability.