Re: Alexa Notifications - Override/Reroute Speech Commands
Posted: Mon Nov 11, 2019 8:28 pm
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:
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:
And then step #2 is an applescript with a :01sec delay:
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!
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!