Page 3 of 4

Re: Alexa Notifications - Override/Reroute Speech Commands

PostPosted: Mon Nov 11, 2019 8:28 pm
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!

Re: Alexa Notifications - Override/Reroute Speech Commands

PostPosted: Fri Nov 29, 2019 4:19 am
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.

Re: Alexa Notifications - Override/Reroute Speech Commands

PostPosted: Fri Nov 29, 2019 5:29 am
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 :)

Re: Alexa Notifications - Override/Reroute Speech Commands

PostPosted: Fri Nov 29, 2019 4:27 pm
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

Re: Alexa Notifications - Override/Reroute Speech Commands

PostPosted: Sat Nov 30, 2019 2:08 pm
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!

Re: Alexa Notifications - Override/Reroute Speech Commands

PostPosted: Sat Feb 01, 2020 4:08 am
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

Re: Alexa Notifications - Override/Reroute Speech Commands

PostPosted: Sat Feb 01, 2020 5:43 am
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.

Re: Alexa Notifications - Override/Reroute Speech Commands

PostPosted: Sat Feb 01, 2020 11:21 am
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

Re: Alexa Notifications - Override/Reroute Speech Commands

PostPosted: Wed Mar 25, 2020 3:16 pm
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!

Re: Alexa Notifications - Override/Reroute Speech Commands

PostPosted: Sun May 03, 2020 3:18 pm
by ckeyes888
Anyone know if this method could play a sound file instead of an announcement?

Thanks,

Carl

Re: Alexa Notifications - Override/Reroute Speech Commands

PostPosted: Tue May 05, 2020 11:29 am
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/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"]);
               

Re: Alexa Notifications - Override/Reroute Speech Commands

PostPosted: Tue May 05, 2020 3:59 pm
by ckeyes888
Well, given my non-existent programming skills I’m certainly pulling for anyone who might find a way.

Carl

Re: Alexa Notifications - Override/Reroute Speech Commands

PostPosted: Tue May 12, 2020 10:25 am
by mundmc
Any progress on this?

Re: Alexa Notifications - Override/Reroute Speech Commands

PostPosted: Tue May 12, 2020 1:02 pm
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.

Re: Alexa Notifications - Override/Reroute Speech Commands

PostPosted: Tue May 12, 2020 2:00 pm
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!