Alexa Notifications - Override/Reroute Speech Commands

Posted on
Tue Oct 01, 2019 6:19 pm
ckeyes888 offline
Posts: 2280
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Alexa Notifications - Override/Reroute Speech Commands

James wrote:
You may have to install the Xcode Command Line Tools.

I believe this method still works:

http://osxdaily.com/2014/02/12/install- ... -mac-os-x/


Sent from my iPhone using Tapatalk


Thanks. I had installed Xcode some time ago. I’ll try your link to reinstall.
This would be an awesome thing to get working.

edit: Ran the link above and it seemed to install the Xcode tools without issue...but still get the same errors I posted above
when running:

cd ~/Desktop/Alexa && npm install github:Apollon77/alexa-remote.git && node ./send-alexa-command.js

Carl
Last edited by ckeyes888 on Tue Oct 01, 2019 6:38 pm, edited 1 time in total.

Posted on
Tue Oct 01, 2019 6:23 pm
ckeyes888 offline
Posts: 2280
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Alexa Notifications - Override/Reroute Speech Commands

indigobo wrote:
I'm a newb myself, but I did have success with using the above instructions. Did you download Node.js?


Yes, thanks. I was able to get that installed and download and rename the send-alexa-command file.
Just stuck on step 2.

Carl

Posted on
Wed Oct 02, 2019 4:22 pm
ckeyes888 offline
Posts: 2280
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Alexa Notifications - Override/Reroute Speech Commands

Finally got it installed but am missing how to execute the scripts in Indigo.
Also, I’m hoping it’s possible to send the contents of a variable to speak?
Any help appreciated!

Thanks,

Carl
Attachments
4DD0C250-391C-4EE8-B956-F5EADC346C9B.jpeg
4DD0C250-391C-4EE8-B956-F5EADC346C9B.jpeg (120.37 KiB) Viewed 1453 times

Posted on
Wed Oct 02, 2019 6:50 pm
James offline
Posts: 22
Joined: Aug 16, 2011

Re: Alexa Notifications - Override/Reroute Speech Commands

The steps I posted above were just to provide an example. The scripts do not integrate at all with Indigo. Although, my original purpose for this thread was to see if I could override Indigo’s speech function in an effort to create such an integration.

I don’t think overriding the function in Python will work, so maybe I’ll come up with another method when I have time.

Right now I’m just setting an Indigo variable with the text I want spoken, and a trigger runs a script when that variable changes to send the command to Alexa (then sets the variable back to empty).

Posted on
Wed Oct 02, 2019 7:33 pm
ckeyes888 offline
Posts: 2280
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Alexa Notifications - Override/Reroute Speech Commands

James wrote:
Right now I’m just setting an Indigo variable with the text I want spoken, and a trigger runs a script when that variable changes to send the command to Alexa (then sets the variable back to empty).


That’s exactly how I’ve been handling announcements in Indigo...without Alexa.
Love to hear how you’ve done it with Alexa...or maybe how you might get it to work in the future.

Thanks,

Carl

Posted on
Fri Oct 11, 2019 4:26 pm
indigobo offline
User avatar
Posts: 22
Joined: Jan 04, 2019
Location: Raleigh, NC

Re: Alexa Notifications - Override/Reroute Speech Commands

James, I can't tell you how much fun I've had with this... Thank you, thank you, thank you!

I do however have a question. Is there a way to send multiple commands at the same time so that a first command would complete before performing the second command? For example, have Alexa read out today's calendar events and she is finished, then start reading out tomorrow's calendar events. I've kind of got this working now but am using two different scripts to accomplish it. The problem (other than me :wink:) is that some days are busier than others so I can't set a specific amount of pause between the commands to make it work out right. On that note, if I had to use a hard pause, can it be placed in your script directly.

Sorry for the questions. Man this would make an awesome plug-in!!

All the best!

Posted on
Sat Oct 12, 2019 11:14 am
ckeyes888 offline
Posts: 2280
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Alexa Notifications - Override/Reroute Speech Commands

indigobo wrote:
James, ....Man this would make an awesome plug-in!!


+20 on that!

For now maybe share how you’re sending these commands to Alexa?

Thanks,

Carl

Posted on
Sat Oct 12, 2019 11:46 am
jens offline
Posts: 265
Joined: May 03, 2015
Location: Sweden

Re: Alexa Notifications - Override/Reroute Speech Commands

Yes please, test message work but I can not get some other spetch:)

//Jens


Skickat från min iPhone med Tapatalk Pro

Posted on
Sat Oct 12, 2019 5:58 pm
indigobo offline
User avatar
Posts: 22
Joined: Jan 04, 2019
Location: Raleigh, NC

Re: Alexa Notifications - Override/Reroute Speech Commands

@Carl I can tell you how I'm doing it, but I have no way of knowing if it is the "correct" way since I have very little coding knowledge. That being said here goes.

Step 1

Follow the directions at the beginning of this thread.

Step 2

Open the send-alexa-command.js file located in the Alexa folder on your Desktop.

Change the part under // Change the sendCommand call below to send a command to one or more of your Alexa devices. to the following:

Code: Select all
sendCommand("speak", 70, "This is a test. Hello World!");


Then save the file. MAKE SURE THAT THE FILE IS SAVED AS PLAIN TEXT NOT RTF!

Step 3

Create a script by simply creating an empty TextEdit document and insert the following:

Code: Select all
#!/bin/bash
cd Desktop/Alexa
node ./send-alexa-command.js


Save the file as test.sh inside the Alexa folder. (MAKE SURE THAT THE FILE IS SAVED AS PLAIN TEXT NOT RTF)

Step 4

In indigo create a new action in Action Groups.
Under Type select Server Actions >> Script and File Actions >> Run Shell Script.
In the popup window delete what's inside the field Full path to file on server.
Locate the test.sh file you just created and drag it on top of the empty Full path to file on server field.

Save the action.

You can then try the action by selecting Execute Actions Only located at the bottom right of the Indigo Home Screen.

The reason I'm doing it this way is because it does things in the background and doesn't require me to open the Terminal app. Initially, I wanted a way to call the node ./send-alexa-command.js directly from within Indigo but couldn't figure out how to do it. Hope this helps, but remember that you get what you pay for :D .

Posted on
Sat Oct 12, 2019 8:25 pm
ckeyes888 offline
Posts: 2280
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Alexa Notifications - Override/Reroute Speech Commands

Great, thanks. I’ll give it a try

Carl

Posted on
Wed Nov 06, 2019 9:11 am
whmoorejr offline
User avatar
Posts: 522
Joined: Jan 15, 2013
Location: Houston, TX

Re: Alexa Notifications - Override/Reroute Speech Commands

I'm stuck on Step2. I am getting an error, but not the same one.
Code: Select all
WHM-Server:~ williammoore$ cd ~/Desktop/Alexa && npm install github:Apollon77/alexa-remote.git && node ./send-alexa-command.js
npm WARN engine http-proxy@1.18.0: wanted: {"node":">=6.0.0"} (current: {"node":"4.8.0","npm":"2.15.11"})
alexa-remote2@2.5.5 ../../node_modules/alexa-remote2
├── https@1.0.0
├── extend@3.0.2
├── querystring@0.2.0
├── uuid@3.3.3
├── ws@6.2.1 (async-limiter@1.0.1)
└── alexa-cookie2@2.1.0 (cookie@0.4.0, http-proxy-response-rewrite@0.0.1, express@4.17.1, http-proxy-middleware@0.19.1)
/Users/williammoore/Desktop/Alexa/send-alexa-command.js:2
let Alexa = require('alexa-remote2');
^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:140:18)
    at node.js:1043:3

Anything to point me in the right direction would be great.

Bill
My Plugin: My People

Posted on
Wed Nov 06, 2019 4:33 pm
whmoorejr offline
User avatar
Posts: 522
Joined: Jan 15, 2013
Location: Houston, TX

Re: Alexa Notifications - Override/Reroute Speech Commands

whmoorejr wrote:
I'm stuck on Step2.

I'm now unstuck. It was a Node.js thing. So I installed the newer version of Node.js, but the old version was still the active one being accessed. When looking up how to force an update or remove and start from scratch, I had to do some sudo command wizardry. That sorta worked..... at least to the point where
Code: Select all
node --version
and
Code: Select all
npm --version
were showing the update.... but when I ran Step 2, it was looking for node in /opt/local/bin/node instead of where it installed at /usr/local/bin/node. Since I couldn't figure out how to tell it to look in the correct place, I just copied node and npm into the opt/local/bin folder. Got the cookie error, provided the German page with my amazon credentials and poof.... all my echo devices announced the test.

Bill
My Plugin: My People

Posted on
Wed Nov 06, 2019 5:24 pm
whmoorejr offline
User avatar
Posts: 522
Joined: Jan 15, 2013
Location: Houston, TX

Re: Alexa Notifications - Override/Reroute Speech Commands

indigobo wrote:
Code: Select all
#!/bin/bash
cd Desktop/Alexa
node ./send-alexa-command.js
.


had to add "~/" to the script before "Desktop" to work for me. (working like a charm now)
Code: Select all
#!/bin/bash
cd ~/Desktop/Alexa
node ./send-alexa-command.js

or
Code: Select all
#!/bin/bash
cd ~/Desktop/Alexa && node ./send-alexa-command.js


Thank your for all your work on this, I'm really looking forward to implementing this in with my stuff.

Bill
My Plugin: My People

Posted on
Fri Nov 08, 2019 10:01 pm
whmoorejr offline
User avatar
Posts: 522
Joined: Jan 15, 2013
Location: Houston, TX

Re: Alexa Notifications - Override/Reroute Speech Commands

James wrote:
There are actually! Here is a list of commands you can use using my previous example:
    weather
    traffic
    flashbriefing
    goodmorning
    singasong
    tellstory
    calendarToday
    calendarTomorrow
    calendarNext
    volume*
    deviceStop
    speak*
    notification*
    announcement*
    ssml*
* Requires additional value

There is MUCH more you can do if you are familiar with programming. See the source file for all the functions you can perform:

[


Thank you again for posting all of this and your examples. Do you know of a way to send a string of commands in one shot? weather + ssml + calendarTomorrow?

Bill
My Plugin: My People

Posted on
Sun Nov 10, 2019 11:06 pm
ar26pt2 offline
Posts: 23
Joined: Jan 23, 2014

Re: Alexa Notifications - Override/Reroute Speech Commands

This tool seems great and powerful, thank you so much for sharing!

Small caution for n00bs: I was using TextEdit to modify the .js file. It was inserting "smart quotes" in place of standard quotations which messes up the file encoding/reading by node.js creating many errors. Before editing code with textedit, turn off smart quotes, smart dashes and everything else smart and rich in the TextEdit preferences... :roll: :roll:
Thanks again!
aaron

Who is online

Users browsing this forum: No registered users and 1 guest