Add wake word phrase to voice assistant start command (#6290)

This commit is contained in:
Jesse Hills
2024-03-06 07:41:18 +13:00
committed by GitHub
parent 96446446b2
commit 01fc0578bd
7 changed files with 30 additions and 2 deletions
@@ -42,6 +42,8 @@ CONF_AUTO_GAIN = "auto_gain"
CONF_NOISE_SUPPRESSION_LEVEL = "noise_suppression_level"
CONF_VOLUME_MULTIPLIER = "volume_multiplier"
CONF_WAKE_WORD = "wake_word"
voice_assistant_ns = cg.esphome_ns.namespace("voice_assistant")
VoiceAssistant = voice_assistant_ns.class_("VoiceAssistant", cg.Component)
@@ -285,6 +287,7 @@ VOICE_ASSISTANT_ACTION_SCHEMA = cv.Schema({cv.GenerateID(): cv.use_id(VoiceAssis
VOICE_ASSISTANT_ACTION_SCHEMA.extend(
{
cv.Optional(CONF_SILENCE_DETECTION, default=True): cv.boolean,
cv.Optional(CONF_WAKE_WORD): cv.templatable(cv.string),
}
),
)
@@ -293,6 +296,9 @@ async def voice_assistant_listen_to_code(config, action_id, template_arg, args):
await cg.register_parented(var, config[CONF_ID])
if CONF_SILENCE_DETECTION in config:
cg.add(var.set_silence_detection(config[CONF_SILENCE_DETECTION]))
if wake_word := config.get(CONF_WAKE_WORD):
templ = await cg.templatable(wake_word, args, cg.std_string)
cg.add(var.set_wake_word(templ))
return var