#ESP + Microphone to control HA Assist with external Speaker. Problem with define the voice

1 messages · Page 1 of 1 (latest)

terse zodiac
#

hi guyes i add an esp with microphone to talk to HA Assistant. And the output from the Assistant is send over integrated media.player speaker. In my Case i am using Alexa echo dot for the voice answers from HA Assist.

My problem is that alexa is using her own voice. I want to give the output with the voices from HA. In HA i tested the code in the services section. And it working without problems. But when i add the Code in the ESP then i get an Error Message.
This is the code which worked in services
http://youre-ip-adress:8123/developer-tools/service

service: tts.cloud_say
data:
  cache: false
  entity_id: media_player.echo_wohnzimmer
  message: >-
    Hello this code here is working
  language: de-DE
  options:
    voice: ChristophNeural

or this code works too

service: tts.speak
data:
  media_player_entity_id: media_player.echo_wohnzimmer
  message: Dies ist eine Testnachricht
  entity_id: tts.home_assistant_cloud
  language: de-DE
  options:
    voice: MajaNeural

but when i use this code in the ESPHome then i get an error message by installing.

homeassistant.service: 
      service: tts.cloud_say
      data:

Must be string, got <class 'esphome.helpers.OrderedDict'>. did you forget putting quotes around the value?.

options: 
          voice: ChristophNeural
        entity_id: media_player.echo_wohnzimmer
        message: !lambda 'return x;'

i think ESP want here a different code format but i have no idea how…
can someone help please?

what mean this?
Must be string, got <class ‘esphome.helpers.OrderedDict’>. did you forget putting quotes around the value?.

if i use the code like this in ESPHome, then it works but alexa is speaking with her own voice. Not the Voice from HA-Assist.

on_tts_start: 
    - homeassistant.service: 
        service: tts.cloud_say
        data: 
          entity_id: media_player.echo_wohnzimmer
          message: !lambda 'return x;'
spare lance
#

did you try using media player media,play just to see if it worked?

terse zodiac
spare lance
#
on_tts_end:
    - homeassistant.service:
        service: media_player.play_media
        data:
          entity_id: media_player.echo_wohnzimmer
          media_content_id: !lambda 'return x;'
          media_content_type: music
          announce: "true"

in place of what you have been trying

terse zodiac
#

INFO ESPHome 2024.2.1
INFO Reading configuration /config/esphome/voice-assist-mic.yaml...
ERROR Error while reading config: Invalid YAML syntax:

mapping values are not allowed here
in "/config/esphome/voice-assist-mic.yaml", line 92, column 13

spare lance
#

check your indentation

terse zodiac
#

ah okay. i flash the esp one moment

#

it was able to flash the esp without an error. but the alexa is saying nothin

#

in debugging i can see that the wakeword was detection

#

tts_output:
media_id: >-
media-source://tts/tts.home_assistant_cloud?message=Mir+geht+es+gut,+vielen+Dank+der+Nachfrage.+Wie+kann+ich+Ihnen+helfen?&language=de-DE&voice=MajaNeural&preferred_format=mp3
url: >-
/api/tts_proxy/495ee654447740750b1455cfc192b432647fc868_de-de_e3cbd5c222_tts.home_assistant_cloud.mp3
mime_type: audio/mpeg

#

this i can see in debugging raw.

spare lance
#

ok just check in the ESPHome integration that the device can make service calls. Next to the device in the list click 'configure' make sure that the box is ticked.

terse zodiac
#

yes it allowed to do that

spare lance
#

ok ... we need an alexa expert! sorry it didn't work.. hopefully someone will be able to come up with other ideas

terse zodiac
spare lance
#

you're welcome

terse zodiac
#

need an ESP Expert. because the code for alexa in HA i know. This code worked in the automations too. Only the ESP dont wont this code

service: tts.speak
data:
  media_player_entity_id: media_player.echo_wohnzimmer
  message: Dies ist eine Testnachricht
  entity_id: tts.home_assistant_cloud
  language: de-DE
  options:
    voice: MajaNeural

or this,

service: tts.cloud_say
data:
  cache: false
  entity_id: media_player.echo_wohnzimmer
  message: >-
    Hello this code here is working
  language: de-DE
  options:
    voice: ChristophNeural

both is working in automations

terse zodiac
#

here on this page from ESP i think is the solution. but i cant find it. there is written:

#

Data structures are not possible, but you can create a script in Home Assistant and call with all the parameters in plain format.

terse zodiac
spare lance
#

what was the solution ?

terse zodiac
#

you must use a script as template for the option structure

#

i made now a script in HA

alias: ha_voice_alexa
sequence:
  - service: tts.speak
    data_template:
      media_player_entity_id: '{{ media_player_id }}'
      entity_id: '{{ tts_id }}'
      language: '{{ lang }}'
      options:
        voice: '{{ voice_agent }}'
      message: '{{ messagecall }}'
mode: single
spare lance
#

a so in HA and not on the ESP

terse zodiac
#

and this on esphome

  on_tts_start: 
    - homeassistant.service: 
        service: script.ha_voice_alexa
        data: 
          media_player_id: 'media_player.echo_wohnzimmer'
          tts_id: 'tts.home_assistant_cloud'
          lang: 'de-DE'
          voice_agent: 'MajaNeural'
          messagecall: !lambda 'return x;'
spare lance
#

very good! I shall try to remember that for future. glad you are up and running! 👍

terse zodiac
mellow marsh
#

how would I change this for english and default voice for alexa? Trying to make this work for my atom echos to respond with my alexa echos.

spare lance
#

can you paste the code that you are trying @mellow marsh

#

and the errror

mellow marsh
#

- homeassistant.service: service: media_player.play_media data: entity_id: media_player.kitchen media_content_id: !lambda 'return x;' media_content_type: music announce: "true"

#

not a error it was what the alexa was responding with. The alexa would say "to send tts set public url in integration configuration"

spare lance
#

do you have a nabu casa subscription ?

mellow marsh
#

and I would go into the alexa media player integration and set the url to my Nabu Casa url(this would just cause everything to stop working 100% so I deleted the intergation and set it back up) or my address "http://192.168.1.36:8123" and then the command would work but alexa would say nothing.

#

Yes paid for a year.

spare lance
#

try the following

  on_tts_end:
    - homeassistant.service: 
        service: tts.cloud_say
        data: 
          entity_id: media_player.kitchen
          message: !lambda 'return x;'
mellow marsh
#

will do it will take a few to recompile.

#

preparation failed: see what went wrong.... Give this a few mins to see what is wrong.

#

that is odd it went through. Now uploading the new bin

#

ok now it says having trouble accessing simon says na skill.......

spare lance
#

i have no idea with regards to alexa configuration. is that something you need to setup in the alexa platform

mellow marsh
#

Yea this from more searching seems to be something that others are running into also. I may just try to change the message and see if I can get it to just respond with something like "done" or what every lol

#

I assume I would just have to change:
message: !lambda 'return x;'
to
message: "Done"

spare lance
mellow marsh
#

I tried it and got a message from alexa saying something about "simon says NA" lol