Run File on Recognize Wake Word($10 to charity of your choice for best answer)

Looking for a way to run a Python file to turn on onboard lights on a respeaker 6 microphone whenever a wake word is recognized. Also a way to stop that script when Rhasspy stops listening.

Thanks

Hi!

This might be of interest:

Hope this helps.

Yes, we made it compatible with rhasspy last month.

Actually it does works, but we need rhasspy publishing all hermes topics like snips/alice does to fully work and have leds following mqtt activity.

HLC also allow to configure actions on button pressed. I use it with snips to disable wakeword, but here we need a way to do it with rhasspy.

Haven’t got around to trying it yet but looks like the best reply. $10 to what charity?

On my pi HermesLedControl was not working, or not how i expected. I can’t remember exactly.
So i wrote a small phyton script that works for me until the whole hermes stuff is implemented. Then I will try HermesLedControl again. :wink:

I use marytts and this is also published over mqtt. I’m not a python developer, so maybe something could be better. Here is my really short temporary solution:

import logging
import time

import paho.mqtt.client as mqtt
from gpiozero import LED
from pixel_ring import pixel_ring

MQTT_IP = 'xxx.xxx.xxx.xxx'
MQTT_PORT = 1883


def on_message(client, userdata, message):
    if 'hermes/nlu/intentNotRecognized' == message.topic:
        logging.info('intent not recognized')
        pixel_ring.think()
        time.sleep(0.5)
        pixel_ring.off()

    if 'rhasspy/de/transition/SnowboyWakeListener' == message.topic:
        if 'loaded' == str(message.payload.decode("utf-8")):
            logging.info('listen')
            pixel_ring.listen()
            time.sleep(0.5)
            pixel_ring.off()

    if message.topic.startswith('hermes/intent/'):
        logging.info('intent ' + message.topic.rpartition('/')[-1])

    if 'rhasspy/de/transition/MaryTTSSentenceSpeaker' == message.topic:
        state = str(message.payload.decode("utf-8"))
        if 'speaking' == state:
            logging.info('speaking')
            pixel_ring.speak()
       elif 'ready' == state:
            logging.info('speaking done')
            pixel_ring.off()


if __name__ == '__main__':
    logging.basicConfig(filename='test.log', level=logging.INFO)
    power = LED(5)
    power.on()

    pixel_ring.set_brightness(5)
    pixel_ring.change_pattern('echo')

    client = mqtt.Client('my_pi')
    client.connect(MQTT_IP, port=MQTT_PORT)
    client.on_message = on_message
    client.loop_start()
    client.subscribe('hermes/nlu/intentNotRecognized')
    client.subscribe('rhasspy/de/transition/SnowboyWakeListener')
    client.subscribe('hermes/intent/#')
    client.subscribe('rhasspy/de/transition/MaryTTSSentenceSpeaker')
    logging.info('starting pixels')

    while True:
        try:
            time.sleep(3)
        except KeyboardInterrupt:
            client.loop_stop()
            break

    pixel_ring.off()
    power.off()
    time.sleep(1)
1 Like

Yes HLC works with snips (and now Alice) Hermes topics. Actually they are not all published by rhasspy so obviously hlc can’t get the messages. Should be ok when rhasspy publish all of them.

Tell me, where did you add this so that it could run my python script to turn on the LEDs? project-alice-assistant/HermesLedControl does not work with respeaker core v2 and therefore I am looking for another way. My LEDs are turned on by this pixel_ring project, but you need to somehow run this script or just make one file as you indicated and have the LEDs turn on

I figured out this difficult task myself and I published the solution here