Skip to content

Latest commit

ย 

History

59 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Kokoro TTS Header


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

  • ๐Ÿ”Š 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_player entity
  • โœ… Connection test during setup โ€” validates server reachability before configuring
  • ๐Ÿ”„ Options changes take effect immediately โ€” no restart required
  • ๐ŸŒ Automatic lang_code detection for optimal multilingual support

๐Ÿ“ฆ Installation

HACS (recommended)

  1. Go to HACS โ†’ Integrations โ†’ Custom repositories.

  2. Add this repository: https://github.com/beecho01/Kokoro-TTS with category Integration.

  3. Either search for Kokoro-TTS in HACS or tap the below button:

    Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

  4. Tap Download and then Install.

  5. Then tap next setup quick-link below to complete the setup configuration:

    Open your Home Assistant instance and start setting up a new integration.

  6. Configure the Kokoro TTS integration as desired.

Manual

  1. Download the latest release from Releases.
  2. Copy the folder custom_components/kokoro_tts into your Home Assistant custom_components directory.
  3. Restart Home Assistant.
  4. Go to Settings โ†’ Devices & services.
  5. Click the Add Configuration button.
  6. Search for Kokoro TTS and select it.
  7. Configure the Kokoro TTS integration as desired.

โš™๏ธ Configuration

The integration can be configured through Home Assistant's UI with automatic discovery of available models and voices from your Kokoro FastAPI server.

Configuration Options

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

๐Ÿ‘จ๐Ÿ‘ฉ Personas

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

๐ŸŽ›๏ธ Voice Blending

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).

Setup Steps

  1. Add Integration: Go to Settings โ†’ Devices & services โ†’ Add Integration โ†’ Search for "Kokoro TTS"

  2. Server Connection (validated automatically):

    • Base URL: Your Kokoro FastAPI server URL (e.g., http://localhost:8880)
    • API Key: Optional authentication key (leave as not-needed if not required)
    • The integration will test the connection before proceeding โ€” if it fails, you'll see a specific error message
  3. Filter Voices โ€” choose a model and narrow the list before you see it:

    • Model: Automatically discovered from /v1/models endpoint (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.
  4. 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 โ†’ Configure take effect immediately โ€” no Home Assistant restart is required.

YAML Configuration (Legacy)

โš ๏ธ YAML configuration is no longer supported. Please use the UI configuration flow instead. If you previously used YAML, remove the kokoro_tts entry from your configuration.yaml and set up the integration through the UI.


โ–ถ๏ธ Usage

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.speak action 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.


๐Ÿ›  Troubleshooting

Connection errors during setup

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

Voice/persona not changing after options update

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:

  1. Go to Settings โ†’ Devices & Services โ†’ Kokoro TTS โ†’ Configure
  2. On "Filter Voices", change the accent/sex as needed and click Next
  3. On "Select Persona", pick the new persona and click Submit
  4. The TTS entity reloads automatically with the new settings

Per-call option overrides

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

๐Ÿ™ Credits

Kokoro FastAPI backend: @remsky

About

A Home Assistant integration to allow configurable connections to Kokoro Text-to-speech (https://github.com/remsky/Kokoro-FastAPI)

Topics

Resources

Stars

11 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages