Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alexa Speaker Output #181

Open
jtwhitlow opened this issue Mar 21, 2024 · 6 comments
Open

Alexa Speaker Output #181

jtwhitlow opened this issue Mar 21, 2024 · 6 comments

Comments

@jtwhitlow
Copy link

jtwhitlow commented Mar 21, 2024

I have been trying to send my voice assistant output to my alexa echo after the m5stack echo takes in the wake word and my gpt processes it. I am new to esphome and i have been able to get it to work on my google speaker, but was wondering what I am doing wrong on my alexa speaker. I have tried several variations on passing to alexa. My "testing" message works, but I cant get the return x; to pass on. Thanks in advance to anyone that can help.

#this is what works for google
service: media_player.play_media
data:
entity_id: media_player.basement_echo
media_content_id: !lambda 'return x;'
media_content_type: music
announce: "true"

This is the testing message that works, but I havent been able to make that dynamic using the !lambda return function

  • homeassistant.service:
    service: notify.alexa_media
    data:
    target: media_player.basement_echo
    message: "testing"
    data_template:
    data: |
    {{{"type": "tts"}}}
@danktankk
Copy link

I have been trying the same thing for about 2 weeks. Im surprised more people havent chimed in on this. You are further along than I am.

@sajov
Copy link

sajov commented Apr 10, 2024

Hi there, not sure if it helps, but in this video it was done for a google device
https://youtu.be/o3yZWD_sFIE?si=yZcuiIifcfnqSrru

@jtwhitlow
Copy link
Author

jtwhitlow commented Apr 10, 2024 via email

@danktankk
Copy link

yep same.. a real bummer too, I liked these little atoms.. they arent even big enough to be a paperweight. so in the bin they go

@cl0ud6uru
Copy link

cl0ud6uru commented May 10, 2024

This is what is working for me on my VLC Telnet speaker.
Need to use Media player, and not notify service. Just make sure your Alexa is a media player.

I also commented out a few of the speaker things to stop the speaker from playing on the S3-Box-3 device

microphone:
  - platform: esp_adf
    id: box_mic

# speaker: !remove
#   # - id: !remove box_speaker

voice_assistant:
  id: va
  microphone: box_mic
  #speaker: box_speaker
  use_wake_word: true
  noise_suppression_level: 2
  auto_gain: 31dBFS
  volume_multiplier: 2.0
  vad_threshold: 3
  on_listening:
    - lambda: id(voice_assistant_phase) = ${voice_assist_listening_phase_id};
    - text_sensor.template.publish:
        id: text_request
        state: "..."
    - text_sensor.template.publish:
        id: text_response
        state: "..."
    - script.execute: draw_display
  on_stt_vad_end:
    - lambda: id(voice_assistant_phase) = ${voice_assist_thinking_phase_id};
    - script.execute: draw_display
  on_stt_end:
    - text_sensor.template.publish:
        id: text_request
        state: !lambda return x;
    - script.execute: draw_display
  on_tts_start:
    - text_sensor.template.publish:
        id: text_response
        state: !lambda return x;
    - lambda: id(voice_assistant_phase) = ${voice_assist_replying_phase_id};
    - script.execute: draw_display

  on_tts_end:
    - homeassistant.service:
        service: media_player.play_media
        data:
          entity_id: media_player.vlc_telnet
          media_content_id: !lambda 'return x;'
          media_content_type: music
          announce: "true"
    - delay: 5s  # Adjust the delay as needed                 
    - lambda: id(voice_assistant_phase) = ${voice_assist_idle_phase_id}; 
    - script.execute: draw_display

  # on_tts_stream_start: !remove

  # on_tts_stream_end: !remove

  on_error:
    - if:
        condition:
          lambda: return !id(init_in_progress);
        then:
          - lambda: id(voice_assistant_phase) = ${voice_assist_error_phase_id};
          - script.execute: draw_display
          - delay: 1s
          - if:
              condition:
                switch.is_off: mute
              then:
                - lambda: id(voice_assistant_phase) = ${voice_assist_idle_phase_id};
              else:
                - lambda: id(voice_assistant_phase) = ${voice_assist_muted_phase_id};
          - script.execute: draw_display
  on_client_connected:
    - if:
        condition:
          switch.is_off: mute
        then:
          - wait_until:
              not: ble.enabled
          - voice_assistant.start_continuous:
          - lambda: id(voice_assistant_phase) = ${voice_assist_idle_phase_id};
        else:
          - lambda: id(voice_assistant_phase) = ${voice_assist_muted_phase_id};
    - lambda: id(init_in_progress) = false;
    - script.execute: draw_display
  on_client_disconnected:
    - lambda: id(voice_assistant_phase) = ${voice_assist_not_ready_phase_id};
    - script.execute: draw_display
  `
```

@danktankk
Copy link

danktankk commented Jun 1, 2024

Thanks, but this isnt for the amazon echo, which is by far the most popular speaker owned, and this also doesnt work for the echo either. I am hoping that someone has figured it out though. If it works for the google brew of smart speakers, then I would hope it would work for the amazon echos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants