Alexa TTS (Text-To-Speech) [and more] plug-in for Vera

just get your cookie manually. instructions are on GitHub or a couple of posts before.

I have the cookie, unless we’re thinking that it’s failed somehow?

 ls -altr
drwxr-xr-x    6 root     root             0 Jan  1  1970 ..
-rw-r--r--    1 root     root         71316 Mar 24 07:17 .alexa.login
-rwx------    1 root     root          2505 Mar 24 07:47 .alexa.cookie
-rw-r--r--    1 root     root          7249 Mar 24 07:48 .alexa.devicelist.txt
-rw-r--r--    1 root     root          8174 Mar 24 07:48 .alexa.devicelist.json
-rw-r--r--    1 root     root            58 Mar 24 07:48 .alexa.devicelist.all
-rwxrwxrwx    1 root     root         33826 Mar 27 08:53 alexa_remote_control_plain.sh
drwxr-xr-x    2 root     root             0 Mar 27 08:53 .

C

drwxr-xr-x    8 root     root             0 Jan  1  1970 ..
-rwxrwxrwx    1 root     root         33826 Mar 20 15:33 alexa_remote_control_plain.sh
-rw-r--r--    1 root     root         71311 Mar 24 18:10 .alexa.login
-rw-r-----    1 root     root          2988 Mar 24 18:14 .alexa.cookie
-rw-r--r--    1 root     root         14481 Mar 24 18:14 .alexa.devicelist.txt
-rw-r--r--    1 root     root         16354 Mar 24 18:14 .alexa.devicelist.json
-rw-r--r--    1 root     root            47 Mar 24 18:14 .alexa.devicelist.all
drwxr-xr-x    2 root     root             0 Mar 27 08:53 .

why does mine show 8 and your 6?

I had problems too, the same day you posted your first one. I resolved by:

  • opening Chrome (I use Edge Chromium as my daily browser by now)
  • logging in again, after clearing all the cookies
  • altering the script and using the same user agent as my browser

I suspect Amazon has changed something on their end, so they’re more aggressive with captcha, unless they find you’re logging with a similar browser. I can provide you a patch to specify the same user agent as your Chrome browser, it should be doable quite easily.

1 Like

No idea!

C

I had to replace my cookie on the same day, i used firefox mobile app with cookie text addon. I did not delete cookies(as annoying) i just cut the section that refered to layla anD amazon. all worked as soon as cookie was replaced.

Thanks. Just for reference should the .alexa.login file get updated each time a TTS is run, or is it persistent as it were?

My cookie is from Firefox (as that’s where I originally found the simplest export method.

Thanks again, both

C

it should stay, unless it’s not valid and the script tries to refresh it - that’s your case, I suspect. I will just delete everything (all the file starting with .) and start again with a fresh cookie.

1 Like

Thanks

cd /storage/alexa
rm .alexa.*
cd ~
mv cookies.txt .alexa.cookie
cp .alexa.cookie /storage/alexa

Ran this in AltUI Lua test:

luup.call_action("urn:dlna-org:serviceId:DLNAMediaController1", "Say", {Text="Rachel has left the building", Volume=40,GroupZones="Office"}, 167)

Now the files have re-populated:

ls -ltra
drwxr-xr-x    6 root     root             0 Jan  1  1970 ..
-rwxrwxrwx    1 root     root         33826 Mar 27 08:53 alexa_remote_control_plain.sh
-rwx------    1 root     root          2404 Mar 27 10:03 .alexa.cookie
-rw-r--r--    1 root     root          7249 Mar 27 10:04 .alexa.devicelist.txt
-rw-r--r--    1 root     root          8174 Mar 27 10:04 .alexa.devicelist.json
-rw-r--r--    1 root     root            58 Mar 27 10:04 .alexa.devicelist.all
drwxr-xr-x    2 root     root             0 Mar 27 10:04 .

But no .alexa.login and no speech.

(and that was a brand new cookie from Firefox this morning)

Thanks again

C

as I said, try with my suggestion: use a brand new browser, login and then copy the user agent into the .sh script.

Thanks

Pretty much what I did.
Firefox is a browser I don’t use, but cleared all the data
Logged into Amazon
Exported the cookie

Where am I going to find the user agent to copy? There's nothing obvious in the cookie apart from:
# Netscape HTTP Cookie File

# https://curl.haxx.se/rfc/cookie_spec.html

# This is a generated file! Do not edit.

Thanks again!

C

Just go to a site like https://www.whatsmyua.info/ :wink:

Ahh HAH

So this is what I have in my alexa_remote_control_plane.sh

SET_BROWSER='Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:74.0) Gecko/20100101 Firefox/74.0'
#SET_BROWSER='Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:1.0) bash-script/1.0'
#SET_BROWSER='Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0'
${CURL} ${OPTS} -s -b ${COOKIE} -A "Mozilla/5.0" -H "DNT: 1" -H "Connection: keep-alive" -L\

Still not working though :frowning:
That user agent I got from Firefox in case that’s not obvious.

Still no login file or, pretty obviously, speech :slight_smile:

Any other suggestions?

Thanks (again and again)

C

OK fixed it.

The cookie for www.amazon.co.uk does not match the cookie for layla.amazon.co.uk which is my Alexa Host

Sorry if this was obvious to everyone else. Really appreciate your help!

C

1 Like

Thanks for the plug-in and for this thread of info. I have the TTS working on my veraplus for a project to TTS “mail” on our “Kitchen Dot” when the mailbox door sensor is opened.

How do specify a different echo for a second scene? For example, TTS “goodnight” on the “Bedroom Dot” when the lights are turned off?

I have created groups in the Alexa app and organized “Bedroom Dot” in the Bedroom group and “Kitchen Dot” in the Kitchen group. I have configured the DefaultEcho variable in the AlexaTTS device (created via Apps, Develop Apps, Create device) to be “Kitchen Dot” and I specified GroupZones=“Kitchen” in the Mailbox scene’s Luup Code and GroupZones=“Bedroom” in the new Goodnight scene. The Kitchen Dot is doing the TTS for both scenes.

Do I create a second Alexa TTS device via Apps, Develop Apps, Create device, and specify “Bedroom Dot” for the DefaultEcho variable?

1 Like

Nope you just need to specify your target echo in the TTS string:

luup.call_action("urn:dlna-org:serviceId:DLNAMediaController1", "Say", {Text="Testing", Volume=40,GroupZones="Living_Room_dot"}, 167)

For example. No idea how you’re generating your string, but change GroupZones to your desired target. You only need the one TTS device.

Does that help?

C

Yes, that helped. I was able to use the echo’s name “Bedroom Dot” or “Kitchen Dot” in the GroupZones variable and TTS worked on those specific Dots. I was confused by some replies in this thread and I thought GroupZones was for the group name in the Alexa app.

I’m generating the string by typing the code in the scene’s “Also, execute the following Luup code:” field. Is there another way? I saw some screenshots by cw-kid in this thread that looked different and had fields to enter the text in.

Thank you

That maybe through reactor. It allows you to fill in the blank variable fields I think you may be able to do the same in the advanced scene editor

1 Like

Good stuff.

There’s nothing wrong with what you’re doing at all, it’s a great way to do simple stuff (although Reactor might be a little more flexible with no extra (IMHO) effort.

It’s also possible to generate your calls in Lua.
I am no coder but with the help of those here I managed to create things like this:

local HallTemp = math.floor(0.5+luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 80))
local HallSet = math.floor (0.5+luup.variable_get("urn:upnp-org:serviceId:TemperatureSetpoint1", "CurrentSetpoint", 80))
local KitchenTemp = math.floor(0.5+luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 154))
local BedroomTemp = math.floor(0.5+luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 216))
local GardenTemp = math.floor(0.5+luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 185))
luup.call_action("urn:dlna-org:serviceId:DLNAMediaController1", "Say", {Text="The temperature in the hall is"..HallTemp.."degrees. Hall Set Point is" ..HallSet.. "degrees. Its" ..KitchenTemp.. "degrees in the kitchen. " ..BedroomTemp.. "degrees in the bedroom and the temperature outside is" ..GardenTemp.. "degrees.",Volume=40,GroupZones="Living_Room_dot"}, 167)

Which runs and tells me the temperatures in various parts of the house and outside…

C

You can also do local http request to your vera box

http://192.168.1.110:3480/data_request?id=action&DeviceNum=102&serviceId=urn:dlna-org:serviceId:DLNAMediaController1&action=Say&Text=say-this-line