Overview
KokoroTTSService provides local, offline text-to-speech synthesis using the kokoro-onnx engine. It runs entirely on the host machine with no external API calls or authentication required. Model files are automatically downloaded to ~/.cache/pipecat/kokoro-onnx/ on first use.
Kokoro TTS API Reference
Pipecat’s API methods for Kokoro TTS integration
Example Implementation
Complete example with interruption handling
kokoro-onnx Repository
Official kokoro-onnx project and documentation
Settings Update Example
Example showing runtime settings updates
Installation
To use Kokoro TTS, install the required dependencies:kokoro-onnx>=0.5.0 and its dependencies.
Prerequisites
Local Setup
Kokoro runs locally and does not require an API key or external service. The first time the service is constructed, it downloads two model files to~/.cache/pipecat/kokoro-onnx/, so the constructor blocks until they arrive:
kokoro-v1.0.onnx— the ONNX speech synthesis modelvoices-v1.0.bin— the voice data file
model_path and voices_path constructor parameters.
The initial model download may take a few minutes depending on your connection
speed. Subsequent runs use the cached files.
Configuration
KokoroTTSService
str
default:"None"
Path to a custom ONNX model file. When
None, the model is automatically
downloaded to ~/.cache/pipecat/kokoro-onnx/kokoro-v1.0.onnx.str
default:"None"
Path to a custom voices binary file. When
None, the file is automatically
downloaded to ~/.cache/pipecat/kokoro-onnx/voices-v1.0.bin.str
default:"None"
deprecated
Deprecated since 0.0.105, removed in 2.0.0. Use
settings=KokoroTTSService.Settings(voice=...) instead.InputParams
default:"None"
deprecated
Deprecated since 0.0.105, removed in 2.0.0. Use
settings=KokoroTTSService.Settings(...) instead.Settings
Runtime-configurable settings passed via thesettings constructor argument using KokoroTTSService.Settings(...). These can be updated mid-conversation with TTSUpdateSettingsFrame. See Service Settings for details.
Supported Languages
Kokoro supports the following languages. Language codes are mapped to espeak-ng voice names internally; Mandarin usescmn and French variants use region-specific codes (fr-fr, fr-be, etc.) rather than ISO codes.
Usage
Basic Setup
With Language Configuration
With Custom Model Paths
Notes
- Fully local: Kokoro runs entirely on the host machine using ONNX Runtime. No API keys, network access, or external services are required after the initial model download.
- Automatic model caching: Model files are downloaded once to
~/.cache/pipecat/kokoro-onnx/and reused on subsequent runs. You can also pre-download models and specify custom paths. - Audio resampling: Kokoro’s native output is automatically resampled to match the pipeline’s configured sample rate.
- Streaming output: The service uses kokoro-onnx’s async streaming API, delivering audio frames incrementally as they are generated.
- Metrics support: The service supports TTFB (time to first byte) and usage metrics for performance monitoring.
- Language mapping: Kokoro phonemizes through espeak-ng, so languages use espeak-ng voice names (e.g.,
cmnfor Mandarin,fr-frfor French) rather than ISO codes. An unsupported language name fails at synthesis time.