TTS on Alexa?

Wow! Just thought I let you know that I could set up the custom component without any problems (using HACS). TTS with the new notification component works too. Great work. Thanks a lot!

The fastest way for me to test TTS through noticiations was the Services tab in the HA developer tools.
I chose notify.alexa_media_echo_dot_kuche as service (which is the Alexa service for my Echo Dot) and used this service data:

{
  "message":"Guten Abend!",
  "data":{"type":"tts"}
}
3 Likes

Hi guys. Hoping for some help as I haven’t gotten this component working.
Component has been installed (captcha code entered).
My two echo dots appear fine but I cant get a notification to work.
I’m on version 0.102.0.dev20191028 installed via docker.

Have I put the service data in correctly? (I call the service but there is no response).

I think you are missing quotation mark before tts

Does anyone know if some Alexa devices will accept sending an Announce and others only TTS? I have one device that will allow the data to be sent as a type Announce and others nothing happens and nothing in the logs. However if I switch to type of TTS it talks. Other devices either works.

Thanks for the reply.

I fixed the quotation mark as you mentioned and also changed alexa media url to amazon.com (from amazon.com.au) and it now works.

Many thanks

If I wanted to have all my Echo’s announce something how would one do that? I have a simple automation to state when the dryer is done with a sensor on the the dryer. I have experimented with this a few times but cannot get it work.

- alias: Dryer Finished
  trigger:
    platform: state
    entity_id: sensor.dryer_state
    from: Drying
    to: Idle
  action:
  - service: media_player.volume_set
    data:
      entity_id:
      - media_player.living_room
      - media_player.master_bedroom
      - media_player.kitchen
      - media_player.guest_room
      - media_player.office
      volume_level: '0.50'
  - service: notify.alexa_media
    entity_id:
    - media_player.living_room
    - media_player.master_bedroom
    - media_player.kitchen
    - media_player.guest_room
    - media_player.office
    data_template:
      message: Hey.. The dryer is done!

I can get it play through Services but I have to pick the exact notify.alexa_media_office to make it work with the below.

{
{"message":"this is what it would sound like if it was working right",
"data":{"type":"tts"}
}

I am not sure how to get this to work right. Thanks ahead for any help.

Hi all,
I have this implementation of TTS working but I have a usage scenario that I can’t work out. Is there a way for the message text to refer to another source instead of hard coding the message text as per the above examples? I’d like to use the feature dynamically e.g. have alexa read the current status of a device or sensor. Specifically, I have a component that tells me the current service status of a train line. I’d like to be able to get the alexa to speak this. Possible?

OK, I’ll answer my own question and also the question above from gdreelin.

This is all assuming you are using the alexa media player integration here:

To make a TTS message pull some of the message from another entity e.g. a sensor, just use a data template for the action instead of a normal data command. Below is an example of a TTS announcement that pulls info from two sensors I have that monitor train service status and uses them as part of the TTS message (the hyphens in the message are just to add a slight pause, making it sound more natural).

- id: '123456767'
  alias: Train service status announcements (working days only)
  description: ''
  trigger:
  - at: '07:15:00'
    platform: time
  condition:
  - condition: state
    entity_id: binary_sensor.workday_sensor
    state: 'on'
  action:
  - data_template:
      data:
        type: tts
      message: central line status is - {{ states('sensor.central') }} . Tea-Eff-Ell rail status is - {{ states('sensor.tfl_rail)') }}
    service: notify.alexa_media_andy_s_echo_dot

Also, to answer gdreelin’s query above, you can use the TTS function of this integration and send the message to multiple Alexa devices at once. I don’t think using the ‘notify.alexa_media’ service works in your example coding above, at least not on my system. You have to use the notify service for a specific device. So, how to message more than one? I haven’t tried gdreelin’s approach above but there are two methods that I know work. The first and most laborious method is to add multiple duplicate actions to the automation, with the same message but just entering a different notify.alexa_media_xxxx for each one. But, there is a better way: create a notify group.

Placing something like the below in your config.yaml file, listing all the devices for the notify group, and it creates a notify service that can be used as the single service target for your TTS message:

notify: # makes a notify group to allow TTS messaging of multiple Alexas at once
  - name: alexa_media_andy_and_alison
    platform: group
    services:
      - service: alexa_media_andy_s_echo_dot
      - service: alexa_media_alison_s_echo_spot

The above creates a service called “notify.alexa_media_andy_and_alison” which you can call with a single TTS message and it goes to both devices. Create other groups and then you can reference any of them in your automations.

Hope this helps someone.

3 Likes

I am following https://github.com/custom-components/alexa_media_player to setup echo dot. setup seems fine. This may seems dumb but I didn’t find documents on how to use it :frowning: Anyone can share documentation how to use it? For example, I want to setup a card in UI that I can type in some text and my echo dot will say it. Or how to send song to echo dot?

I’ve been using this integration for a while now however I haven’t been able to get TTS to multiple alexa’s. I have the following setup:

When this automation is triggered it seems to only notify on the alexa last spoken too.

You need to create a notify group of media devices and then send the TTS to the group name rather than listing individual devices. I also use the Alexa Media Player integration to carry out TTS tasks. For example, in your configuration.yaml, place something like this:

notify: 
  - name: alexa_media_andy_and_alison
    platform: group
    services:
      - service: alexa_media_andy_s_echo_dot
      - service: alexa_media_alison_s_echo_spot

With this example, you can get rid of the target line, just make the service call to the group:
notify.alexa_media_andy_and_alison

PS. how are you going to fit your washing machine inside the dryer? :wink:

I play announcements through multiple Alexa devices for appliances that need attention, like this:

- alias: washing machine done
  initial_state: on
  trigger:
    - platform: state
      entity_id: binary_sensor.washing_machine_running
      from: 'on'
      to: 'off'
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: binary_sensor.dnd
        state: 'off'
  action:
    - service: notify.alexa_media
      data:
        message: "Washing Machine cycle is completed."
        data:
          type: announce
        target:
          - media_player.attic_echo_dot
          - media_player.blue_room_echo_dot
          - media_player.downstairs_echo_dot
          - media_player.kitchen_echo_dot

The announcements are not played exactly synchronized, but plenty close enough.

1 Like

Hi ! Can you please help me - this is Exactly what I have spent hours researching - sending a TTS command and having it play on all my devices .

However here is the error I am getting

I am very new to Home Assistant , what am I doing wrong ?

Im working on the same thing as well.

You need to create a script first like,

alias: Close Doors
sequence:
   - service: notify.alexa_media
     data_template:
       target: 
         - media_player.bedroom_echo_show
         - media_player.bathroom
         - media_player.kitchen
       data:
         type: announce
       message: ""
mode: single

Then, create an automation in the GUI to reference the script.

Most of the time I found it to be indentation

1 Like

Thanks, that the only way I managed to make it work (outside of node red).
sorry if my question is stupid (I’m new to Home Assistant"
but how can you call this script in an automation with a custom “message” ?
if you had a example that would be brilliant otherwise no worries I’m sure I’ll figure out.
Thanks again

You don’t have to actually do it this way, its more, create a script, if you want to call it from multiple automations.

You can just create this as a action in an automation. Use the GUI first, then fresh it out with extra media players ext when you get the hang of how it works.

If you do want to create a script, its call service as the action.

:slight_smile:

1 Like

that’s perfect tanks a lot !