I am using Mycroft with Google AIY Voice kit (BLUE BUTTON).
AIM: Every time the button is pressed, I want to Activate the “hello-world skill” and say something to the user.
WHAT I TRIED: Modified the “button.py” code as follows:
------START OF CODE----------------------------------------------------------------
import subprocess
import time
import RPi.GPIO as GPIO
from subprocess import call
while True:
if GPIO.input(gpio_pin) == False: # Listen for the press
call([‘python’, “/home/pi/say_command.py”, “localhost”, “Emergency”])
GPIO.cleanup()
----------END OF CODE-----------------------------------------------------------
Note: Emergency is the intent in the “vocab/en-us” folder
PROBLEM: When the button is pressed after reboot,
the “skill-hello-world” skill is activated and speaks out what is present in the dialog folder of “skill-hello-world”, but ONLY ONCE (sometimes twice).
After which when the button is pressed, there is no response from the R-Pi.
Hi there @vailshery, thanks for reaching out to us, and huge well done on extending Mycroft so far!
I’m going to ping my colleague @forslund here to see if he may have any advice.
What would be useful here is if you have the mycroft-skills.log available for us to review?
it’s hard to say since the formatting of the code is missing. But I tried the say_command.py from the commandline and the first time I ran it it hanged. This might be what’s causing your issue. The call() method hangs and blocks subsequent calls.
Try the command from the command line and see if you get similar behaviour. You could try using the send function in the mycroft.messagebus.send instead of using the subprocess.call
Sorry for the improper formatting since I just did a copy+paste.
When I run “say_command.py Emergency”, my skill is activated and runs once or sometimes at least for 5 times.
The behaviour is similar when i use the call() method in “button.py”
I will try using the send function and check the results.
I edited the code in the “button.py” script as mentioned in the code section below.
I also edited the skill folders (cd skills) as mentioned just below this line under the NOTE section.
NOTE:
“introduction” is the utterance which should be in the “/home/pi/skills/skill-intro/vocab/en- us/intro.voc”.
(1.a) Change the contents of the .dialog file in the dialog folder of the particular skill you are using as per
your requirments. (what the assistant speaks ;)).
“call” is the utterance which should be in the “/home/pi/skills/skill-call/vocab/en-us/call.voc”.
(2.a) Change the contents of the .dialog file in the dialog folder of the particular skill you are using as per
your requirements. (Lights up the LED in my case;)).
(2.b) In my case, the GPIO which provides LOGIC HIGH as output is used to trigger a GSM module.
I will attach the video of the same.
The solution to the problem is
"call([‘python’, ‘-m’, ‘mycroft.messagebus.send’, ‘recognizer_loop:utterance’, ‘{“utterances”: [“call”]}’])"
PS: Use without quotes
Thanks enormously for such a great writeup, @vailshery! We really appreciate it! Hope you don’t mind, I made a small edit to the formatting of the post so that the code displays as a code block
Again, many thanks both for figuring this out and also for writing it up so that others can learn from your work.