Thanks to Smart Home Junkie's video (invidious link), I had my Atom Echos as voice recognition boxes with all audio output redirected to a media player of my choice (because the audio on the Echo is super quiet).
Whenever ESPHome updated, I updated my Echos to get the recent ESPHome updates, and then reinstalled the custom yaml for audio redirection.
However, with ESPHome's recent 2024.6.4 update, trying to install the yaml triggers errors that don't seem to make sense. For example, here's a section of the yaml:
microphone:
- platform: i2s_audio
id: echo_microphone_kitchen
i2s_din_pin: GPIO23
adc_type: external
pdm: true
speaker:
- platform: i2s_audio
id: echo_speaker_kitchen
i2s_dout_pin: GPIO21
dac_type: external
mode: mono
voice_assistant:
id: va
microphone: echo_microphone_kitchen
speaker: echo_speaker_kitchen
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_tts_end:
- homeassistant.service:
service: media_player.play_media
data:
entity_id: media_player.${media_player}
media_content_id: !lambda 'return x;'
media_content_type: music
announce: "false"
on_end:
- delay: 100ms
- wait_until:
not:
speaker.is_playing:
- script.execute: reset_led
on_error:
- light.turn_on:
id: led
red: 100%
green: 0%
blue: 0%
brightness: 100%
effect: none
- delay: 1s
- script.execute: reset_led
on_client_connected:
- if:
condition:
switch.is_on: use_wake_word
then:
- voice_assistant.start_continuous:
- script.execute: reset_led
on_client_disconnected:
- if:
condition:
switch.is_on: use_wake_word
then:
- voice_assistant.stop:
- light.turn_off: led
external_components:
- source: github://pr#5230
components:
- esp_adf
refresh: 0s
esp_adf:
On lines 3 and 10 I define unique IDs for the device's microphone and speaker.
But ESPHome won't compile, telling me:
- on line 46: Too many candidates found for 'id' type 'speaker::Speaker' Some are 'echo_speaker', 'echo_speaker_kitchen'.
- on line 57: Too many candidates found for 'id' type 'speaker::Speaker' Some are 'echo_speaker', 'echo_speaker_kitchen'.
- on line 77: Too many candidates found for 'id' type 'microphone::Microphone' Some are 'echo_microphone', 'echo_microphone_kitchen'.
- on line 90: Too many candidates found for 'id' type 'speaker::Speaker' Some are 'echo_speaker', 'echo_speaker_kitchen'.
There are no other occurrences of the word "speaker" or "microphone" in the conf yaml (and I'm not including other yaml files).
I'm assuming most of this config is default, and the only things I care about are forcing pin 21 for the speaker (line 11) and redirecting audio to my media player (lines 45-52).
on_tts_end:
you have a media player component while you define a speaker instead. They are not interchangeable. It is likely trying to grab default values from somewhere because of that. Media player is better if you want the device to also play music or alerts through home assistant instead of voice assistant or some preset wav files.Media player is also a speaker using an arduino library (not compatible with esp_adf as that uses the esp-idf framework and not arduino). If you want to use the media player, you have to get rid of
vad_threshold
and the esp_adf.Please follow this yaml for an esp-idf config using the speaker instead of the media player: https://github.com/esphome/firmware/blob/main/voice-assistant/m5stack-atom-echo.yaml
Thanks for the help, @JustEnoughDucks@feddit.nl.
I copied the yaml you suggested and made 2 changes:
I changed the
i2s_dout_pin
fromGPIO22
toGPIO21
:...and added my
on_tts_end
with the media_player:This did compile and the audio output from the echo is played on the media_player, but the audio is also played on the Echo itself. Previously, changing the
i2s_dout_pin
fromGPIO22
toGPIO21
prevented the Echo from playing the audio (I think by directing audio data to pin 21, which is not used).I'm not sure what you meant here:
I tried removing "vad_threshold: 3" and the "esp_adf" component:
...but with the same result: audio plays on both the media_player and the Echo's speaker.
Instead of trying to prevent the audio from getting to the Echo's speaker, is there a way to just turn the Echo's speaker volume to zero?
Sorry, I misunderstood what you are trying to do here. I thought you were trying to use the Atom Echo itself as a media player. Disregard that arduino library comment, it isn't relevant. I just watched the video since I couldn't earlier.
Indeed what you are doing should work. Are you certain that the upload was successful? With GPIO21 set as the speaker output, the speaker data should absolutely not work. The fact that it does means that somewhere along the line, the GPIO22 is set as the speaker output.
FYI, here's the config yaml I'm copy-pasting for all my Echos. The only thing that changes are in the "substitutions" section:
(sorry about my delayed response, @JustEnoughDucks@feddit.nl )
I'm sure that the install is successful because there are no errors during/after install, the Echo recognizes speech and interacts with Home Assistant, and when I change something in the yaml (e.g., which media player to pipe the audio to) the change takes effect.
Here's something weird: I believe the default pin for "speaker" should be GPIO22, and when I switch it to GPIO21 it should not work. This works on some of my Echos, but not all of them!
Also weird: I think the standard pinout is:
Though I don't know what these mean, I tried setting "speaker" to GPIO18 - which apparently isn't used- and still the audio comes out of the Echo speaker! But again, only on some of my Echos.
I'd think that maybe some of these Echos are ignoring the GPIO setting for "speaker" and using a default, but these Echos used to work! (that is, they used to not play audio out of the Echo speaker when "speaker" was GPIO21). And so I want to think that maybe the ESPHome upgrade made them stop working, but all my Echos have the same upgrade and yet still some of them work.
Is there a way to config the Echo speaker to have zero volume? If so, I could just set that and then who cares if the audio is piped to it.
Well, I wasn't able to figure this out and was just living with duplicate audio coming from the echo and the media player mostly simultaneously. But today I upgraded ESPHome from 2024.6.6 to 2024.7.0 and the problem is gone. Sheesh! :)