Giter VIP home page Giter VIP logo

ha-alexa-tts's Introduction

ha-alexa-tts

Alexa Unsolicted TTS for Home Assistant

Here is the unsolicited text to speech for Alexa devices that we have been waiting for!

The loetzimmer.de shell script has been updated (Thanks Ralf Otto) with the excellent work of Michael Geramb to support direct TTS to any Alexa devices!

This script does work by using the Alexa web interface, so it may break at anytime. However, the TTS component is POSTing a JSON object direct to the API endpoint, so the odds that TTS portion stays working are high.

The TTS works with two shells scripts, the original by Alex Loetzimmer and wrapper for it that allows Home Assistant to call it as a command line notify component.

To get started, download the scripts: https://github.com/walthowd/ha-alexa-tts

Save scripts in your Home Assistant config directory and make them executable (chmod +x alexa_remote_control.sh & chmod +x alexa_wrapper.sh)

Add your login credentials to the Home Assistant secrets.yaml file, with the keys alexa_email and alexa_password.

Run the script interactively to pull your devices:

./alexa_remote_control.sh -a

If login fails look at /tmp/.alexa.login. Search for "password" and see if you are being prompted for the captcha. If so, you can attempt to login to Alexa manually from a browser (from the same IP) and see if that fixes the issue for you. It never did for me, so I logged in to https://alexa.amazon.com with Chrome and used the cookies.txt extension(https://chrome.google.com/webstore/detail/cookiestxt/njabckikapfpffapmjgojcnbfjonfjfg?hl=en) to export my amazon cookies to /tmp/.alexa.cookie. Other individuals have reported success using the same procedure, but only when using Firefox.

Once you have ./alexa_remote_control.sh -a returning your devices you can test TTS by running:

./alexa_remote_control.sh -d "My Dot Name" -e speak:This_is_a_test!

If that works, next in a shell type:

echo $PATH

Copy that value and put it in the PATH in alexa_wrapper.sh

Add a command line notify to Home Assistant:

notify:
  - platform: command_line
    name: 'My Dot Name'
    command: "/home/homeassistant/.homeassistant/alexa_wrapper.sh -d 'My Dot Name'"

If you are using hass.io, adjust the command line to:

     command: "/config/alexa_wrapper.sh -d 'My Dot Name'"

Restart Home Assistant and you should now be able to call notify.my_dot_name with a message from an automation or the services interface broadcast messages to your devices.

You can also add a notify for all of your Alexa devices:

notify:
  - platform: command_line
    name: 'All Alexas'
    command: "/home/homeassistant/.homeassistant/alexa_wrapper.sh -d 'ALL'"

Let me know if you have any questions!

ha-alexa-tts's People

Contributors

eracknaphobia avatar kotopoulos10 avatar neilcrosby avatar patriot1889 avatar vivianlink avatar walthowd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ha-alexa-tts's Issues

TTS is ignoring ? and ! chars

When sending TTS command like:

alexa_remote_control.sh -d 'Echo Salon' -e speak:"hey? Is there someone?"

The TTS seems well passed to the script, but Alexa is ignoring ? character, like if they were removed from the string (she is prononing the sentence without pause and without question intonation).
The same problem occurs with ! character, while it is correctly working with dot and coma (. or ,).

Alexa no sound

After playing around with it I finally got passed the cookie stuff.

Now i try doing a command or tts I do get a response in the terminal but Alexa doesn't talk at all.

core-ssh:/config# ./alexa_remote_control.sh -d "Alexa bedroom" -e goodmorning
sending cmd:goodmorning to dev:Alexa bedroom type:A3S5BH2HU6***
serial:G090LF1174831T** customerid:A1NJJUS9Z****
Sequence command: Alexa.GoodMorning.Play
HTTP/1.1 0 x-amzn-RequestId: baa41eed-02fd-11e9-****-576a926e3217
Access-Control-Allow-Origin: https://alexa.amazon.com
Content-Encoding: deflate
Vary: Origin
Access-Control-Expose-Headers: x-amzn-dat-gui-client-upgrade,X-Amzn-Error,loginUrl,X-Amzn-RequestId,x-amzn-alt-domain,Date,Location
Access-Control-Allow-Credentials: true
Date: Tue, 18 Dec 2018 19:47:19 GMT
Connection: close

This is what i get back. I did read somewhere that I'm not the only one that have/used to have this issue but I could see a fix for it really quick.

jq not found

I had this issue earlier.
I don't know how to send a message to the owner
I'm using hassbian for home assistant and I was getting this error jq not found when I was trying to run alexa_remote_control.sh
I have sorted the issue out with sudo apt-get install jq
Hope it helps!

Not pronoucing sensor values

I'm trying to make her say this, but I get only silence

message: "temperature is {{ states('sensor.house_temp') }}"

any way to get it to work?

UK settings

I couldn't get the signin to work until I changed to these settings:

LANGUAGE="en-GB"
AMAZON='amazon.co.uk'
ALEXA='layla.amazon.co.uk'

Hope this helps.

nothing happens

Hi,

i've tried it, set up, but nothing happens, if i send


( 7:31:19)[1607 :/tmp/ha-alexa-tts]# ./alexa_remote_control.sh -d "Echo in Livingroom" -e speak:This_is_a_test!
sending cmd:speak:This_is_a_test! to dev:Echo in Livingroom type:A3S5BH2HU6VAYF serial:XXXXXXXXXXXXXXXXXXXX customerid:XXXXXXXXXXXXXXXX
Sequence command: Alexa.Speak
HTTP/1.1 0 x-amzn-RequestId: 56e37882-79cb-11e8-bde6-1566dd090b8e
Access-Control-Allow-Origin: https://alexa.amazon.com
Content-Encoding: deflate
Vary: Origin
Access-Control-Expose-Headers: x-amzn-dat-gui-client-upgrade,X-Amzn-Error,loginUrl,X-Amzn-RequestId,x-amzn-alt-domain,Date,Location
Access-Control-Allow-Credentials: true
Date: Wed, 27 Jun 2018 05:31:27 GMT
Connection: close


"underscore" included in speaking

Hi,

This tool works well for me for long time, but now echo's speech includes underscore
Example with command: -e speak:1_2
It should be: "one two" (as before) but now: "one underscore two"

Any idea to fix?

Volume command does not work anymore

Since yesterday, the volume command does not work.
I got the following message back :
{"message":"No routes found","userFacingMessage":null}

The speak command still works...

Regards

Can't get the Wrapper to work in HASSIO

I successfully followed all the steps, but actually getting it to work inside HASSIO via the Wrapper.sh does not work.
It also does not give an error or something.

Unable to cirvument captcha

I am getting a captcha screen at .alexa.login and there is no success circumventing it.
I have tried the following:

  1. Using firefox with disabled javascript and cleaned up cookies to login to alexa.amazon.com
  2. Using chrome with disabled javascript and cleaned up cookies to login to alexa.amazon.com
  3. Using chrome extension you suggested to get "all cookies" into cookies.txt and:
  • Copy/Pasted cookies.txt into the SAMBA share folder homeassistant on Windows
  • Renamed cookies.txt to -> .alexa.cookie (at which point disappeared from file explorer).
  • Logged in via SSH on Pi navigated to /home/homeassistant/.homeassistant
  • Executed: sudo mv .alexa.cookie /tmp
  • Navigated to /tmp
  • Executed chown and chgrp to set owner and group of .alexa.cookie to 'pi' (same as .alexa.login)
  • Navigated back to /home/homeassistant/.homeassistant
  • Executed the script ./alexa_remote_control.sh -a as per instructions.
  • Nevative result , got captcha again.

Is it still working or has Amazon blocked it? Am I doing anything wrong based on the above?

Amazon cookie issue

Receiving error on first login (as expected). Followed procedure for logging in via chrome and using cookie.txt extension to save cookie. Moved cookie in to correct location.

Upon subsequent runs of alexa_remote_control.sh -a receive message that cookie is expired, logging in again. Login again fails.

Any other workarounds for this?

alexa_remote_control.sh -s <trackID> ???

Good evening everyone,

Did anyone of you manage to run the option alexa_remote_control.sh -s ???

I have searched for all possible trackID imaginable on Amazon Music, I tested all the keys that existed and I do not find how it works.

I arrived there with for example 'Artist' 'Album' but it's not easy to find what to put, I guess with trackID it's easier.
For example: /var/www/html/plugins/script/core/ressources/alexa_remote_control.sh -d "Le salon" -s "Joe Dassin" "Les Champs-Elysées"

If you found where are the trackID, I'm interested with a huge pleasure !!!

HASSIO

Can this be implemented on HASIO?

Thanks!

Cookie issues

Hi,
I'm using Hassio in a docker environment. This is just a server, and not a workstation, so it has no GUI, and as such no Chrome, no Firefox, etc. I'm trying to use this, but it keeps giving me the following error:

cookie does not exist. logging in ...
ERROR: Amazon Login was unsuccessful. Possibly you get a captcha login screen.
Try logging in to https://alexa.amazon.com with your browser. In your browser
make sure to have all Amazon related cookies deleted and Javascript disabled!

(For more information have a look at /tmp/.alexa.login)

I looked in /tmp/.alexa.login, and it doesn't show any request for CAPTCHA.

Any help would be much appreciated!

Thanks

b

Cookie Expired message. Getting captcha.

I've followed your instructions. Sure enough, I'm getting the captcha from my hass.io. So I used the cookies.txt extension to put the cookies file where specified. However, it tells me "cookie expired. logging in again". Then gets the captcha again.

I don't get the captcha locally in any browser, not in incognito, not when clearing cookies and all app data, not when disabling javascript, etc. I saved the cookies from a fresh login with cookies disabled. I'm on the same IP as the hass.io.

It appears the copied cookies are no good for another client? Doesn't make sense.

Any ideas?

Iheartradio support

Any Idea how to add Iheartradio support for music radio station playback?

I tried logging in with firefox and javascript disabled to watch the commands used but it doesn't look like you can login without javascript anymore. At least from what I can tell.

Thanks!

Can't get it to work from HA...

I can get it working from the command line and all of the entries in PATH are in the file, but I can't get it to work from HA itself. I'm not sure what information to provide here as I've already tried everything I can think of. Any tricks I might have missed? Really cool and works FINE from the command line. I'm certain it's something I haven't done...

Edit: I got it to work ONE time. A subsequent message didn't work... I updated the scripts (I had older copies) and the issue seems to be that the script is erasing the cookie every time I try to run it. Ran once, so I don't know what that's all about.

Problem on the HASS implementation side

Having an issue on the HASS implementation side... Tests from the command line work fine, no issues with login and tests always result in speech coming out of the appropriate device - tested all of them.

I set up the command line notify objects in my configuration.yaml, restarted HASS and they all show up in services correctly and no errors in the log.

Then I setup an automation to test with and triggered it but nothing happens. No speech and no errors in the HASS log to show why it may have failed.

I also tried it manually from the service dev page (I think I have the JSON correct, but if I don't feel free to point that out):

Service: notify.office_dot

Service Data:
{
  "message": "Testing!"
}

And again, nothing. No speech, no errors. I see the service call toast message, but nothing happens.

I'm stumped at where to begin troubleshooting and would appreciate any help you can provide.

Further details: My old school HASS root directory is /home/hass and both scripts are in there. Both are properly setup as executable and changing ownership from root to the HASS user doesn't seem to make a difference.

Also tried hard coding the ALEXA_REMOTE variable in alexa_wrapper.sh to reflect my setup's path of /home/hass/alexa_remote_control.sh but that also didn't make a difference.

TTS not working?

Running
./alexa_remote_control.sh -d "Leo's Echo Dot" -e speak:This_is_a_test!

Yields the following, but no sound from the device:

Sequence command: Alexa.Speak
HTTP/1.1 0 x-amzn-RequestId: d705e43d-f8fa-11e8-9c91-0bad5422181d
Access-Control-Allow-Origin: https://alexa.amazon.com
Content-Encoding: deflate
Vary: Origin
Access-Control-Expose-Headers: x-amzn-dat-gui-client-upgrade,X-Amzn-Error,loginUrl,X-Amzn-RequestId,x-amzn-alt-domain,Date,Location
Access-Control-Allow-Credentials: true
Date: Thu, 06 Dec 2018 02:01:26 GMT
Connection: close

no alexa command received

Commands

weather, traffic, flashbriefing, goodmorning, singasong, tellstory, vol

... all yield similar results.

While -q, -b, seem to work. It seems it's set to "read only".

Perhaps the devs have blocked "write"-style messages?

Cookies expired and no .alexa.login file

EXTREMELY excited to get this working, I've been waiting quite some time to push Audio to Alexa!

  • Running latest Hassio version
  • Using fresh firefox
  • Disabled Javascript, logged into alexa (had to put in the captcha)
  • Using Firefox cookies.txt plugin (copying to .alexa.cookie)
  • running ./alexa_remote_control.sh -a ..... Says cookies expired, trying to login, then says might be captcha
  • Trying to troubleshoot but script isn't even writing out a .alexa.login file

Any ideas?

Content-Encoding: deflate

script worked for a while, but now i get the following, with no output:

sending cmd:speak:This_is_a_test! to dev:Master Echo Dot type:A3S5BH2HU6VAYF serial:#serial# customerid:#customerid#
Sequence command: Alexa.Speak
HTTP/1.1 0 x-amzn-RequestId: 34393924-76ba-11e8-83a3-f941d21034f8
Access-Control-Allow-Origin: https://alexa.amazon.com
Content-Encoding: deflate
Vary: Origin
Access-Control-Expose-Headers: x-amzn-dat-gui-client-upgrade,X-Amzn-Error,loginUrl,X-Amzn-RequestId,x-amzn-alt-domain,Date,Location
Access-Control-Allow-Credentials: true
Date: Sat, 23 Jun 2018 07:51:14 GMT
Connection: close

Works in Hassio until you reboot

Got it working in Hassio OK. But after a reboot it stops working and I have to reload the cookie "/tmp/.alexa.cookie". Is there a way around this?

Italian language

Hi and thanks for this.
Could you please upgrade for Italy?
I tryed just to add it-IT and amazon.it in the remote control script, but I am not sure it is enough.
Thanks!!

Alexa Sound effects?

I'd like to have a sound effect instead of TTS "Door Open"

According to this Alexa Sound Library link, seems like it should be possible to embed in the "speak" variable (could be mistaken) like this:

<speak>
    This is Alexa's regular speech, followed by the sound effect "bear groan roar (1)".
    <audio src='soundbank://soundlibrary/animals/amzn_sfx_bear_groan_roar_01'/>
</speak>

Tried this but not working ... any thoughts?

./alexa_remote_control.sh -d "ALL" -e "speak:'test'.<audio src='soundbank://soundlibrary/home/amzn_sfx_door_open_01'/>"

Hass.io Implementation Help

I have followed each step and have successfully managed to test the commands from the command line.

Since adding to to Hass.io I have tried to make a script call but this doesn't work. I have also tried to make a service call using the following request:

screen shot 2018-12-05 at 23 24 12

But unfortunately upon every call I get the following error:

2018-12-05 23:22:19 ERROR (SyncWorker_15) [homeassistant.components.notify.command_line] Command failed: /config/alexa_wrapper.sh -d 'Nathan's Echo Dot'

I've tried several calls and each time the same thing.

Here's my config.yaml notify:

#Notify
notify:
  - platform: command_line
    name: "Livingroom Echo"
    command: "/config/alexa_wrapper.sh -d 'Nathan's Echo Dot'"

Here's my PATH:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ALEXA_REMOTE="$DIR/alexa_remote_control.sh"

Any help would be greatly appreciated being so close to a result.

Error in read-me

Hi, first off, many thanks for this. TTS was a great addition but this is the icing on the cake.

There is an error in your read me, the command is missing .sh, so should be...

notify:
  - platform: command_line
    name: 'My Dot Name'
    command: "/home/homeassistant/.homeassistant/alexa_wrapper.sh -d 'My Dot Name'"

and

notify:
  - platform: command_line
    name: 'All Alexas'
    command: "/home/homeassistant/.homeassistant/alexa_wrapper.sh -d 'ALL'"

You may also like to add a note for hassio users, the command would be…

command: "/config/alexa_wrapper.sh -d 'ALL'"

...but apart from that the install is identical.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.