Metadata-Version: 2.5
Name: alkove-esphome
Version: 0.2.0
Summary: Typed wake words for Alkove's ESPHome component: compiles a word for alkove_spot, where ESPHome runs or as YAML to paste
Project-URL: Homepage, https://alkove.ai
Project-URL: Repository, https://github.com/alkove-ai/alkove
Author: Eddy Bordi
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
Keywords: esp32,esphome,home-assistant,keyword-spotting,wake-word
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
Requires-Python: >=3.10
Requires-Dist: alkove<0.7,>=0.6.0
Description-Content-Type: text/markdown

# Alkove Spot for ESPHome (preview)

Typed wake words on the ESP32-S3, in place of `micro_wake_word`: any word you type is a wake word, in French, English, Spanish, Portuguese, Italian, Catalan, Romanian, German, Dutch, Polish or Swedish, with no training and no recording. One language per device: its words are all in that language, and the device runs that language's alkove-spot-1 in one file, in 4 bits (2.05 MB, read in place from PSRAM), with the SDK's wake word search. It fires `on_wake_word_detected` as `micro_wake_word` does.

Maintained by Alkove.

## Needs

- An ESP32-S3 with 8 MB of octal PSRAM, on ESP-IDF.
- To compile the words, the `alkove-esphome` Python package where ESPHome runs: `pip install alkove-esphome`, or `uvx --with alkove-esphome esphome run …`. Where it cannot be installed (ESPHome's Home Assistant add-on), `uvx alkove-esphome "ok Nabu" --lang en` on any computer prints the word compiled, to paste under `words:`.

Measured on a bare ESP32-S3-N16R8 set like the Home Assistant Voice PE (its caches, code and fixed data in PSRAM), ESPHome 2026.11: the model loads in 60 ms, takes 0.38 MB of PSRAM besides its file and 49 KB of internal RAM, and runs at 0.58× real time on one core, speech events included; 8.5 KB of its task's 16 KB stack are never used. On a Home Assistant Voice PE with Wi-Fi and `task_stack_in_psram: true`: the model loads in 65 ms, takes 375 KB of PSRAM and 66.5 KB of internal RAM, 51 KB of DMA memory stays free, and it ran stable over 90 s.

## Use

```yaml
external_components:
  - source:
      type: git
      url: https://github.com/alkove-ai/alkove
      ref: esphome-v0.2.0
      path: integrations/esphome/components
    components: [alkove_spot]

psram:
  mode: octal
  speed: 80MHz

alkove_spot:
  microphone: my_microphone # 16 kHz, 16 bits, one channel
  words:
    - text: ok Nabu
      lang: en
    - text: hey Jarvis
      lang: en
  on_wake_word_detected:
    - voice_assistant.start:
        wake_word: !lambda return wake_word;
```

The library and the model of the words' language are downloaded once from the `esphome-v0.2.0` release and checked by their sha256.

- `words`: a text and its language, compiled by Lex when ESPHome builds. Every word is in the same language: one language's Spot fits on the device, and words in two languages stop the build with an error. `thresholds: {pause, anywhere}` sets a word's own, else they are Spot's defaults for its language. A word can also be given compiled, as `alkove-esphome` prints it: `name`, `lang`, `phonemes` (Lex's phoneme ids, `p`, `french`) and `thresholds`.
- `context`: `pause` (default, the word said after a pause: far fewer false alarms), `anywhere` or `both`.
- `log_scores: true` logs each second's best score above -3, to set a word's thresholds on the device.
- `task_stack_in_psram: true` puts the task's 16 KB stack in PSRAM: internal RAM back for a device short of it, such as a Home Assistant Voice PE whose speaker cannot get its DMA buffers next to Wi-Fi.
- `alkove_spot.start`, `alkove_spot.stop` and the condition `alkove_spot.is_running`, as `micro_wake_word`'s.
- `speech: {confidence, exit_confidence, start, stop}` with `on_speech_start` and `on_speech_end`: when someone starts and stops speaking, from Spot's speech head and the SDK's decision, with the SDK's defaults (0.7, 0.4, 200ms, 600ms). `stop: 2s` ends a command after two seconds of silence, with no server.

[`example.yaml`](./example.yaml) is the test board's configuration, with `test_audio`: a 16 kHz mono WAV run once at boot.

## Build

`alkove_esphome/` is the `alkove-esphome` package, which the component imports to compile the words. `lib/` is the Rust library (`alkove-spot-esp`) behind a C ABI (`include/alk_spot.h`); `components/alkove_spot/` links it with `espressif/esp-nn` and embeds the model. `./dist.sh path/to/models` (espup's toolchain; `<lang>/spot-q4.mcu` for each language) builds the bundle into `dist/alkove-spot-esp-<version>/` and writes its manifest to `components/alkove_spot/bundle.json`; `bundle: dist/alkove-spot-esp-<version>` takes a local one instead of the release, and `model:` and `library:` set the files one by one.
