Add wake word integration (#96380)

* Add wake component

* Add wake support to Wyoming

* Add helper function to assist_pipeline (not complete)

* Rename wake to wake_word

* Fix platform

* Use send_event and clean up

* Merge wake word into pipeline

* Add wake option to async_pipeline_from_audio_stream

* Add start/end stages to async_pipeline_from_audio_stream

* Add wake timeout

* Remove layer in wake_output

* Use VAD for wake word timeout

* Include audio metadata in wake-start

* Remove unnecessary websocket command

* wake -> wake_word

* Incorporate feedback

* Clean up wake_word tests

* Add wyoming wake word tests

* Add pipeline wake word test

* Add last processed state

* Fix tests

* Add tests for wake word

* More tests for the codebot
This commit is contained in:
Michael Hansen 2023-08-07 21:22:16 -05:00 committed by GitHub
parent 798fb3e31a
commit 7ea2998b55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 1802 additions and 27 deletions

View file

@ -8,7 +8,7 @@ from homeassistant.components import stt
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from . import STT_INFO, TTS_INFO
from . import STT_INFO, TTS_INFO, WAKE_WORD_INFO
from tests.common import MockConfigEntry
@ -52,6 +52,21 @@ def tts_config_entry(hass: HomeAssistant) -> ConfigEntry:
return entry
@pytest.fixture
def wake_word_config_entry(hass: HomeAssistant) -> ConfigEntry:
"""Create a config entry."""
entry = MockConfigEntry(
domain="wyoming",
data={
"host": "1.2.3.4",
"port": 1234,
},
title="Test Wake Word",
)
entry.add_to_hass(hass)
return entry
@pytest.fixture
async def init_wyoming_stt(hass: HomeAssistant, stt_config_entry: ConfigEntry):
"""Initialize Wyoming STT."""
@ -72,6 +87,18 @@ async def init_wyoming_tts(hass: HomeAssistant, tts_config_entry: ConfigEntry):
await hass.config_entries.async_setup(tts_config_entry.entry_id)
@pytest.fixture
async def init_wyoming_wake_word(
hass: HomeAssistant, wake_word_config_entry: ConfigEntry
):
"""Initialize Wyoming Wake Word."""
with patch(
"homeassistant.components.wyoming.data.load_wyoming_info",
return_value=WAKE_WORD_INFO,
):
await hass.config_entries.async_setup(wake_word_config_entry.entry_id)
@pytest.fixture
def metadata(hass: HomeAssistant) -> stt.SpeechMetadata:
"""Get default STT metadata."""