Take variable from voice into Python
-
So basically, I want to take a number I say to Alexa (specifically int), and make a variable from python, that number. Is this possible, and if it is, how can I do it? Thanks
-
@Itricio, you'll need to use one of the non-Smart Home skills - either TRIGGERcmd, or TRIGGER command. The Smart Home skills only pass "on" or "off" as the parameter.
Here's a script that takes a parameter, and passes it back to TRIGGERcmd so you can have Alexa say the parameter back to you if you include {{result}} in the Voice Reply field.
import sys, os if(len(sys.argv) > 1): first_param = sys.argv[1] print('Sending parameter to TRIGGERcmd for Alexa or Google Assistant to speak: ' + first_param) sts = os.system(os.environ['USERPROFILE'] + "\\.TRIGGERcmdData\\SendResult.bat " + first_param) else: print('No script arguments/parameters.')
Assuming you give your script the word "script" in your voice field, say, ""Alexa, ask triggercmd to run script with parameter five."
Here's some more about using the Voice Reply command field:
https://www.triggercmd.com/forum/topic/962/solved-get-alexa-responses-that-contain-a-variable-value-taken-from-a-script/4 -