How to error out (with sound) during intent handling?


I’m trying to let Rhasspy know when something has gone wrong during the intent handling (can’t connect to an external service or the user has tried to do something invalid) and I want the session to end (as opposed to timeout) and play the error sound at the correct location.

This is what I tried:

    def _error(self, client, site_id, session_id, custom_data):

        # I tried a lot of different variations of the following, but none of them quite worked
        # the "continueSession" got close, but would re-beep and then error, which not quite right
        # I disabled/enabled these as needed depending on the message I was trying to publish
        notification = {
            "siteId": site_id,
            "sessionId": session_id,
            "customData": f"{custom_data}",
            "error": f"{custom_data}",
            "termination": "error",
        client.publish("hermes/dialogueManager/intentNotRecognized", json.dumps(notification))
        client.publish("hermes/dialogueManager/sessionEnded", json.dumps(notification))
        client.publish("hermes/error/dialogueManager", json.dumps(notification))
        client.publish("hermes/error/nlu", json.dumps(notification))  # probably not this one!

and the notification print would look something like this (again sort of depending on what was in the message):

{'siteId': 'default', 'sessionId': 'default-jarvis_linux-e0be5916-5742-48cc-b2e1-14857fbeacd0', 'customData': 'Timer has to be set for more than 0 seconds'}

I’m curious which is the right message to publish to and if the behavior I’m looking for (play the error beep) makes sense.

My workaround is just to play the error sound with playBytes and call hermes/dialogueManager/endSession.

Let me know!

From the code, the only time the error is played is when an intent is not recognized:

So you have to publish is message to: hermes/nlu/intentNotRecognized

From the docs here Reference - Rhasspy, these are required:

  • input
  • id
  • siteId
  • sessionId

Try sending this payload to hermes/nlu/intentNotRecognized:
{"id: : null, "input": "", "siteId":"your_site_id","sessionId": "session_id"}

Obviously replace the siteId and sessionId like you already have in your code.
I have tried it (even without Id to that does not seem to be required) and the error sound was played, followed by an sessionEnded message :slight_smile:
When I remove input node, it stopped working. I think only input, siteId and sessionId are actually required.

The code is here by the way:

Lookup the

async def on_message(

yes, that did it! and thanks for the link to the code - I still need to familiarize myself with more of the Rhasspy codebase for sure!

1 Like