I want to make my Atom-Echo play a short sound when the wakeword is detected. I tryed using the “on_wake_word_detected” and then use “speaker.play” but the output is always after everything is over and not as i want it, after wakeword is detected.
Here my configuration:
I found the same behaviour too when trying to play a ping after the wake word is detected. A workaround is to move - script.execute: play_bing to just after on_listening: instead of using on_wake_word_detected:.
How I do it…enable in homeassistant esp_home m5entity configuration this one “Allow the device to make Home Assistant service calls” - then, I put in the esphome config the “on_listening” and use an homeassistant service call - in my case I use mqtt as all my voice commands and notifications run via an mqtt server. But you could use tts command from homeassistant here. It then simply works like this “hey jarvis”… “yeeeees?” “do this and that”
Thanks a lot for sharing! I’m a new to HA’s Voice Assist functionality. I’m working with an onju-voice (nest mini) device, and that works just fine. For wakework detection¬ification I’m trying with this in ESPHome configuration of the onju-voice device:
Has anyone managed to get this working, to play a sound when the wake word is detected. Any sound TTS or wav?
In the MQTT solution posted here, I don’t really get how do you play a sound on the Echo. Fine you will send a MQTT message… but then what… the Echo isn’t exposed as a media player.
I wanted to give it a try with speaker.play, but I don’t get what to put into the data field. How to convert a wav file to whatever format is needed here? I can’t find any docs
I’m getting close to figuring this out. Instead of using ‘on_listening’ use ‘on_wake_word_detected’. I’ll just post what I have here (I’m using piper though):
Test it out for yourself and see if you can improve it!
Edit: I should have said that there is something wrong the stuff I modified for ‘on_end’ - it does restart wakeword detection, however it doesn’t actually detect the wakeword until I toggle the switch in HA. So it needs work.
Edit2: see updated code above. Might have cracked it! Not sure if this would work on other ESP32 devices running voice assistant, but please give it a try.
I am already very happy with how it works right now. There may be one small improvement for me. After the wakeword confirmation (“What do you want?”), there is a slight delay until the device will listen. I have tried removing (one-by-one) the delays as included in your “on_wake_word_detected” configuration, but that does not seem to work.
In my case it almost works with ESP32 speaker, but with bug.
First it says “not recognized” and then the phrase “room light on” (and it does switch light).
Looks like I’ve messed with the configuration, I’d appreciate it if you could point out what’s wrong with my program.
It’s like there’s a loop and it’s listening for something unnecessary.
p.s. I removed the caching false line, as this is a standard phrase that will be repeated every time and it works faster. This can’t be the cause of the failure, can it?
Edit 1: It seems to work a bit better by adding a delay in play_wakeword_sound.on_turn_off
Edit 2: The file module was updated and argument changed from path to file
It is a path on the computer you run esphome compile, if you have it in the same place as the yaml config file it should work as shown. The esphome compilation will read in the file and embed it in the firmware that is then uploaded to the device.
I was able to get a sound to play from the Atom Echo using your code and instructions, so thank you so much for providing those!
However, after the assist pipeline has finished, and tries to send back a voice reply, the Echo’s log fills up with “speaker buffer is full” (or something to that effect) and the voice never plays. The wake sound I’m using is about a second long and about 15kb in size when converted to .raw. Any idea on how to resolve this?
Hi, it could be the file size. My sound is 8k, so you could try reducing it and see if that helps. You could also try to add a short delay between the speaker.play and wait_until and before voice_assistant.start_continuous and see if that makes a difference.