Change wake word response

Hi there! I’m trying to change the wake word response. I’m using a raspberry pi 2. I thought of changing the files in /usr/share/snips/assistant/custom_dialogue/sound/. There I can find the audio played when the wake word is captured and after a command is registered. I’m worried if that is the best way of doing what I want to achieve, speak the wake word and get a custom response. Also, how can I configure my app to don’t play the sound after speak a command?
I’m making an assistant with very few actions and a custom response to every single of them. I’m playing wav files after a intent is captured. If there is a better way to do this please give my some lights. Many thanks!

Have a look at the following option in /etc/snips.toml:

[snips-dialogue]
sound_feedback_disabled_default = true

Thanks!

I also want to get a response after speak the wake word. Like playing a wav file after the wake word detection. Haven’t found anything in the forum. Found some references here: https://docs.snips.ai/reference/hermes but I don’t really know how to implement it :’(

The sound feedback option in /etc/snips.toml is both for the feedback after the wake word is detected and after you have spoken your command.

You can change the wav files in /usr/share/snips/assistant/custom_dialogue/sound/, but they will be overwritten after each update of the assistant.

Yes, I understand that, but… Isn’t there a way to have sound_feedback_disabled_default = true and detect the wake word via python and play a wav file? That way there wouldn’t be a need to replace all the file after every update of the assistant.

If you make snips speak as wakeword detection, snips will hear what was spoken and it won’t work

Humm… Right now this is what I have:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import configparser
from hermes_python.hermes import Hermes
from hermes_python.ffi.utils import MqttOptions
from hermes_python.ontology import *
import io
import paho.mqtt.publish as publish
import paho.mqtt.client as client

# MQTT client to connect to the bus
mqtt_client = client.Client()
HOST = "localhost"
PORT = 1883
HOTWORD_DETECTED = "hermes/hotword/default/detected"

SITE = "default"
SOUNDFILE = "/usr/share/snips/assistant/custom_dialogue/sound/of_course.wav"
START = "/usr/share/snips/assistant/custom_dialogue/sound/start_of_input.wav"

CONFIGURATION_ENCODING_FORMAT = "utf-8"
CONFIG_INI = "config.ini"

class SnipsConfigParser(configparser.SafeConfigParser):
    def to_dict(self):
        return {section : {option_name : option for option_name, option in self.items(section)} for section in self.sections()}

def read_configuration_file(configuration_file):
    try:
        with io.open(configuration_file, encoding=CONFIGURATION_ENCODING_FORMAT) as f:
            conf_parser = SnipsConfigParser()
            conf_parser.readfp(f)
            return conf_parser.to_dict()
    except (IOError, configparser.Error) as e:
        return dict()

def subscribe_intent_callback(hermes, intentMessage):
    conf = read_configuration_file(CONFIG_INI)
    action_wrapper(hermes, intentMessage, conf)

def action_wrapper(hermes, intentMessage, conf):
    print("TEST - RESPONSE")

    binaryFile = open(SOUNDFILE, mode='rb')
    wav = bytearray(binaryFile.read())
    publish.single("hermes/audioServer/{}/playBytes/whateverId".format(SITE), payload=wav, hostname="localhost", client_id="") 

    current_session_id = intentMessage.session_id
    hermes.publish_end_session(current_session_id, "")

# Subscribe to the important messages
def on_connect(client, userdata, flags, rc):
    mqtt_client.subscribe(HOTWORD_DETECTED)

# Process a message as it arrives
def on_message(client, userdata, msg):
    if not msg.topic == HOTWORD_DETECTED:
        return
    else:
        print("--------------- DETECTED ---------------")
        binaryFile = open(START, mode='rb')
        wav = bytearray(binaryFile.read())
        publish.single("hermes/audioServer/{}/playBytes/whateverId".format(SITE), payload=wav, hostname="localhost", client_id="") 

if __name__ == "__main__":
    mqtt_client.on_connect = on_connect
    mqtt_client.on_message = on_message
    mqtt_client.connect(HOST, PORT)
    mqtt_client.loop_forever()

    mqtt_opts = MqttOptions()
    with Hermes(mqtt_options=mqtt_opts) as h:
        h.subscribe_intent("NBatalhaArmis:Open_Door", subscribe_intent_callback) \
         .start()

The wake word is detected and a wav file is played, all fine. The problem comes when I try to speak the intent hotword, it does nothing. I suppose then I can’t make both work like this as you said. Then the option is to change usr/share/snips/assistant/custom_dialogue/sound/ I guess, right?

1 Like

yep, changing the sound is the way to go… As @Val couldn’t make snips understand we need a way to act right after wakeword, before intent detection… The github issue was denied

1 Like

So I think this thread answered my question before I asked…
I was hoping to set something up to have the sound feedback off by default. Then after the hotword if no voice was detected, have it respond “yes” or just beep and start listening again.

A lot of times I can’t directly see the LEDs, so I have no idea if it caught the wake word. It would be nice to have an audio response if you’re trying to talk to it from another room. It would make it more dynamic and natural.
For example, if I begin talking to someone in another room, I usually don’t just keep talking. I usually say their name and wait for them to respond before I get on with my conversation. On the other hand, if I’m staring at someone in the face, I don’t usually wait for them to reply before I speak because I can see I have their attention.

The key would be to only do this if no voice is detected after the hotword. I wouldn’t want the opposite effect if a noisy room it’s constantly saying “yes”.

Changing the wav file is working quite well.

Except the error one which seems not to trigger anymore… any reason that can lead to that?

I agree @Psycho, this would be a great feature and truly needed. It would solve a lot of “hacking”