A Home Assistant custom integration for connecting to Kokoro FastAPI, enabling high-quality local Text-to-Speech. Easily send TTS audio to your speakers or media players directly from Home Assistant.
๐ง Listen to a preview: โถ Play
- ๐ Quick Links
- โจ Features
- ๐ฆ Installation
- โ๏ธ Configuration
โถ๏ธ Usage- ๐ Troubleshooting
- ๐ Credits
- ๐ Convert text to speech using Kokoro FastAPI
- โก Low-latency responses for near real-time playback
- ๐ Streaming synthesis โ speech starts on the first sentence, while a conversation agent is still writing
- ๐๏ธ Voice selection with per-call overrides
- ๐๏ธ Voice blending โ combine multiple personas (equal or weighted) into a custom voice
- ๐ง Configurable server URL and parameters
- ๐ Works with any Home Assistant
media_playerentity - โ Connection test during setup โ validates server reachability before configuring
- ๐ Options changes take effect immediately โ no restart required
- ๐ Automatic
lang_codedetection for optimal multilingual support
-
Go to
HACSโIntegrationsโCustom repositories. -
Add this repository:
https://github.com/beecho01/Kokoro-TTSwith categoryIntegration. -
Either search for
Kokoro-TTSin HACS or tap the below button: -
Tap
Downloadand thenInstall. -
Then tap next setup quick-link below to complete the setup configuration:
-
Configure the Kokoro TTS integration as desired.
- Download the latest release from Releases.
- Copy the folder
custom_components/kokoro_ttsinto your Home Assistantcustom_componentsdirectory. - Restart Home Assistant.
- Go to
SettingsโDevices & services. - Click the
Add Configurationbutton. - Search for
Kokoro TTSand select it. - Configure the Kokoro TTS integration as desired.
The integration can be configured through Home Assistant's UI with automatic discovery of available models and voices from your Kokoro FastAPI server.
| Option | Description | Default | Range/Options |
|---|---|---|---|
base_url |
Kokoro FastAPI server URL | Required | Valid HTTP/HTTPS URL |
api_key |
Authentication key | "not-needed" |
Any string |
model |
TTS model to use | "kokoro" |
Auto-discovered or custom |
language |
Language filter for voices | "All Languages" |
All Languages, American English, British English, Japanese, etc. |
sex |
Sex filter for voices | "All" |
All, Female, Male |
persona |
Voice persona/character | Required | Auto-discovered from server |
speed |
Speech speed multiplier | 1.0 |
0.25 - 4.0 |
format |
Audio format | "mp3" |
mp3, wav, opus, flac, pcm |
sample_rate |
Audio sample rate | 24000 |
22050, 24000, 44100 |
| Language | Sex | Name | Preview | Persona Code |
|---|---|---|---|---|
| American English ๐บ๐ธ | Female | Heart | โถ Play | af_heart |
| American English ๐บ๐ธ | Female | Alloy | โถ Play | af_alloy |
| American English ๐บ๐ธ | Female | Aoede | โถ Play | af_aoede |
| American English ๐บ๐ธ | Female | Bella | โถ Play | af_bella |
| American English ๐บ๐ธ | Female | Jessica | โถ Play | af_jessica |
| American English ๐บ๐ธ | Female | Kore | โถ Play | af_kore |
| American English ๐บ๐ธ | Female | Nicole | โถ Play | af_nicole |
| American English ๐บ๐ธ | Female | Nova | โถ Play | af_nova |
| American English ๐บ๐ธ | Female | River | โถ Play | af_river |
| American English ๐บ๐ธ | Female | Sarah | โถ Play | af_sarah |
| American English ๐บ๐ธ | Female | Sky | โถ Play | af_sky |
| American English ๐บ๐ธ | Male | Adam | โถ Play | am_adam |
| American English ๐บ๐ธ | Male | Echo | โถ Play | am_echo |
| American English ๐บ๐ธ | Male | Eric | โถ Play | am_eric |
| American English ๐บ๐ธ | Male | Fenrir | โถ Play | am_fenrir |
| American English ๐บ๐ธ | Male | Liam | โถ Play | am_liam |
| American English ๐บ๐ธ | Male | Michael | โถ Play | am_michael |
| American English ๐บ๐ธ | Male | Onyx | โถ Play | am_onyx |
| American English ๐บ๐ธ | Male | Puck | โถ Play | am_puck |
| American English ๐บ๐ธ | Male | Santa | โถ Play | am_santa |
| British English ๐ฌ๐ง | Female | Alice | โถ Play | bf_alice |
| British English ๐ฌ๐ง | Female | Emma | โถ Play | bf_emma |
| British English ๐ฌ๐ง | Female | Isabella | โถ Play | bf_isabella |
| British English ๐ฌ๐ง | Female | Lily | โถ Play | bf_lily |
| British English ๐ฌ๐ง | Male | Daniel | โถ Play | bm_daniel |
| British English ๐ฌ๐ง | Male | Fable | โถ Play | bm_fable |
| British English ๐ฌ๐ง | Male | George | โถ Play | bm_george |
| British English ๐ฌ๐ง | Male | Lewis | โถ Play | bm_lewis |
| Japanese ๐ฏ๐ต | Female | Alpha | โถ Play | jf_alpha |
| Japanese ๐ฏ๐ต | Female | Gongitsune | โถ Play | jf_gongitsune |
| Japanese ๐ฏ๐ต | Female | Nezumi | โถ Play | jf_nezumi |
| Japanese ๐ฏ๐ต | Female | Tebukuro | โถ Play | jf_tebukuro |
| Japanese ๐ฏ๐ต | Male | Kumo | โถ Play | jm_kumo |
| Mandarin Chinese ๐จ๐ณ | Female | Xiaobei | โถ Play | zf_xiaobei |
| Mandarin Chinese ๐จ๐ณ | Female | Xiaoni | โถ Play | zf_xiaoni |
| Mandarin Chinese ๐จ๐ณ | Female | Xiaoxiao | โถ Play | zf_xiaoxiao |
| Mandarin Chinese ๐จ๐ณ | Female | Xiaoyi | โถ Play | zf_xiaoyi |
| Mandarin Chinese ๐จ๐ณ | Male | Yunjian | โถ Play | zm_yunjian |
| Mandarin Chinese ๐จ๐ณ | Male | Yunxi | โถ Play | zm_yunxi |
| Mandarin Chinese ๐จ๐ณ | Male | Yunxia | โถ Play | zm_yunxia |
| Mandarin Chinese ๐จ๐ณ | Male | Yunyang | โถ Play | zm_yunyang |
| Spanish ๐ช๐ธ | Female | Dora | โถ Play | ef_dora |
| Spanish ๐ช๐ธ | Male | Alex | โถ Play | em_alex |
| Spanish ๐ช๐ธ | Male | Santa | โถ Play | em_santa |
| French ๐ซ๐ท | Female | Siwis | โถ Play | ff_siwis |
| Hindi ๐ฎ๐ณ | Female | Alpha | โถ Play | hf_alpha |
| Hindi ๐ฎ๐ณ | Female | Beta | โถ Play | hf_beta |
| Hindi ๐ฎ๐ณ | Male | Omega | โถ Play | hm_omega |
| Hindi ๐ฎ๐ณ | Male | Psi | โถ Play | hm_psi |
| Italian ๐ฎ๐น | Female | Sara | โถ Play | if_sara |
| Italian ๐ฎ๐น | Male | Nicola | โถ Play | im_nicola |
| Brazilian Portuguese ๐ง๐ท | Female | Dora | โถ Play | pf_dora |
| Brazilian Portuguese ๐ง๐ท | Male | Alex | โถ Play | pm_alex |
| Brazilian Portuguese ๐ง๐ท | Male | Santa | โถ Play | pm_santa |
Kokoro FastAPI supports blending multiple voices into a single custom voice. Instead of picking a persona from the dropdown during setup or options configuration, type a custom value into the Persona field:
| Syntax | Result |
|---|---|
af_bella+af_sky |
Equal blend of Bella and Sky |
af_bella(2)+af_sky(1) |
Weighted blend โ 67% Bella, 33% Sky |
The same syntax works for the per-call persona option (see Per-call option overrides). Blending works best between voices of the same language, since the lang_code sent to the API is derived from the first voice's prefix (or from the language you've configured).
-
Add Integration: Go to
SettingsโDevices & servicesโAdd Integrationโ Search for "Kokoro TTS" -
Server Connection (validated automatically):
- Base URL: Your Kokoro FastAPI server URL (e.g.,
http://localhost:8880) - API Key: Optional authentication key (leave as
not-neededif not required) - The integration will test the connection before proceeding โ if it fails, you'll see a specific error message
- Base URL: Your Kokoro FastAPI server URL (e.g.,
-
Filter Voices โ choose a model and narrow the list before you see it:
- Model: Automatically discovered from
/v1/modelsendpoint (defaults to "kokoro") - Language Filter: Filter personas by language (All Languages, American English, British English, etc.)
- Sex Filter: Filter personas by sex (All, Female, Male)
- Click
Nextโ this is a separate step because Home Assistant's setup forms don't live-filter as you change a dropdown; submitting is what applies the filter.
- Model: Automatically discovered from
-
Select Persona โ pick from the list filtered by the previous step:
- Voice/Persona: Select from the filtered list of available personas
- Speed: Playback speed (0.25x to 4.0x, default: 1.0)
- Format: Audio format (mp3, wav, opus, flac, pcm)
- Sample Rate: Audio sample rate (22050, 24000, 44100 Hz)
Changing options? Any changes made via
SettingsโDevices & ServicesโConfiguretake effect immediately โ no Home Assistant restart is required.
โ ๏ธ YAML configuration is no longer supported. Please use the UI configuration flow instead. If you previously used YAML, remove thekokoro_ttsentry from yourconfiguration.yamland set up the integration through the UI.
Kokoro gets used in two different ways, and it's worth knowing which is which:
- Conversation replies - you talk to Home Assistant's voice assistant, and an AI conversation agent writes a reply on the spot.
- Triggered/predefined text โ a script, automation, or notification calls the
tts.speakaction with text you already wrote yourself, e.g. "Front door opened."
Triggered action (predefined text)
action: tts.speak
data:
media_player_entity_id: media_player.living_room_speaker
message: 'Hello from Kokoro Text-to-Speech!'
cache: false
language: en
target:
entity_id: tts.kokoro
Conversation Agent
For conversation replies specifically, Kokoro starts speaking almost immediately instead of waiting for the AI to finish writing its whole answer - the longer the reply, the more time this saves. It works automatically and there's nothing to turn on, and nothing to configure.
One thing to know, however, if your audio format is set to wav or flac during the setup process,
these don't work for streaming voice replies due to how they are generated, so Kokoro automatically uses mp3 for them instead.
This means, that your setup will work exactly as you want for triggered/predefined text, but the conversation agent will automatically switch to use mp3 in this specific case.
| Error | Cause | Fix |
|---|---|---|
| Cannot connect to the server | Server not reachable | Check the URL, ensure the server is running, and verify network connectivity |
| Connection timed out | Server too slow to respond | Check server load; increase timeout if server is slow to start |
| SSL error | Certificate issue | Check your reverse proxy / SSL certificate settings |
| Server not found | URL points to wrong endpoint | Ensure the URL points to the Kokoro FastAPI root (e.g. http://192.168.0.1:8880) |
| Authentication failed | Wrong API key | Check your API key matches the server's configured key |
Options changes take effect immediately without a restart. Configure is a two-step
form โ a "Filter Voices" step (Model/Voice Accent/Sex) followed by a "Select Persona"
step. Changing Voice Accent or Sex only takes effect once you click Next on that
first step; the Persona list on the second step is filtered accordingly. If the voice
doesn't change:
- Go to
SettingsโDevices & ServicesโKokoro TTSโConfigure - On "Filter Voices", change the accent/sex as needed and click
Next - On "Select Persona", pick the new persona and click
Submit - The TTS entity reloads automatically with the new settings
You can override the default persona, speed, format, and volume on a per-call basis:
action: tts.speak
data:
media_player_entity_id: media_player.living_room_speaker
message: "Hello from Kokoro!"
options:
persona: af_bella
speed: 1.5
format: mp3
volume_multiplier: 1.5
target:
entity_id: tts.kokoro| Option | Description | Default | Range |
|---|---|---|---|
persona |
Voice persona code | Config default | Any discovered persona |
speed |
Speech speed multiplier | 1.0 |
0.25 โ 4.0 |
format |
Audio format | mp3 |
mp3, wav, opus, flac, pcm |
sample_rate |
Audio sample rate (Hz) | 24000 |
22050, 24000, 44100 |
volume_multiplier |
Volume multiplier | 1.0 |
Any positive float |
Kokoro FastAPI backend: @remsky
