TTS on Alexa?

The thread “Echo Devices (Alexa) as Media Player - Testers Needed” has almost 1,400 posts, and the thread “Alexa Announce Feature - Text to Speach via Alexa now a possability?” has more than 300 posts- many of which point to the former topic.

Can someone please summarize how to use TTS on Alexa without having to read through more than a thousand posts on the topic(s)?

6 Likes

This is all based my experience with the former and being in the US. I have no experience (yet…) with the latter.

basically…

you need to copy the alexa.py file from the github repo and place it in your custom_components/media_player directory.

Then in your config you place the following:

media_player:
  - platform: alexa
    email: !secret amazon_email
    password: !secret amazon_pass
    url: amazon.com

when you restart you should be greeted with a new pop up for the configuration for the component which, at this point, should just be that you need enter in a “Captcha” verification. Which should then create a persistent key in you configuration directory (alexa_media.pickle) and some other config files in the same directory where you placed the alexa.py file.

Once you complete that successfully (and maybe a restart of HA) then you should see all of your Echo devices pop up as media_players in your states list which you can use to play different media sources controlled by HA. And there will also be a new service exposed (media_player.alexa_tts) that you can use to send TTS messages to your desired Echo media_player devices.

For example:

    - service: media_player.alexa_tts
      data:
        entity_id: 
          - media_player.computer_room_dot
          - media_player.kitchen_dot
          - media_player.livingroom_dot
        message: "your message here..."
10 Likes

Thanks. You just saved me days of reading and !comprehending lots of off-topic posts.

I know. It was a few hundred less when I started in and it still took forever.

But if it doesn’t work then unfortunately you’ll be back to diving in there to try to find the fix.

I had some troubles but I and another dev on the component had a little side exchange and he was able to work out the problem in their code that was causing the failures.

Hopefully it should just work now.

Wow, worked the first time.
You reduced the thousand plus posts on the topic into a single post.

This will solve a problem we’ve had around here- My wife uses Alexa Drop-in to give us a head’s up to come to dinner. However, the kitchen is a pretty noisy environment and it’s sometimes difficult for her to be understood, or for her to tell Alexa to ‘hang up’ to terminate the drop-in. Now, I can just give her a dash-like button to send the dinner notification to all alexa units. She is gonna’ love this.

In my research, I stumbled across some who were sending commands to Alexa, or commands to Home Assistant through Alexa. Have you done either of these?

:smiley: I’m glad I could help!

not sure what you mean by this.

This is what you are doing using the media player component above.

The way I do this now is thru the HA cloud service. I’ve done it in the past using the HAASKA skill or the Emulated Hue component.

I also would like to thank you for summarising this for the same reason mentioned by stevemann, I now have this working perfectly, was previously using my Sonos system for audio announcements which for some reason my dogs did not like at all :unamused: now switched all anouncements to my echo dots and the dogs don’t bat an eye :smile:

1 Like

Thank you very much man.

Thank you for the boiled down instructions. I have tried this using HA in an unraid docker with no success. I do not get any sort of popup to configure the component after restarting HA.

what have you done for the config? steps?

I followed the instructions at the top of this thread verbatim.

you need to set your logbook debug for that component then restart HA and see what the log says.

logger:
  default: warn #The default level & above to be logged
  logs:
    custom_components.media_player.alexa: debug

Added per your post, restarted and still have nothing pertaining to the custom component. Is there an include that has to be uncommented for it to read those files?

Edit: It appears HA is choking on that logger syntax. I had to remove it to get the UI back.

Edit2: I got the following error out of the log. Do I need to put all media_player sources under a single “media_player:” key? Maybe that is my issue although I already have a couple configured.

the syntax for the logger is fine if you copied it into your configuration.yaml exactly as i posted it.

let’s start from the top…

did you create a media_player directory in your config directory under the custom_components directory and put the alexa.py file downloaded from the github repo in that directory?

you should have this (my config directory is /home/finity/docker/hass-config/):

ex

you probably won’t have the pycache folder yet.

then in your configuration.yaml file you have only one media_player section and it contains the following (and substituted your own login credentials)?:

media_player:
  - platform: alexa
    email: !secret amazon_email
    password: !secret amazon_pass
    url: amazon.com

restarted HA, with the logger set to debug as above and then…

1 Like

I initially put the alexa.py in /custom_components and ran the file. Then realized the mistake and moved it to custom_components/media_player. I did notice the pycache folder got created so I deleted it assuming that it would re-create it when I restarted. after re-running, the pychache folder has not been recreated.

How do I handle multiple media_player devices? Just put them under a single “media_player:” key with separate platforms?

yes.

media_player:
  - platform: alexa
    email: !secret amazon_email
    password: !secret amazon_pass
    url: amazon.com
  - platform: some_other_media_player

Interesting, it didn’t throw that error when I had two media_player, but does now that I have 3. I combined them and restarted with the following result:

https://pastebin.com/fBi9TvcH

where did you put the logger: entry? it should not be under your homeassistant: section.

it should be it’s own component aligned all the way to the left margin.

Success! After combining under a single media_player key and removing the logger syntax that was hanging up the UI, I found “Alexa Captcha” under the “Unused Devices” (didn’t get a pop up). Ran the captcha and it added the echo dots and Fire TV’s.

Thank you!

You nailed the issue with the logger entry. It was tabbed over.