[Deprecated] Amazon Alexa Text to Speech (TTS) v0.6.2 - Direct Integration (USA, Canada, UK, Italy, Australia, & Brazil)

I think that error is a catch-all error message. I've seen it thrown when there's too many TTS requests in a short time.

1 Like

Thank you! I just checked and the Alexa TTS is still working, so I'll just let it keep running.

1 Like

So I'm working on setting up 3 tablets to speak messages. I was able to successfully get all 3 to speak the message (4 out of 6 times), but only if I put in a 1 second delay between each. If it errors 1 or 2 of the tablets will typically say something along the lines of "Sorry, I'm having trouble understanding right now, please try again later".

Has anyone else seen this type of behavior and found a way to fix it?

I believe you are running into the Amazon imposed throttling restriction. If you try to send too many speak commands at the same time, the Amazon servers throw an error.

Adding slight delays is definitely a solution.

I believe the Echo Speaks integration implements some sort of queuing mechanism to space out the requests. I have not added any such feature to my Alexa TTS integration.

1 Like

Thanks Ogiewon

1 Like

I haven't really invested much time in the Alexa API, but it looks like there's an announcement API as well that will broadcast to multple Echos with the preceding announcement tone. Echo Speaks looks like it allows you to pick the specific echos, but for my purposes I always want to broadcast everywhere so I replaced the command in Alexa TTS with this (based on the Echo Speaks code), which works for me:

command = "{\"behaviorId\":\"PREVIEW\",\"sequenceJson\":\"{\\\"@type\\\":\\\"com.amazon.alexa.behaviors.model.Sequence\\\",\\\"startNode\\\":{\\\"@type\\\":\\\"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode\\\",\\\"operationPayload\\\":{\\\"customerId\\\":\\\"${MEDIAOWNERCUSTOMERID}\\\",\\\"expireAfter\\\":\\\"PT5S\\\",\\\"content\\\":[{\\\"locale\\\":\\\"${LANGUAGE}\\\",\\\"display\\\":{\\\"title\\\":\\\"AlexaTTS\\\",\\\"body\\\":\\\"${message}\\\"},\\\"speak\\\":{\\\"type\\\":\\\"text\\\",\\\"value\\\":\\\"${message}\\\"}}],\\\"target\\\":{\\\"customerId\\\":\\\"${MEDIAOWNERCUSTOMERID}\\\"}},\\\"type\\\":\\\"AlexaAnnouncement\\\"}}\",\"status\":\"ENABLED\"}"

None of my business really, but I'd suggest sending that as a pull request to @ogiewon on Github.

Also, I can see there's at least a bunch of escape characters have been stripped (and maybe other things as well) in what you've cut & pasted. So, I'd recommend using blockquote (<\>) in the editor while pasting code.

Thanks, fixed the formatting.

I thought about doing a PR, but I really don't have time to do this right, this is just a hack that replaces the ability to send speech to individual echos since that's all I needed. I just installed a single echo and renamed it to "announcement device"

It would be better to add a playAnnouncement() or playAnnouncementAll() method similar to what echo speaks does. Or possibly to add an "All Echos" child device.

I'd do this if I had time, but realistically it's not going to get done. :slight_smile:

1 Like

I was thinking the same thing. I really like this idea so I will try to work on adding an "All Echos" child device. This way users can select individual devices, or all of them at once.

Thanks for to idea and the code snippet! I'll let you all know when it is ready for testing.

2 Likes

Would the playing to 'All echos' be in sync like when playing songs via Spotify Connect or would they play staggered? If the playback is synchronized, that would be a useful addition.

@rjb.bob - I copied and pasted your code snippet from above into my Alexa TTS App to compare it against the existing "command = ..." string. They appear to be identical. Can you please share your entire Alexa TTS App source code with me so I can determine what the changes were?

Thanks,
Dan

@ogiewon

Oops, sorry, I must have copied the original line instead of the modified one.

                // announce to all echos
                command = "{\"behaviorId\":\"PREVIEW\",\"sequenceJson\":\"{\\\"@type\\\":\\\"com.amazon.alexa.behaviors.model.Sequence\\\",\\\"startNode\\\":{\\\"@type\\\":\\\"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode\\\",\\\"operationPayload\\\":{\\\"customerId\\\":\\\"${MEDIAOWNERCUSTOMERID}\\\",\\\"expireAfter\\\":\\\"PT5S\\\",\\\"content\\\":[{\\\"locale\\\":\\\"${LANGUAGE}\\\",\\\"display\\\":{\\\"title\\\":\\\"AlexaTTS\\\",\\\"body\\\":\\\"${message}\\\"},\\\"speak\\\":{\\\"type\\\":\\\"text\\\",\\\"value\\\":\\\"${message}\\\"}}],\\\"target\\\":{\\\"customerId\\\":\\\"${MEDIAOWNERCUSTOMERID}\\\"}},\\\"type\\\":\\\"AlexaAnnouncement\\\"}}\",\"status\":\"ENABLED\"}"
                //    command = "{\"behaviorId\":\"PREVIEW\",\"sequenceJson\":\"{\\\"@type\\\":\\\"com.amazon.alexa.behaviors.model.Sequence\\\",\\\"startNode\\\":{\\\"@type\\\":\\\"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode\\\",\\\"type\\\":\\\"${SEQUENCECMD}\\\",\\\"operationPayload\\\":{\\\"deviceType\\\":\\\"${DEVICETYPE}\\\",\\\"deviceSerialNumber\\\":\\\"${DEVICESERIALNUMBER}\\\",\\\"locale\\\":\\\"${LANGUAGE}\\\",\\\"customerId\\\":\\\"${MEDIAOWNERCUSTOMERID}\\\"${TTS}}}}\",\"status\":\"ENABLED\"}"
4 Likes

I have uploaded the new Alexa TTS App to my GitHub repository. This version (0.5.6) will allow you to select an "All Echos" device in addition to all of the other Echo devices associated with your account. You can then use this device to send broadcast TTS messages to all of your echos at once.

Thanks @rjb.bob for the code snippet and idea to add this simple solution. This also will help prevent users from bumping up against Amazon's rate limiting threshold.

Please give it a try and let me know how it goes for you.

3 Likes

Will do - will the "All Echos" device have the announcement tone before the TTS announcement?

1 Like

Yes, there is an announcement tone.

2 Likes

@ogiewon

I noticed you were working on adding volume controls too. This should help. Its very similar to the tts code (thats why I didn't rename the variable) just uses a different command and value.

def SEQUENCECMD = "Alexa.DeviceControls.Volume"
def TTS= ",\\\"value\\\":\\\"${volume}\\\"" //volume can be 0-100
def command = "{\"behaviorId\":\"PREVIEW\",\"sequenceJson\":\"{\\\"@type\\\":\\\"com.amazon.alexa.behaviors.model.Sequence\\\",\\\"startNode\\\":{\\\"@type\\\":\\\"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode\\\",\\\"type\\\":\\\"${SEQUENCECMD}\\\",\\\"operationPayload\\\":{\\\"deviceType\\\":\\\"${DEVICETYPE}\\\",\\\"deviceSerialNumber\\\":\\\"${DEVICESERIALNUMBER}\\\",\\\"locale\\\":\\\"${LANGUAGE}\\\",\\\"customerId\\\":\\\"${MEDIAOWNERCUSTOMERID}\\\"${TTS}}}}\",\"status\":\"ENABLED\"}"
2 Likes

So after sometime I get the "Alexa TTS: Please check your cookie!" alert even though AlexaCookieNodeJs is running on the Pi. (I did change the ports to 8181 & 8282 as I couldn't get it to work on 81 during the initial install).

I basically have to go back to http://10.0.3.5:8181 login with my Amazon credentials and get the Alexa Cookie refresh options go back to the App on Hubitat delete the current "Raw or edited cookie" and replace the existing Alexa Cookie refresh option with the new one and save it again. After doing this it starts working again. But after sometime I have to repeat this process.

Any tips on how to resolve this?

@dan.t's fix, described earlier in this thread, works perfectly.

1 Like

I do have the following cron job: 30 2 * * * pm2 restart AlexaCookie

Perhaps it isn't executing correctly or maybe I have another issue? Is there a way to check this?

Are you using PM2 as root? And is your command in root's crontab, or in something like /etc/cron.d

Here's what I have in /etc/cron.d

30 23 * * * root /usr/local/bin/pm2 restart AlexaCookie >/dev/null 2>&1

pm2 on my Ubuntu 18.04 odroid is installed in /usr/local/bin

Edit: Also tabs between the time, root, and the command

1 Like