From 132e671a648294bc4698e1f9cdd648dcc3d0dd34 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:33:45 +0100 Subject: [PATCH 01/22] New mww2 m5stack-atom-echo.yaml --- .../m5stack-atom-echo.yaml | 350 +++++++++++++++++- 1 file changed, 349 insertions(+), 1 deletion(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index f8f75f6..a2159c7 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -1 +1,349 @@ -<<: !include ../voice-assistant/m5stack-atom-echo.yaml +substitutions: + name: m5stack-atom-echo + friendly_name: M5Stack Atom Echo + +esphome: + name: ${name} + name_add_mac_suffix: true + friendly_name: ${friendly_name} + min_version: 2024.7.1 + project: + name: m5stack.atom-echo-voice-assistant + version: "24.7.4.1" + +esp32: + board: m5stack-atom + framework: + type: esp-idf + +logger: +api: + +ota: + - platform: esphome + id: ota_esphome + - platform: http_request + id: ota_http_request + +update: + - platform: http_request + id: update_http_request + name: Firmware + source: https://firmware.esphome.io/wake-word-voice-assistant/m5stack-atom-echo/manifest.json + +dashboard_import: + package_import_url: github://esphome/firmware/wake-word-voice-assistant/m5stack-atom-echo.yaml@main + +wifi: + on_connect: + - delay: 5s # Gives time for improv results to be transmitted + - ble.disable: + on_disconnect: + - ble.enable: + ap: + +improv_serial: + +esp32_improv: + authorizer: none + +button: + - platform: factory_reset + id: factory_reset_btn + name: Factory reset + +i2s_audio: + - id: i2s_audio_bus + i2s_lrclk_pin: GPIO33 + i2s_bclk_pin: GPIO19 + +microphone: + - platform: i2s_audio + id: echo_microphone + i2s_din_pin: GPIO23 + adc_type: external + pdm: true + +speaker: + - platform: i2s_audio + id: echo_speaker + i2s_dout_pin: GPIO22 + dac_type: external + mode: mono + +voice_assistant: + id: va + microphone: echo_microphone + speaker: echo_speaker + noise_suppression_level: 2 + auto_gain: 31dBFS + volume_multiplier: 2.0 + vad_threshold: 3 + on_listening: + - light.turn_on: + id: led + blue: 100% + red: 0% + green: 0% + effect: "Slow Pulse" + on_stt_vad_end: + - light.turn_on: + id: led + blue: 100% + red: 0% + green: 0% + effect: "Fast Pulse" + on_tts_start: + - light.turn_on: + id: led + blue: 100% + red: 0% + green: 0% + brightness: 100% + effect: none + on_end: + - delay: 100ms + - voice_assistant.stop: + - wait_until: + not: + voice_assistant.is_running: + - wait_until: + not: + switch.is_on: timer_ringing + - if: + condition: + switch.is_on: use_micro_wake_word + then: + - micro_wake_word.start: + - script.execute: reset_led + else: + - voice_assistant.start_continuous: + - script.execute: reset_led + on_error: + - light.turn_on: + id: led + red: 100% + green: 0% + blue: 0% + brightness: 100% + effect: none + - delay: 2s + - script.execute: reset_led + on_client_connected: + - delay: 5s + - if: + condition: + switch.is_on: use_micro_wake_word + then: + - micro_wake_word.start: + else: + - voice_assistant.start_continuous: + - script.execute: reset_led + on_client_disconnected: + - voice_assistant.stop: + - micro_wake_word.stop: + on_timer_finished: + - voice_assistant.stop: + - micro_wake_word.stop: + - switch.turn_on: timer_ringing + - wait_until: + not: + microphone.is_capturing: + - light.turn_on: + id: led + red: 0% + green: 100% + blue: 0% + brightness: 100% + effect: "Fast Pulse" + - while: + condition: + switch.is_on: timer_ringing + then: + - lambda: id(echo_speaker).play(id(timer_finished_wave_file), sizeof(id(timer_finished_wave_file))); + - delay: 1s + - wait_until: + not: + speaker.is_playing: + - light.turn_off: led + - switch.turn_off: timer_ringing + - if: + condition: + switch.is_on: use_micro_wake_word + then: + - micro_wake_word.start: + - script.execute: reset_led + else: + - voice_assistant.start_continuous: + - script.execute: reset_led + +binary_sensor: + # butto does the following: + # short click - stop a timer, if no timer then restart either microwakeword or voice assistant continuous + - platform: gpio + pin: + number: GPIO39 + inverted: true + name: Button + disabled_by_default: true + entity_category: diagnostic + id: echo_button + on_multi_click: + - timing: + - ON for at least 50ms + - OFF for at least 50ms + then: + - if: + condition: + switch.is_on: timer_ringing + then: + - switch.turn_off: timer_ringing + else: + - if: + condition: + switch.is_on: use_micro_wake_word + then: + - voice_assistant.stop + - micro_wake_word.stop: + - delay: 1s + - script.execute: reset_led + - script.wait: reset_led + - micro_wake_word.start: + else: + - if: + condition: voice_assistant.is_running + then: + - voice_assistant.stop: + - script.execute: reset_led + - voice_assistant.start_continuous: + - timing: + - ON for at least 10s + then: + - button.press: factory_reset_btn + +light: + - platform: esp32_rmt_led_strip + id: led + name: None + disabled_by_default: true + entity_category: config + pin: GPIO27 + default_transition_length: 0s + chipset: SK6812 + num_leds: 1 + rgb_order: grb + rmt_channel: 0 + effects: + - pulse: + name: "Slow Pulse" + transition_length: 250ms + update_interval: 250ms + min_brightness: 50% + max_brightness: 100% + - pulse: + name: "Fast Pulse" + transition_length: 100ms + update_interval: 100ms + min_brightness: 50% + max_brightness: 100% + +script: + - id: reset_led + then: + - if: + condition: + - switch.is_on: use_micro_wake_word + - switch.is_on: use_listen_light + then: + - light.turn_on: + id: led + red: 100% + green: 89% + blue: 71% + brightness: 60% + effect: none + else: + - if: + condition: + - switch.is_off: use_micro_wake_word + - switch.is_on: use_listen_light + then: + - light.turn_on: + id: led + red: 0% + green: 100% + blue: 100% + brightness: 60% + effect: none + else: + - light.turn_off: led + +switch: + - platform: template + name: Use micro wake word + id: use_micro_wake_word + optimistic: true + restore_mode: RESTORE_DEFAULT_ON + entity_category: config + on_turn_on: + - voice_assistant.stop: + - lambda: id(va).set_use_wake_word(false); + - delay: 1s + - micro_wake_word.start: + - script.execute: reset_led + on_turn_off: + - micro_wake_word.stop: + - lambda: id(va).set_use_wake_word(true); + - delay: 1s + - voice_assistant.start_continuous: + - script.execute: reset_led + - platform: template + name: Use listen light + id: use_listen_light + optimistic: true + restore_mode: RESTORE_DEFAULT_ON + entity_category: config + on_turn_on: + - script.execute: reset_led + on_turn_off: + - script.execute: reset_led + - platform: template + id: timer_ringing + optimistic: true + internal: true + restore_mode: ALWAYS_OFF + on_turn_on: + - delay: 15min + - switch.turn_off: timer_ringing + +external_components: + - source: github://pr#5230 + components: + - esp_adf + refresh: 0s + - source: github://jesserockz/esphome-components + components: [file] + refresh: 0s + - source: + type: git + url: https://github.com/kahrendt/esphome + ref: mww-v2-external-library + refresh: 0s + components: [ micro_wake_word ] + +esp_adf: + +file: + - id: timer_finished_wave_file + file: https://github.com/esphome/firmware/raw/main/voice-assistant/sounds/timer_finished.wav + +micro_wake_word: + on_wake_word_detected: + - voice_assistant.start: + wake_word: !lambda return wake_word; + vad: + model: https://github.com/kahrendt/microWakeWord/releases/download/v2.1_models/vad.json + models: + - model: https://github.com/kahrendt/microWakeWord/releases/download/v2.1_models/okay_nabu.json +# - model: https://github.com/kahrendt/microWakeWord/releases/download/v2.1_models/hey_jarvis.json +# - model: https://github.com/kahrendt/microWakeWord/releases/download/v2.1_models/hey_mycroft.json From 00de89f27a67b10d218548d5dd8f4ffc7ea21a3a Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:52:18 +0100 Subject: [PATCH 02/22] http_request --- wake-word-voice-assistant/m5stack-atom-echo.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index a2159c7..00e61dd 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -31,6 +31,8 @@ update: name: Firmware source: https://firmware.esphome.io/wake-word-voice-assistant/m5stack-atom-echo/manifest.json +http_request: + dashboard_import: package_import_url: github://esphome/firmware/wake-word-voice-assistant/m5stack-atom-echo.yaml@main From 32489037792823c679b622ce06d659006b4a862e Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:12:45 +0100 Subject: [PATCH 03/22] Remove esp32_improv for size The program size (2104013 bytes) is greater than maximum allowed (1835008 bytes) --- wake-word-voice-assistant/m5stack-atom-echo.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index 00e61dd..e9080d1 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -37,17 +37,17 @@ dashboard_import: package_import_url: github://esphome/firmware/wake-word-voice-assistant/m5stack-atom-echo.yaml@main wifi: - on_connect: - - delay: 5s # Gives time for improv results to be transmitted - - ble.disable: - on_disconnect: - - ble.enable: +# on_connect: +# - delay: 5s # Gives time for improv results to be transmitted +# - ble.disable: +# on_disconnect: +# - ble.enable: ap: improv_serial: -esp32_improv: - authorizer: none +#esp32_improv: +# authorizer: none button: - platform: factory_reset From f7e2a5a28bfdb679fc14dfaf9af4e219c604dd15 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:19:48 +0100 Subject: [PATCH 04/22] Update wake-word-voice-assistant/m5stack-atom-echo.yaml Co-authored-by: Matthias Pfefferle --- wake-word-voice-assistant/m5stack-atom-echo.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index e9080d1..bc5707f 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -344,8 +344,7 @@ micro_wake_word: - voice_assistant.start: wake_word: !lambda return wake_word; vad: - model: https://github.com/kahrendt/microWakeWord/releases/download/v2.1_models/vad.json models: - - model: https://github.com/kahrendt/microWakeWord/releases/download/v2.1_models/okay_nabu.json -# - model: https://github.com/kahrendt/microWakeWord/releases/download/v2.1_models/hey_jarvis.json -# - model: https://github.com/kahrendt/microWakeWord/releases/download/v2.1_models/hey_mycroft.json + - model: okay_nabu +# - model: hey_jarvis +# - model: hey_mycroft From 3cd2524b08cd53ffa438635731d6bd69f8e645c8 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Mon, 22 Jul 2024 12:23:26 +0100 Subject: [PATCH 05/22] correct project name --- wake-word-voice-assistant/m5stack-atom-echo.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index bc5707f..4bdb9a0 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -8,7 +8,7 @@ esphome: friendly_name: ${friendly_name} min_version: 2024.7.1 project: - name: m5stack.atom-echo-voice-assistant + name: m5stack.atom-echo-wake-word-voice-assistant version: "24.7.4.1" esp32: From 8ed0e3442638f5c06090bf0c1aefeb14719a9273 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Mon, 22 Jul 2024 12:32:36 +0100 Subject: [PATCH 06/22] Substitute model choice --- wake-word-voice-assistant/m5stack-atom-echo.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index 4bdb9a0..99f11dd 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -1,7 +1,7 @@ substitutions: name: m5stack-atom-echo friendly_name: M5Stack Atom Echo - + micro_wake_word_model: okay_nabu # hey_jarvis and hey_mycroft are also supported esphome: name: ${name} name_add_mac_suffix: true @@ -345,6 +345,4 @@ micro_wake_word: wake_word: !lambda return wake_word; vad: models: - - model: okay_nabu -# - model: hey_jarvis -# - model: hey_mycroft + - model: ${micro_wake_word_model} From 3a00077c0bc7888c68b2db7353e4a936716ef3db Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Mon, 22 Jul 2024 12:41:27 +0100 Subject: [PATCH 07/22] remove commented lines --- wake-word-voice-assistant/m5stack-atom-echo.yaml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index 99f11dd..8cd71a4 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -37,18 +37,10 @@ dashboard_import: package_import_url: github://esphome/firmware/wake-word-voice-assistant/m5stack-atom-echo.yaml@main wifi: -# on_connect: -# - delay: 5s # Gives time for improv results to be transmitted -# - ble.disable: -# on_disconnect: -# - ble.enable: ap: improv_serial: -#esp32_improv: -# authorizer: none - button: - platform: factory_reset id: factory_reset_btn From 6c108ea0bb7439b3e201ead7e99d220a4108cbae Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Mon, 22 Jul 2024 12:43:19 +0100 Subject: [PATCH 08/22] fixes typo --- wake-word-voice-assistant/m5stack-atom-echo.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index 8cd71a4..4a50ffa 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -172,8 +172,9 @@ voice_assistant: - script.execute: reset_led binary_sensor: - # butto does the following: - # short click - stop a timer, if no timer then restart either microwakeword or voice assistant continuous + # button does the following: + # short click - stop a timer + # if no timer then restart either microwakeword or voice assistant continuous - platform: gpio pin: number: GPIO39 From ed81c14133f2f877d12cfbb450f395b5b9d77f49 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Mon, 22 Jul 2024 13:43:34 +0100 Subject: [PATCH 09/22] Use selector instead of toggle --- .../m5stack-atom-echo.yaml | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index 4a50ffa..455af6a 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -106,7 +106,7 @@ voice_assistant: switch.is_on: timer_ringing - if: condition: - switch.is_on: use_micro_wake_word + lambda: return id(wake_word_engine_location).state == "On device"; then: - micro_wake_word.start: - script.execute: reset_led @@ -127,7 +127,7 @@ voice_assistant: - delay: 5s - if: condition: - switch.is_on: use_micro_wake_word + lambda: return id(wake_word_engine_location).state == "On device"; then: - micro_wake_word.start: else: @@ -163,7 +163,7 @@ voice_assistant: - switch.turn_off: timer_ringing - if: condition: - switch.is_on: use_micro_wake_word + lambda: return id(wake_word_engine_location).state == "On device"; then: - micro_wake_word.start: - script.execute: reset_led @@ -196,7 +196,7 @@ binary_sensor: else: - if: condition: - switch.is_on: use_micro_wake_word + lambda: return id(wake_word_engine_location).state == "On device"; then: - voice_assistant.stop - micro_wake_word.stop: @@ -247,7 +247,7 @@ script: then: - if: condition: - - switch.is_on: use_micro_wake_word + - lambda: return id(wake_word_engine_location).state == "On device"; - switch.is_on: use_listen_light then: - light.turn_on: @@ -311,6 +311,35 @@ switch: - delay: 15min - switch.turn_off: timer_ringing +select: + - platform: template + entity_category: config + name: Wake word engine location + id: wake_word_engine_location + optimistic: true + restore_value: true + options: + - In Home Assistant + - On device + initial_option: On device + on_value: + - if: + condition: + lambda: return x == "In Home Assistant"; + then: + - micro_wake_word.stop + - delay: 500ms + - lambda: id(va).set_use_wake_word(true); + - voice_assistant.start_continuous: + - if: + condition: + lambda: return x == "On device"; + then: + - lambda: id(va).set_use_wake_word(false); + - voice_assistant.stop + - delay: 500ms + - micro_wake_word.start + external_components: - source: github://pr#5230 components: From 75979beb96b53be1455cf6b23490f1970bf58d99 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Mon, 22 Jul 2024 14:56:59 +0100 Subject: [PATCH 10/22] remove old switch --- .../m5stack-atom-echo.yaml | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index 455af6a..75b611d 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -260,7 +260,7 @@ script: else: - if: condition: - - switch.is_off: use_micro_wake_word + - lambda: return id(wake_word_engine_location).state == "On device"; - switch.is_on: use_listen_light then: - light.turn_on: @@ -274,24 +274,6 @@ script: - light.turn_off: led switch: - - platform: template - name: Use micro wake word - id: use_micro_wake_word - optimistic: true - restore_mode: RESTORE_DEFAULT_ON - entity_category: config - on_turn_on: - - voice_assistant.stop: - - lambda: id(va).set_use_wake_word(false); - - delay: 1s - - micro_wake_word.start: - - script.execute: reset_led - on_turn_off: - - micro_wake_word.stop: - - lambda: id(va).set_use_wake_word(true); - - delay: 1s - - voice_assistant.start_continuous: - - script.execute: reset_led - platform: template name: Use listen light id: use_listen_light From 807c9b576a7b8e32d78e40b7af98922256586001 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Mon, 22 Jul 2024 14:59:37 +0100 Subject: [PATCH 11/22] Update m5stack-atom-echo.yaml --- wake-word-voice-assistant/m5stack-atom-echo.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index 75b611d..579ace0 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -260,7 +260,7 @@ script: else: - if: condition: - - lambda: return id(wake_word_engine_location).state == "On device"; + - lambda: return id(wake_word_engine_location).state != "On device"; - switch.is_on: use_listen_light then: - light.turn_on: From ad3c6e8d0dcee477dcd1ae23a8b4bc7128de93c4 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Tue, 23 Jul 2024 09:32:39 +0100 Subject: [PATCH 12/22] Add Alexa to hint text --- wake-word-voice-assistant/m5stack-atom-echo.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index 579ace0..4831c34 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -1,7 +1,7 @@ substitutions: name: m5stack-atom-echo friendly_name: M5Stack Atom Echo - micro_wake_word_model: okay_nabu # hey_jarvis and hey_mycroft are also supported + micro_wake_word_model: okay_nabu # alexa, hey_jarvis and hey_mycroft are also supported esphome: name: ${name} name_add_mac_suffix: true From f0a8943b4b92964c7a1945a7c80147811b60fd42 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Wed, 24 Jul 2024 13:42:32 +0100 Subject: [PATCH 13/22] Support multiple models --- wake-word-voice-assistant/m5stack-atom-echo.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index 4831c34..3f973a5 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -1,7 +1,11 @@ substitutions: name: m5stack-atom-echo friendly_name: M5Stack Atom Echo - micro_wake_word_model: okay_nabu # alexa, hey_jarvis and hey_mycroft are also supported + micro_wake_word_models: + - model: okay_nabu +# - model: alexa +# - model: hey_jarvis +# - model: hey_mycroft esphome: name: ${name} name_add_mac_suffix: true @@ -348,5 +352,4 @@ micro_wake_word: - voice_assistant.start: wake_word: !lambda return wake_word; vad: - models: - - model: ${micro_wake_word_model} + models: ${micro_wake_word_models} From 1c760e462a30f1c2bdb1ac0245ecaea68d8007af Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Wed, 24 Jul 2024 13:49:34 +0100 Subject: [PATCH 14/22] 2 models --- wake-word-voice-assistant/m5stack-atom-echo.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index 3f973a5..c29768d 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -1,11 +1,8 @@ substitutions: name: m5stack-atom-echo friendly_name: M5Stack Atom Echo - micro_wake_word_models: - - model: okay_nabu -# - model: alexa -# - model: hey_jarvis -# - model: hey_mycroft + micro_wake_word_model: okay_nabu # alexa, hey_jarvis, hey_mycroft are also supported + 2nd_micro_wake_word_model: # esphome: name: ${name} name_add_mac_suffix: true @@ -352,4 +349,7 @@ micro_wake_word: - voice_assistant.start: wake_word: !lambda return wake_word; vad: - models: ${micro_wake_word_models} + models: + - model: ${micro_wake_word_model} + - model: ${2nd_micro_wake_word_model} + From 49d7243133759368d8e58873e722ce8d185c5b59 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Wed, 24 Jul 2024 13:50:50 +0100 Subject: [PATCH 15/22] revert to one wake word --- wake-word-voice-assistant/m5stack-atom-echo.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index c29768d..d66a62a 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -2,7 +2,6 @@ substitutions: name: m5stack-atom-echo friendly_name: M5Stack Atom Echo micro_wake_word_model: okay_nabu # alexa, hey_jarvis, hey_mycroft are also supported - 2nd_micro_wake_word_model: # esphome: name: ${name} name_add_mac_suffix: true @@ -350,6 +349,4 @@ micro_wake_word: wake_word: !lambda return wake_word; vad: models: - - model: ${micro_wake_word_model} - - model: ${2nd_micro_wake_word_model} - + - model: ${micro_wake_word_model} From 08a67a5929708df6a60f5aabaf5dc3f3ed301424 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Thu, 25 Jul 2024 10:18:06 +0100 Subject: [PATCH 16/22] linting --- wake-word-voice-assistant/m5stack-atom-echo.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index d66a62a..f540272 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -1,7 +1,7 @@ substitutions: name: m5stack-atom-echo friendly_name: M5Stack Atom Echo - micro_wake_word_model: okay_nabu # alexa, hey_jarvis, hey_mycroft are also supported + micro_wake_word_model: okay_nabu # alexa, hey_jarvis, hey_mycroft are also supported esphome: name: ${name} name_add_mac_suffix: true @@ -61,7 +61,7 @@ microphone: speaker: - platform: i2s_audio id: echo_speaker - i2s_dout_pin: GPIO22 + i2s_dout_pin: GPIO22 dac_type: external mode: mono @@ -163,7 +163,7 @@ voice_assistant: - switch.turn_off: timer_ringing - if: condition: - lambda: return id(wake_word_engine_location).state == "On device"; + lambda: return id(wake_word_engine_location).state == "On device"; then: - micro_wake_word.start: - script.execute: reset_led @@ -210,7 +210,7 @@ binary_sensor: then: - voice_assistant.stop: - script.execute: reset_led - - voice_assistant.start_continuous: + - voice_assistant.start_continuous: - timing: - ON for at least 10s then: @@ -258,7 +258,7 @@ script: brightness: 60% effect: none else: - - if: + - if: condition: - lambda: return id(wake_word_engine_location).state != "On device"; - switch.is_on: use_listen_light @@ -271,7 +271,7 @@ script: brightness: 60% effect: none else: - - light.turn_off: led + - light.turn_off: led switch: - platform: template @@ -333,9 +333,9 @@ external_components: - source: type: git url: https://github.com/kahrendt/esphome - ref: mww-v2-external-library + ref: mww-v2-external-library refresh: 0s - components: [ micro_wake_word ] + components: [micro_wake_word] esp_adf: From a4a840a25bcb2748fa3a2f70967604a7ee533e20 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Thu, 25 Jul 2024 10:20:08 +0100 Subject: [PATCH 17/22] more linting --- wake-word-voice-assistant/m5stack-atom-echo.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index f540272..b4024d3 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -341,12 +341,12 @@ esp_adf: file: - id: timer_finished_wave_file - file: https://github.com/esphome/firmware/raw/main/voice-assistant/sounds/timer_finished.wav + file: https://github.com/esphome/firmware/raw/main/voice-assistant/sounds/timer_finished.wav micro_wake_word: on_wake_word_detected: - - voice_assistant.start: + - voice_assistant.start: wake_word: !lambda return wake_word; vad: - models: - - model: ${micro_wake_word_model} + models: + - model: ${micro_wake_word_model} From 9fe03242f4544c5f26f0aa06fde505e7f99dc712 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Thu, 25 Jul 2024 10:21:21 +0100 Subject: [PATCH 18/22] last lint --- wake-word-voice-assistant/m5stack-atom-echo.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index b4024d3..a1576f7 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -346,7 +346,7 @@ file: micro_wake_word: on_wake_word_detected: - voice_assistant.start: - wake_word: !lambda return wake_word; + wake_word: !lambda return wake_word; vad: models: - model: ${micro_wake_word_model} From 08c5d415a7a245136643dd090292ac90b1ea9585 Mon Sep 17 00:00:00 2001 From: HarvsG <11440490+HarvsG@users.noreply.github.com> Date: Thu, 25 Jul 2024 10:26:48 +0100 Subject: [PATCH 19/22] indenting --- .../m5stack-atom-echo.yaml | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index a1576f7..83a9f5e 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -259,19 +259,19 @@ script: effect: none else: - if: - condition: - - lambda: return id(wake_word_engine_location).state != "On device"; - - switch.is_on: use_listen_light - then: - - light.turn_on: - id: led - red: 0% - green: 100% - blue: 100% - brightness: 60% - effect: none - else: - - light.turn_off: led + condition: + - lambda: return id(wake_word_engine_location).state != "On device"; + - switch.is_on: use_listen_light + then: + - light.turn_on: + id: led + red: 0% + green: 100% + blue: 100% + brightness: 60% + effect: none + else: + - light.turn_off: led switch: - platform: template From a83f1ca6cbf14852e666f06cae8ee5bf90540f26 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Mon, 29 Jul 2024 09:42:19 +1200 Subject: [PATCH 20/22] Add adopted config --- .../m5stack-atom-echo.adopted.yaml | 329 ++++++++++++++++++ .../m5stack-atom-echo.yaml | 13 +- 2 files changed, 333 insertions(+), 9 deletions(-) create mode 100644 wake-word-voice-assistant/m5stack-atom-echo.adopted.yaml diff --git a/wake-word-voice-assistant/m5stack-atom-echo.adopted.yaml b/wake-word-voice-assistant/m5stack-atom-echo.adopted.yaml new file mode 100644 index 0000000..59a870e --- /dev/null +++ b/wake-word-voice-assistant/m5stack-atom-echo.adopted.yaml @@ -0,0 +1,329 @@ +substitutions: + name: m5stack-atom-echo + friendly_name: M5Stack Atom Echo + micro_wake_word_model: okay_nabu # alexa, hey_jarvis, hey_mycroft are also supported + +esphome: + name: ${name} + name_add_mac_suffix: true + friendly_name: ${friendly_name} + min_version: 2024.7.1 + +esp32: + board: m5stack-atom + framework: + type: esp-idf + +logger: +api: + +ota: + - platform: esphome + id: ota_esphome + +wifi: + ap: + +button: + - platform: factory_reset + id: factory_reset_btn + name: Factory reset + +i2s_audio: + - id: i2s_audio_bus + i2s_lrclk_pin: GPIO33 + i2s_bclk_pin: GPIO19 + +microphone: + - platform: i2s_audio + id: echo_microphone + i2s_din_pin: GPIO23 + adc_type: external + pdm: true + +speaker: + - platform: i2s_audio + id: echo_speaker + i2s_dout_pin: GPIO22 + dac_type: external + mode: mono + +voice_assistant: + id: va + microphone: echo_microphone + speaker: echo_speaker + noise_suppression_level: 2 + auto_gain: 31dBFS + volume_multiplier: 2.0 + vad_threshold: 3 + on_listening: + - light.turn_on: + id: led + blue: 100% + red: 0% + green: 0% + effect: "Slow Pulse" + on_stt_vad_end: + - light.turn_on: + id: led + blue: 100% + red: 0% + green: 0% + effect: "Fast Pulse" + on_tts_start: + - light.turn_on: + id: led + blue: 100% + red: 0% + green: 0% + brightness: 100% + effect: none + on_end: + - delay: 100ms + - voice_assistant.stop: + - wait_until: + not: + voice_assistant.is_running: + - wait_until: + not: + switch.is_on: timer_ringing + - if: + condition: + lambda: return id(wake_word_engine_location).state == "On device"; + then: + - micro_wake_word.start: + - script.execute: reset_led + else: + - voice_assistant.start_continuous: + - script.execute: reset_led + on_error: + - light.turn_on: + id: led + red: 100% + green: 0% + blue: 0% + brightness: 100% + effect: none + - delay: 2s + - script.execute: reset_led + on_client_connected: + - delay: 2s # Give the api server time to settle + - if: + condition: + lambda: return id(wake_word_engine_location).state == "On device"; + then: + - micro_wake_word.start: + else: + - voice_assistant.start_continuous: + - script.execute: reset_led + on_client_disconnected: + - voice_assistant.stop: + - micro_wake_word.stop: + on_timer_finished: + - voice_assistant.stop: + - micro_wake_word.stop: + - switch.turn_on: timer_ringing + - wait_until: + not: + microphone.is_capturing: + - light.turn_on: + id: led + red: 0% + green: 100% + blue: 0% + brightness: 100% + effect: "Fast Pulse" + - while: + condition: + switch.is_on: timer_ringing + then: + - lambda: id(echo_speaker).play(id(timer_finished_wave_file), sizeof(id(timer_finished_wave_file))); + - delay: 1s + - wait_until: + not: + speaker.is_playing: + - light.turn_off: led + - switch.turn_off: timer_ringing + - if: + condition: + lambda: return id(wake_word_engine_location).state == "On device"; + then: + - micro_wake_word.start: + - script.execute: reset_led + else: + - voice_assistant.start_continuous: + - script.execute: reset_led + +binary_sensor: + # button does the following: + # short click - stop a timer + # if no timer then restart either microwakeword or voice assistant continuous + - platform: gpio + pin: + number: GPIO39 + inverted: true + name: Button + disabled_by_default: true + entity_category: diagnostic + id: echo_button + on_multi_click: + - timing: + - ON for at least 50ms + - OFF for at least 50ms + then: + - if: + condition: + switch.is_on: timer_ringing + then: + - switch.turn_off: timer_ringing + else: + - if: + condition: + lambda: return id(wake_word_engine_location).state == "On device"; + then: + - voice_assistant.stop + - micro_wake_word.stop: + - delay: 1s + - script.execute: reset_led + - script.wait: reset_led + - micro_wake_word.start: + else: + - if: + condition: voice_assistant.is_running + then: + - voice_assistant.stop: + - script.execute: reset_led + - voice_assistant.start_continuous: + - timing: + - ON for at least 10s + then: + - button.press: factory_reset_btn + +light: + - platform: esp32_rmt_led_strip + id: led + name: None + disabled_by_default: true + entity_category: config + pin: GPIO27 + default_transition_length: 0s + chipset: SK6812 + num_leds: 1 + rgb_order: grb + rmt_channel: 0 + effects: + - pulse: + name: "Slow Pulse" + transition_length: 250ms + update_interval: 250ms + min_brightness: 50% + max_brightness: 100% + - pulse: + name: "Fast Pulse" + transition_length: 100ms + update_interval: 100ms + min_brightness: 50% + max_brightness: 100% + +script: + - id: reset_led + then: + - if: + condition: + - lambda: return id(wake_word_engine_location).state == "On device"; + - switch.is_on: use_listen_light + then: + - light.turn_on: + id: led + red: 100% + green: 89% + blue: 71% + brightness: 60% + effect: none + else: + - if: + condition: + - lambda: return id(wake_word_engine_location).state != "On device"; + - switch.is_on: use_listen_light + then: + - light.turn_on: + id: led + red: 0% + green: 100% + blue: 100% + brightness: 60% + effect: none + else: + - light.turn_off: led + +switch: + - platform: template + name: Use listen light + id: use_listen_light + optimistic: true + restore_mode: RESTORE_DEFAULT_ON + entity_category: config + on_turn_on: + - script.execute: reset_led + on_turn_off: + - script.execute: reset_led + - platform: template + id: timer_ringing + optimistic: true + internal: true + restore_mode: ALWAYS_OFF + on_turn_on: + - delay: 15min + - switch.turn_off: timer_ringing + +select: + - platform: template + entity_category: config + name: Wake word engine location + id: wake_word_engine_location + optimistic: true + restore_value: true + options: + - In Home Assistant + - On device + initial_option: On device + on_value: + - if: + condition: + lambda: return x == "In Home Assistant"; + then: + - micro_wake_word.stop + - delay: 500ms + - lambda: id(va).set_use_wake_word(true); + - voice_assistant.start_continuous: + - if: + condition: + lambda: return x == "On device"; + then: + - lambda: id(va).set_use_wake_word(false); + - voice_assistant.stop + - delay: 500ms + - micro_wake_word.start + +external_components: + - source: github://pr#5230 + components: + - esp_adf + refresh: 0s + - source: github://jesserockz/esphome-components + components: [file] + refresh: 0s + +esp_adf: + +file: + - id: timer_finished_wave_file + file: https://github.com/esphome/firmware/raw/main/voice-assistant/sounds/timer_finished.wav + +micro_wake_word: + on_wake_word_detected: + - voice_assistant.start: + wake_word: !lambda return wake_word; + vad: + models: + - model: ${micro_wake_word_model} diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index 83a9f5e..fa5ae13 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -2,6 +2,7 @@ substitutions: name: m5stack-atom-echo friendly_name: M5Stack Atom Echo micro_wake_word_model: okay_nabu # alexa, hey_jarvis, hey_mycroft are also supported + esphome: name: ${name} name_add_mac_suffix: true @@ -9,7 +10,7 @@ esphome: min_version: 2024.7.1 project: name: m5stack.atom-echo-wake-word-voice-assistant - version: "24.7.4.1" + version: "24.7.29" esp32: board: m5stack-atom @@ -34,7 +35,7 @@ update: http_request: dashboard_import: - package_import_url: github://esphome/firmware/wake-word-voice-assistant/m5stack-atom-echo.yaml@main + package_import_url: github://esphome/firmware/wake-word-voice-assistant/m5stack-atom-echo.adopted.yaml@main wifi: ap: @@ -124,7 +125,7 @@ voice_assistant: - delay: 2s - script.execute: reset_led on_client_connected: - - delay: 5s + - delay: 2s # Give the api server time to settle - if: condition: lambda: return id(wake_word_engine_location).state == "On device"; @@ -330,12 +331,6 @@ external_components: - source: github://jesserockz/esphome-components components: [file] refresh: 0s - - source: - type: git - url: https://github.com/kahrendt/esphome - ref: mww-v2-external-library - refresh: 0s - components: [micro_wake_word] esp_adf: From e499890acc96f4542393d3c48b617605e8b1238d Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Mon, 29 Jul 2024 09:50:05 +1200 Subject: [PATCH 21/22] Add captive portal --- wake-word-voice-assistant/m5stack-atom-echo.adopted.yaml | 2 ++ wake-word-voice-assistant/m5stack-atom-echo.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.adopted.yaml b/wake-word-voice-assistant/m5stack-atom-echo.adopted.yaml index 59a870e..5f89701 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.adopted.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.adopted.yaml @@ -24,6 +24,8 @@ ota: wifi: ap: +captive_portal: + button: - platform: factory_reset id: factory_reset_btn diff --git a/wake-word-voice-assistant/m5stack-atom-echo.yaml b/wake-word-voice-assistant/m5stack-atom-echo.yaml index fa5ae13..0255e36 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.yaml @@ -42,6 +42,8 @@ wifi: improv_serial: +captive_portal: + button: - platform: factory_reset id: factory_reset_btn From b95ab23050de4e6a7fa895d4f2c5c7c29c504569 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Mon, 29 Jul 2024 09:53:38 +1200 Subject: [PATCH 22/22] Fix indentation --- wake-word-voice-assistant/m5stack-atom-echo.adopted.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wake-word-voice-assistant/m5stack-atom-echo.adopted.yaml b/wake-word-voice-assistant/m5stack-atom-echo.adopted.yaml index 5f89701..5138221 100644 --- a/wake-word-voice-assistant/m5stack-atom-echo.adopted.yaml +++ b/wake-word-voice-assistant/m5stack-atom-echo.adopted.yaml @@ -109,7 +109,7 @@ voice_assistant: - delay: 2s - script.execute: reset_led on_client_connected: - - delay: 2s # Give the api server time to settle + - delay: 2s # Give the api server time to settle - if: condition: lambda: return id(wake_word_engine_location).state == "On device";