Alexa Notifications - Override/Reroute Speech Commands

Posted on
Mon Nov 11, 2019 8:28 pm
ar26pt2 offline
Posts: 23
Joined: Jan 23, 2014

Re: Alexa Notifications - Override/Reroute Speech Commands

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!

Posted on
Fri Nov 29, 2019 4:19 am
Seeker offline
Posts: 425
Joined: Aug 05, 2013

Re: Alexa Notifications - Override/Reroute Speech Commands

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.

Posted on
Fri Nov 29, 2019 5:29 am
autolog offline
Posts: 3500
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Alexa Notifications - Override/Reroute Speech Commands

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 :)

Posted on
Fri Nov 29, 2019 4:27 pm
ckeyes888 offline
Posts: 2279
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Alexa Notifications - Override/Reroute Speech Commands

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

Posted on
Sat Nov 30, 2019 2:08 pm
mundmc offline
User avatar
Posts: 814
Joined: Sep 14, 2012

Re: Alexa Notifications - Override/Reroute Speech Commands

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!

Posted on
Sat Feb 01, 2020 4:08 am
mwoodage offline
User avatar
Posts: 103
Joined: Dec 19, 2014
Location: Devon UK

Re: Alexa Notifications - Override/Reroute Speech Commands

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

Posted on
Sat Feb 01, 2020 5:43 am
siclark offline
Posts: 1568
Joined: Jun 13, 2017
Location: UK

Re: Alexa Notifications - Override/Reroute Speech Commands

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.

Posted on
Sat Feb 01, 2020 11:21 am
mwoodage offline
User avatar
Posts: 103
Joined: Dec 19, 2014
Location: Devon UK

Re: Alexa Notifications - Override/Reroute Speech Commands

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

Posted on
Wed Mar 25, 2020 3:16 pm
mundmc offline
User avatar
Posts: 814
Joined: Sep 14, 2012

Re: Alexa Notifications - Override/Reroute Speech Commands

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!

Posted on
Sun May 03, 2020 3:18 pm
ckeyes888 offline
Posts: 2279
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Alexa Notifications - Override/Reroute Speech Commands

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

Thanks,

Carl

Posted on
Tue May 05, 2020 11:29 am
whmoorejr offline
User avatar
Posts: 522
Joined: Jan 15, 2013
Location: Houston, TX

Re: Alexa Notifications - Override/Reroute Speech Commands

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/alexa/custom-skills/ask-soundlibrary.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

Posted on
Tue May 05, 2020 3:59 pm
ckeyes888 offline
Posts: 2279
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Alexa Notifications - Override/Reroute Speech Commands

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

Carl

Posted on
Tue May 12, 2020 10:25 am
mundmc offline
User avatar
Posts: 814
Joined: Sep 14, 2012

Re: Alexa Notifications - Override/Reroute Speech Commands

Any progress on this?

Posted on
Tue May 12, 2020 1:02 pm
whmoorejr offline
User avatar
Posts: 522
Joined: Jan 15, 2013
Location: Houston, TX

Re: Alexa Notifications - Override/Reroute Speech Commands

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

Posted on
Tue May 12, 2020 2:00 pm
mundmc offline
User avatar
Posts: 814
Joined: Sep 14, 2012

Re: Alexa Notifications - Override/Reroute Speech Commands

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!

Who is online

Users browsing this forum: No registered users and 1 guest