OHF-Voice/speech-to-phrase
Fast and personalized local speech-to-text
Speech‑to‑Phrase – a Home‑Assistant‑focused speech recogniser
What it is – A locally‑run speech‑to‑text system that doesn’t try to transcribe arbitrary speech. Instead it answers the question “Which of the known command phrases did the user say?” by matching spoken input against a set of templates that include your Home Assistant entities, areas and floors.
Why it exists – For home‑automation you usually only need to recognise a limited, well‑defined set of commands (turn on the kitchen light, add apples to the shopping list, etc.). By restricting the vocabulary to those phrases the recogniser can be fast, run offline and be personalised to the exact names you use in Home Assistant.
How it works (high‑level)
- Sentence templates – Pre‑written language files (YAML) describe the commands you can say. The repository ships templates for many languages and you can add your own.
- Dynamic expansion – At start‑up the tool merges the templates with the names of entities, areas and floors that you have exposed to Home Assistant, producing a hassil template file that represents every possible utterance.
- Finite‑State Transducer (FST) – Using the Rhasspy white‑paper techniques, the compact template is compiled into an FST (via OpenFST and OpenGRM). This efficiently encodes the huge combinatorial space without enumerating every sentence.
- Kaldi acoustic model – The FST is turned into a language model for Kaldi, an open‑source speech‑recognition toolkit. A built‑in pronunciation dictionary and a Phonetisaurus model supply phonemes for known and unknown words.
- Post‑processing fuzzy layer – After Kaldi produces a raw transcription, a small fuzzy‑matching step cleans up minor errors (duplicate/missing words) and forces entity names to match exactly what Home Assistant knows.
Key features
- Local‑only – No cloud service, works behind your firewall.
- Multi‑language – Kaldi‑based version (v1.4.3) supports 22 languages; a newer rewrite (in
OHF‑Voice/apps) currently covers the most common ones. - Custom sentences – Add your own YAML files to extend the command set without touching the code.
- Docker ready – Official container (
rhasspy/wyoming-speech-to-phrase) that can be hooked to Home Assistant via the Wyoming integration. - Automatic model download – Acoustic models and pronunciation tools are fetched from the public HuggingFace dataset
rhasspy/rhasspy-speech. - Home Assistant integration – Connects through the Home Assistant websocket, using a long‑lived access token.
Getting started (quick steps)
- Install – Either add the add‑on from Home Assistant’s Supervisor store or run the Docker command shown in the README.
- Provide credentials – Supply
--hass-websocket-uriand--hass-tokenso the service can read your entities. - (Optional) Custom sentences – Create a directory with language‑specific
sentences.yamlfiles and launch with--custom-sentences-dir /path/to/dir. - Run – The service will download the required acoustic model, build the FST, train the Kaldi language model and start listening on port 10300.
- Use – Send audio to the Wyoming endpoint; the recogniser returns the matched phrase, which Home Assistant can then turn into an automation.
Languages currently supported (Kaldi v1.4.3)
English, French, German, Dutch, Spanish, Italian, Russian, Czech, Catalan, Greek, Romanian, Portuguese (Portugal), Polish, Hindi, Basque, Finnish, Mongolian, Slovenian, Swahili, Thai, Turkish.
Extending / customizing
- Add new entity names – Expose devices to Home Assistant’s Assist feature; they are automatically incorporated.
- Create new command templates – Follow the format in
speech_to_phrase/sentences/<lang>/sentences.yamlor supply your own via the custom‑sentences directory. - Add new languages – Contribute a pronunciation dictionary and acoustic model (or reuse an existing Kaldi model) and add sentence templates; see issue #149 for the current status.
Where the project is now
The Kaldi‑based code in this repository is frozen at version 1.4.3. Development has moved to the OHF‑Voice/apps monorepo, where the system is being rewritten to use a constrained CTC decoder, Home‑Assistant‑intents for sentence sources, and a web UI for selecting commands.
Who might use this
- Home‑automation enthusiasts who want offline, privacy‑preserving voice control.
- Developers building custom Home Assistant voice assistants and needing a recogniser that can understand the exact entity names they expose.
- Anyone looking for a lightweight alternative to cloud‑based speech‑to‑text when the command set is bounded.
Links
- Add‑on badge – Quick install from Home Assistant Supervisor.
- Docker image –
rhasspy/wyoming-speech-to-phrase. - Home Assistant intents repo – Source of sentence templates for the new rewrite.
- Rhasspy whitepaper – Underlying techniques for FST compilation.
- Issue #149 – Tracker for language support and migration details.
Related
- Project
- Project
- Project
- Project
- Project