diff --git a/home-assistant-voice.yaml b/home-assistant-voice.yaml index ad20e497..a639ee12 100644 --- a/home-assistant-voice.yaml +++ b/home-assistant-voice.yaml @@ -167,6 +167,10 @@ globals: type: bool restore_value: no initial_value: 'false' + - id: wake_word_engine + type: std::string + restore_value: true + initial_value: '"micro_wake_word"' switch: # This is the master mute switch. It is exposed to Home Assistant. The user can only turn it on and off if the hardware switch is off. (The hardware switch overrides the software one) @@ -324,7 +328,15 @@ binary_sensor: priority: true sound_file: !lambda return id(center_button_press_sound); - delay: 300ms - - voice_assistant.start: + # Start based on selected engine + - if: + condition: + lambda: return id(wake_word_engine) == "open_wake_word"; + then: + - voice_assistant.start: + else: + - voice_assistant.start: + wake_word: "button_press" # Double Click # . Exposed as an event entity. To be used in automations inside Home Assistant - timing: @@ -1671,6 +1683,40 @@ select: id(hey_jarvis).set_probability_cutoff(212); // 0.83 -> 1.502 FAPH on DipCo id(hey_mycroft).set_probability_cutoff(237); // 0.93 -> 1.878 FAPH on DipCo } + - platform: template + name: "Wake Word Engine" + id: wake_word_engine_select + options: + - "micro_wake_word" + - "open_wake_word" + restore_value: true + initial_option: "micro_wake_word" + entity_category: config + optimistic: true + on_value: + then: + - lambda: |- + id(wake_word_engine) = x; + - logger.log: + format: "Wake word engine changed to: %s" + args: [x.c_str()] + level: INFO + # Stop both engines + - if: + condition: + lambda: return id(mww).is_running(); + then: + - micro_wake_word.stop: + - voice_assistant.stop: + - delay: 500ms + # Start the selected engine + - if: + condition: + lambda: return x == "micro_wake_word"; + then: + - micro_wake_word.start: + else: + - voice_assistant.start_continuous: voice_assistant: id: va @@ -1679,17 +1725,24 @@ voice_assistant: channels: 0 media_player: external_media_player micro_wake_word: mww - use_wake_word: false + use_wake_word: true noise_suppression_level: 0 auto_gain: 0 dbfs volume_multiplier: 1 on_client_connected: - lambda: id(init_in_progress) = false; - - micro_wake_word.start: - - lambda: id(voice_assistant_phase) = ${voice_assist_idle_phase_id}; - script.execute: control_leds + - if: + condition: + lambda: return id(wake_word_engine) == "micro_wake_word"; + then: + - micro_wake_word.start: + else: + - voice_assistant.start_continuous: + - lambda: id(voice_assistant_phase) = ${voice_assist_idle_phase_id}; on_client_disconnected: - voice_assistant.stop: + - micro_wake_word.stop: - lambda: id(voice_assistant_phase) = ${voice_assist_not_ready_phase_id}; - script.execute: control_leds on_error: @@ -1749,6 +1802,9 @@ voice_assistant: # Start a script that would potentially enable the stop word if the response is longer than a second - script.execute: activate_stop_word_once # When the voice assistant ends ... + on_tts_end: + - lambda: id(voice_assistant_phase) = ${voice_assist_idle_phase_id}; + - script.execute: control_leds on_end: - wait_until: not: @@ -1777,7 +1833,15 @@ voice_assistant: - script.execute: control_leds on_timer_tick: - script.execute: control_leds - + on_wake_word_detected: + - if: + condition: + switch.is_on: wake_sound + then: + - script.execute: + id: play_sound + priority: false + sound_file: !lambda return id(wake_word_triggered_sound); button: - platform: factory_reset id: factory_reset_button