Unique notification sounds for wake words

Hi,
I’m using two different wake words for two assistants. Can I set up unique notification sounds for each one, or am I limited to just one sound file (wake_word_triggered_sound_file)?

where? and did you mean the response start
sound?

I mean the HA Voice PE sound after the trigger word is spoken - in the YAML file defined as wake_word_triggered_sound_file (one times).
In newer HA versions I am able to configure two trigger words and I am using this to switch between two different assistants.

Yes, you can get the wakeword name (from json)

on_wake_word_detected (Optional, Automation): An automation to perform when the wake word is detected. The wake_word phrase from the model manifest is provided as a std::string to any actions in this automation.

and choose the wake-up sound based on that.

Thank you for this approach. It’s almost working, but not quite yet.

I can’t seem to fully override the on_wake_word_detected trigger. Whenever I try to redefine the micro_wake_word block, it fails due to conflicting model IDs.

If I use a basic definition, it seems to act additively instead of replacing the existing logic, so the original sound still plays. Disabling the toggle in the UI works as a workaround, but then the 300ms delay is missing.

I also tried using !remove or !extend, but without success—they either resulted in error messages or were ignored entirely. I have to admit, I’m still in the process of learning the ropes when it comes to these types of YAML customizations and I don’t quite understand the concept of overriding package functions yet.

Any advice on the best way to properly override this function in YAML?

My working YAML:

micro_wake_word:
  id: mww
  microphone:
    microphone: i2s_mics
    channels: 1
    gain_factor: 4
  stop_after_detection: false
  vad:  
  on_wake_word_detected:
    - if:
        condition:
          switch.is_off: master_mute_switch
        then:
          - lambda: |-
              id(detected_wake_word) = wake_word;
              if (wake_word == "Okay Nabu") {
                id(play_nabu_triggered_sound).execute();
              } else if (wake_word == "Hey Jarvis") {               
                id(play_jarvis_triggered_sound).execute();
              }
          - delay: 300ms
#          - voice_assistant.start:
#              wake_word: !lambda return wake_word; 

Here’s a working code snippet for the current version of esphome. You’ll have to figure out the rest of the syntax yourself.

                            - if:
                                condition:
                                  switch.is_on: wake_sound
                                then:
                                  - if:
                                      condition:
                                        lambda: |-
                                          return (wake_word == "Okay Nabu");
                                      then:
                                        - script.execute:
                                            id: play_sound
                                            priority: true
                                            sound_file: "wake_word_triggered_sound"
                                      else:
                                        - script.execute:
                                            id: play_sound
                                            priority: true
                                            sound_file: "beep"
                                  - delay: 360ms
                            - voice_assistant.start:
                                wake_word: !lambda return wake_word;

Playing audio doesn’t require using an extended script, as there’s a standard action. However, for VPE configuration, this is the preferred option due to the large number of possible audio events.

I’m already using the method you described, but I should have mentioned that I’m using a separate script function for playing the jarvis and nabu sound.

To clarify: the issue isn’t that the sound doesn’t work. The problem is that both scripts are being triggered - the original YAML’s wake word function and my own.

I’m struggling to figure out how to correctly override the existing YAML logic so that only my custom function runs.

Either combine the files into one configuration, or make edits to the common part.

Wouldn’t that prevent me from regularly updating the YAML? I’m also unclear on what the common part refers to. Additionally, the code snippet above isn’t working as expected.

Yes, it will interfere - as soon as you interfere with the code, you lose automatic updates. You will have to monitor the changes manually.

I’m not sure what your project looks like, but the common part is the code you import using packages: into the device-specific configuration.