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. On first use, the service automatically downloads two model files to~/.cache/pipecat/kokoro-onnx/:
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
Path to a custom ONNX model file. When
None, the model is automatically
downloaded to ~/.cache/pipecat/kokoro-onnx/kokoro-v1.0.onnx.Path to a custom voices binary file. When
None, the file is automatically
downloaded to ~/.cache/pipecat/kokoro-onnx/voices-v1.0.bin.Voice identifier for synthesis. Deprecated in v0.0.105. Use
settings=KokoroTTSService.Settings(voice=...) instead.Deprecated in v0.0.105. 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: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.