JP | EN

Kokoro-FastAPI Setup Guide

A complete setup guide for using the high-quality, lightweight "Kokoro" TTS model as a Web API.

Guide for Kokoro-FastAPI

Table of Contents:

What is Kokoro-FastAPI?

Kokoro-FastAPI is a project that provides the high-quality, lightweight TTS (Text-to-Speech) model "Kokoro" as an easy-to-use Web API.
A key feature is not just reading text, but the ability to finely control pronunciation and rhythm using Markdown-like syntax.

Key Features and Use Cases

Using the control tags below allows for natural, human-like speech and precise reading of technical terminology.

Example text with control tags:

The gNodeB utilized [MIMO](/maɪmoʊ/) techniques to achieve high throughput for enhanced mobile broadband services. [pause:0.5s] A 5G network allows operators to optimize a [CORESET](/ˈkɔːɹˌsɛt/) configuration based on available bandwidth and traffic loads.
🔊 Play Sample:

Automation Workflow Integration (n8n)

This API truly shines when combined with no-code tools like n8n or AI agents.
For instance, using an AI Agent node, you can automate complex processes to build a sophisticated voice generation pipeline:

Setup Guide: Prerequisites

This guide explains how to run "Kokoro-FastAPI" on a Windows 11 environment.

1. Prerequisites

Windows 11 Home does not include the necessary tools to run Linux by default. First, let's set up the foundation.

① Enable Virtualization (BIOS/UEFI)

This is essential for running WSL2 and Docker.

② Install WSL2

This allows you to run Linux directly on Windows.

wsl --install

③ Install NVIDIA Drivers (GPU only)

Required only if you want to accelerate performance using an NVIDIA GPU (GeForce, etc.).

④ Install Docker Desktop

The tool for managing containers (application execution environments).

⑤ Install Git (Option 2 only)

Required to download the source code.

Choosing a Setup Method (Option 1 vs Option 2)

Choose the method that best fits your needs.

Feature Option 1: Use Pre-built Image (Recommended) Option 2: Build from Source
Difficulty ★☆☆ (Easy) ★★☆ (Intermediate)
Best For Quick start, users who want minimal hassle. Developers, users who want to modify the code.
Process Start with a single command. Clone via Git and build locally.
Data Persistence Model data is lost if the container is removed (requires re-download). Easier to persist data via config files.

Step-by-Step: Option 1 (Start Immediately with Pre-built Image)

The easiest method. Run this in Command Prompt or PowerShell.

Install and Run

【CPU Only】

docker run -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-cpu:latest

【With NVIDIA GPU】

docker run --gpus all -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-gpu:latest

Update Procedure

If new features are added, update to the latest version using these steps:

# For CPU
docker pull ghcr.io/remsky/kokoro-fastapi-cpu:latest

# For GPU
docker pull ghcr.io/remsky/kokoro-fastapi-gpu:latest

Step-by-Step: Option 2 (Build from Source)

This method involves downloading the code to your local machine using Git.

Installation

git clone https://github.com/remsky/Kokoro-FastAPI.git
cd Kokoro-FastAPI

Run

Build and start the container with the following command:

docker compose up --build

Update Procedure

git pull origin main
docker compose up --build

The --build flag ensures the container is rebuilt with the latest code.

Kokoro TTS API Verification & Usage Tips

n8n Integration Example (HTTP Request Node)

Here is an example configuration for calling Kokoro-FastAPI from n8n.
When communicating between Docker environments, typically use host.docker.internal as the hostname.