-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically decode JSON payload in on_topic decorator #8
Comments
This would actually help issue #12 aswell. By decoding the payload before passing to the decorated method to a dictionary for example, you could access the slots by just |
But then this example "@app.on_topic("hermes/+/{site_id}/playBytes/#")" would not work anymore. In some of my cases I need the payload as bytes. |
Yes, I would definitely make this optional. @H3adcra5h are you using the |
Yes I do. That's why I implemented this. In my app(s) I do much more than intent handling. Some of my own sensors communicating over MQTT and I use this project too. Otherwise I would have to implement it twice. On simple example where I use the bytes is publishing messages for all satellites if an important alert comes in. My master is running complete headless, no mic no speaker. For alerting if use hermes/tts/say on the master I copy the results from hermes/audioServer/master/playBytes to all satellites. It's faster than using "say" for all satellites. |
I would definitely make it opt out though. I think for most usecases a standard decoded format is the way to go. |
It depends on the use case of course. I'm not sure which use cases are the most popular, because frankly I have no clue who is using rhasspy-hermes-app :-) In SnipsKit I did decode the payload as JSON by default: https://snipskit.readthedocs.io/en/latest/API.html#module-snipskit.mqtt.decorators. If I remember correctly, I did this because then you wouldn't have to do anything special to be able to address the JSON content like a dict, e.g. What other use cases are you seeing, @JonahKr? |
I was more thinking about the users rather than the specific appliences. |
The intention for my implementation was the possibility to handle topics outside of the main scope "intent handling" in a flexible way. The decorator will definitely work with all topics. Most of the topics in rhasspy are json based, that's true, but not all, e.g. playBytes or audioCaptured. If you want to make it as easy as possible, than all main topics should have it's own decorator. |
From the forum:
The text was updated successfully, but these errors were encountered: