synesthesiam / rhasspy

Rhasspy voice assistant for offline home automation
https://rhasspy.readthedocs.io
MIT License
944 stars 101 forks source link

add missing ASR fields for Hermes MQTT publishing #130

Closed janekbettinger closed 4 years ago

janekbettinger commented 4 years ago

I ran into the following error when using hermes-python 0.8.1 to handle an intent:

Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 232, in 'calling callback function'
  File "/my-fs/venv/lib/python3.7/site-packages/hermes_python/ffi/wrappers.py", line 61, in convert_arguments_when_invoking_function
    return func(hermes_client, *parsed_args)
  File "/my-fs/venv/lib/python3.7/site-packages/hermes_python/ffi/wrappers.py", line 60, in <genexpr>
    parsed_args = (handler_argument_type.from_c_repr(arg.contents) for arg in (args))
  File "/my-fs/venv/lib/python3.7/site-packages/hermes_python/ontology/dialogue/intent.py", line 68, in from_c_repr
    c_asr_token_arrays_length = c_repr.asr_tokens.contents.count
ValueError: NULL pointer access

Rhasspy was sending the following MQTT message:

{"sessionId": "", "siteId": "default", "input": "pause", "intent": {"intentName": "Pause", "confidenceScore": 1.0}, "slots": []}

According to the Hermes protocol specification the fields asrTokens and asrConfidence are not optional.

Indeed, manually publishing the following message works:

{"sessionId": "", "siteId": "default", "input": "pause", "intent": {"intentName": "Pause", "confidenceScore": 1.0}, "slots": [], "asrTokens": [], "asrConfidence": 1}

(Note that it would also work without asrConfidence)

synesthesiam commented 4 years ago

Great, thank you!