# OPT-IN WAKE-WORD AUDIO VERIFICATION — snippet, NOT a complete config.
# Source: esphome/esphome PR #21885 "[voice_assistant] Stream buffered wake
# word audio for verification" by synesthesiam, merged into the dev branch on
# 2026-11-04. At last check (2026-11-30) this had still NOT shipped in a
# stable ESPHome release (absent from 2026.11.0 and the 2026.11.1 patch of
# 2026-11-25; first expected in 2026.12.0). The docs PR (#8027) merged
# 2026-11-24, but the live component docs do not yet show wake_word_audio. Add these keys to your existing
# voice_assistant block only on an ESPHome build that supports them.
# NOTE: wake_word_audio REQUIRES a micro_wake_word: key in the same
# voice_assistant block (cv.key_requires in the PR) -- pasting this into a
# streaming-only config fails validation.
#
# How it works (per the PR):
#   - With wake_word_audio configured and a Home Assistant client subscribed,
#     both microphone channels are ring-buffered continuously
#     (buffer_duration, default 1.5s).
#   - On a microWakeWord detection the device sends the start request with
#     the model id, detection probability and buffered byte counts, then
#     streams buffered + live audio immediately -- voice_assistant.start
#     must run within ~1s of the detection for verification to apply.
#   - Home Assistant answers WAKE_WORD_END (accepted) or the new
#     VOICE_ASSISTANT_WAKE_WORD_REJECTED event. A rejection stops the stream
#     and fires on_wake_word_rejected on the device.
#   - No verdict within wake_word_audio.timeout -> the run stops with the
#     wake-word-verification-timeout error.
#   - microWakeWord's VAD model is disabled while this mode is active; the
#     mode only engages when the Home Assistant client requests it.
voice_assistant:
  id: va
  wake_word_audio:
    # seconds of pre-detection audio kept per channel (PR default 1.5s;
    # bigger buffers cost RAM)
    buffer_duration: 1.5s
    # how long to wait for HA's accept/reject before failing the run
    timeout: 1s
  on_wake_word_rejected:
    # Re-arm detection here: a rejection path that restarts nothing leaves
    # the satellite deaf -- one of the failure modes in esphome issue #22361.
    - micro_wake_word.start:
