Alexa Notifications - Override/Reroute Speech Commands

Ask questions about integrating other services (internet and otherwise) and applications with Indigo.
ar26pt2
Posts: 25
Joined: Thu Jan 23, 2014 3:52 pm
Contact:

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by ar26pt2 »

Ok I hacked together a script for pushing speech through to my Echos.. A python script that rewrites the alexa-send-command.js replacing an anchor/placeholder with and indigo variable. Then an applescript that runs it in a terminal window. I have these run as an action group i call whenever I update the variable and want to push that as speech to certain alexa devices. It seems to work, but alexa does not like speech strings that get too long. I'm a terrible self taught coder so please be kind.
1. Follow directions earlier in this thread to get node.js and the alexa-remote code and the send-alexa-command.js
2. modify send-alexa-command.js file to change the sendCommand line to:

Code: Select all

sendCommand("speak", "SAYANCHOR", ["Kitchen", "Master", "Front Room"]);
In my example I am just using "speech" only and only sending it to three of my Echo devices, change to aliases of your devices of course.
3. copy or rename that file to send-alexa-base.js
4. Make action group "say alexa variable" with #1 a python script:

Code: Select all

saythis=str(indigo.variables['alexatextforspeech'].value)
import codecs
def process(lines):
    for line in lines:
        yield line.replace('SAYANCHOR',saythis)

base = '///Users/Indigo/Desktop/AlexaRemote/send-alexa-base.js'
new= '///Users/Indigo/Desktop/AlexaRemote/send-alexa-newcmd.js'
with codecs.open(base, 'r', 'utf-8') as infile:
    with codecs.open(new, 'w', 'utf-8') as outfile:
        for line in process(infile):
            outfile.write(line)
infile.close()
outfile.close()
And then step #2 is an applescript with a :01sec delay:
tell application "Terminal"
set currentTab to do script "cd ~/Desktop/AlexaRemote && node ./send-alexa-newcmd.js"
end tell
delay 8
tell application "Terminal" to close (get window 1)
Voila! Now I write scripts or functions to update the variable and then follow with this action group to push it out. Can link some Alexa-Hue devices as functions such as "Alexa, check house status" and the like and can then get feedback with low latency. I'm sure there is a prettier way to do this, but (again) amateur coder here!
Seeker
Posts: 441
Joined: Mon Aug 05, 2013 5:08 am

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by Seeker »

I'm following this closely, as my Sonos announcements (which have worked fairly reliably with the indigo Sonos plugin for a couple of years) do not work at this moment.
autolog
Posts: 4077
Joined: Tue Sep 10, 2013 3:07 am
Location: West Sussex, UK
Contact:

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by autolog »

Seeker wrote:I'm following this closely, as my Sonos announcements (which have worked fairly reliably with the indigo Sonos plugin for a couple of years) do not work at this moment.
Also, see this tread for useful info and scripts: Alexa Announcements :)
ckeyes888
Posts: 2438
Joined: Thu Nov 26, 2009 2:41 pm
Location: Kalispell, MT

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by ckeyes888 »

Seeker wrote:I'm following this closely, as my Sonos announcements (which have worked fairly reliably with the indigo Sonos plugin for a couple of years) do not work at this moment.
Not the easiest thing to get working but so well worth it!
I originally had Sonos speakers throughout the house that were nice for music but annoyingly intermittent for announcements.
After setting up Alexa in most every room I changed to simple Airplay speakers to handle announcements, which was also hit and miss.

Now with Alexa handling announcements I was able to get rid of the Airplay speakers.
Been up and running a few weeks now with no issues and am impressed with the voice options and quality.

Many thanks for all the help in getting it working!

Carl
User avatar
mundmc
Posts: 1068
Joined: Fri Sep 14, 2012 4:34 pm

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by mundmc »

ckeyes888 wrote:
Seeker wrote:I'm following this closely, as my Sonos announcements (which have worked fairly reliably with the indigo Sonos plugin for a couple of years) do not work at this moment.
Not the easiest thing to get working but so well worth it!
I originally had Sonos speakers throughout the house that were nice for music but annoyingly intermittent for announcements.
After setting up Alexa in most every room I changed to simple Airplay speakers to handle announcements, which was also hit and miss.

Now with Alexa handling announcements I was able to get rid of the Airplay speakers.
Been up and running a few weeks now with no issues and am impressed with the voice options and quality.

Many thanks for all the help in getting it working!

Carl
This might be what I needed to read in order to get me to take a swing at this!
User avatar
mwoodage
Posts: 189
Joined: Fri Dec 19, 2014 8:35 am
Location: Devon UK

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by mwoodage »

Hello,
I thought i would have a play with this today and see if i can get it working - however i see there is a note at the bottom of your instructions for "if you're outside of the US". I've clicked on the link but can't seem to find any further info - are you able to point me in the right direction so it will work in the UK?

* The attached file will have to be edited if you are outside the United States. See the alexa-remote repo for more details.
Thanks
Martin
siclark
Posts: 2356
Joined: Tue Jun 13, 2017 5:08 am
Location: UK

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by siclark »

Martin.
Follow Jon's autolog direction here. Both he and I are in the UK.


Alexa Announcements
https://r.tapatalk.com/shareLink/topic? ... source=app

It's very quick to get working.
User avatar
mwoodage
Posts: 189
Joined: Fri Dec 19, 2014 8:35 am
Location: Devon UK

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by mwoodage »

siclark wrote:Martin.
Follow Jon's autolog direction here. Both he and I are in the UK.


Alexa Announcements
https://r.tapatalk.com/shareLink/topic? ... source=app

It's very quick to get working.

Thanks siclark, i'll give that a go :D

Cheers
Martin
User avatar
mundmc
Posts: 1068
Joined: Fri Sep 14, 2012 4:34 pm

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by mundmc »

This is awesome, really awesome. I'm a dummy and never saw that you posted an attachment for "send-alexa-command.js", so that was an hour of screwing with npm and node, but I finally saw it and it was a piece of cake. Thank you. Questions will follow!
ckeyes888
Posts: 2438
Joined: Thu Nov 26, 2009 2:41 pm
Location: Kalispell, MT

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by ckeyes888 »

Anyone know if this method could play a sound file instead of an announcement?

Thanks,

Carl
User avatar
whmoorejr
Posts: 844
Joined: Tue Jan 15, 2013 11:23 am
Location: Houston, TX

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by whmoorejr »

ckeyes888 wrote:Anyone know if this method could play a sound file instead of an announcement?

Thanks,

Carl

I've been trying, but no luck so far. There is a listing of Amazon sound files: https://developer.amazon.com/en-US/docs ... brary.html

but I haven't figured out the right way to put it into the .js file.... in the below example, I'm getting "Hello" on my echo dot, but nothing else.

Code: Select all

        
        let customSSML = "<speak>" +
        	"Hello" +
            "<audio src='soundbank://soundlibrary/animals/amzn_sfx_bear_groan_roar_01'/>" +
        	"</speak>"; 
        sendCommand("ssml", customSSML, ["Echo Bill's Office"]);
               
Tried putting it all on one line.... still only hear "hello". No bears.

Code: Select all

 sendCommand("ssml", "<speak>hello<audio src='soundbank://soundlibrary/animals/amzn_sfx_bear_groan_roar_01'/> </speak>", ["Echo Bill's Office"]);
               
Bill
My Plugin: My People
ckeyes888
Posts: 2438
Joined: Thu Nov 26, 2009 2:41 pm
Location: Kalispell, MT

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by ckeyes888 »

Well, given my non-existent programming skills I’m certainly pulling for anyone who might find a way.

Carl
User avatar
mundmc
Posts: 1068
Joined: Fri Sep 14, 2012 4:34 pm

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by mundmc »

Any progress on this?
User avatar
whmoorejr
Posts: 844
Joined: Tue Jan 15, 2013 11:23 am
Location: Houston, TX

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by whmoorejr »

mundmc wrote:Any progress on this?
For playing sounds, I’m guessing something needs to be added to the .js file near the bottom where it identifies commands. That’s a total guess because I’m not a programmer either... just a copy and paste warrior.
Bill
My Plugin: My People
User avatar
mundmc
Posts: 1068
Joined: Fri Sep 14, 2012 4:34 pm

Re: Alexa Notifications - Override/Reroute Speech Commands

Post by mundmc »

whmoorejr wrote:
mundmc wrote:Any progress on this?
For playing sounds, I’m guessing something needs to be added to the .js file near the bottom where it identifies commands. That’s a total guess because I’m not a programmer either... just a copy and paste warrior.
Same here!
Post Reply

Return to “Integrating Services/Applications”