Giter Site home page Giter Site logo

snipsco / hermes-protocol Goto Github PK

View Code? Open in Web Editor NEW
36.0 36.0 30.0 2.5 MB

Definition of the Hermes protocol used by the Snips platform

Home Page: https://snips.ai

License: Other

Rust 40.70% Shell 0.82% Kotlin 10.86% C 8.83% Python 26.47% JavaScript 2.34% TypeScript 9.98%
hermes javascript kotlin platform protocol python rust

hermes-protocol's People

Contributors

adrienball avatar anthonyray avatar clemdoum avatar cpoisson avatar deluvi avatar dependabot[bot] avatar elbywan avatar fredszaq avatar garvys avatar gstraymond avatar hdlj avatar kali avatar nebuto avatar thomas-bouvier avatar tobor-spins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hermes-protocol's Issues

cannot import name 'DialogueConfiguration'

installed hermes-python 0.4

from the docs at https://hermespython.readthedocs.io/en/latest/tutorial.html#enabling-and-disabling-intents-on-the-fly the code says

from hermes_python.ontology.dialogue.session import DialogueConfiguration

dialogue_conf = DialogueConfiguration()                          \
                        .disable_intent("intent1")               \
                        .enable_intent("intent2")                \
                        .enable_intents(["intent1", "intent2"])  \
                        .disable_intents(["intent2", "intent1"])

hermes.configure_dialogue(dialogue_conf)

when i try to use this code i get

 from hermes_python.ontology.dialogue.session import DialogueConfiguration
ImportError: cannot import name 'DialogueConfiguration'

ARM64 support

I am trying to install Snips in a Pine Rock 64 device.

I have workarounded the installation of Debian packages via sudo dpkg --add-architecture armhf, but I am not able to install python-hermes using any of available wheels (I have tried pip install hermes-python and all whl files in PyPI).

Any hint to install hermes-python in this platform? Which steps are necessary to compile it in the device?

Thanks.

PD: I think that there are many ARM64 devices and providing software for them or at least instructions to install Snips in these platforms would be useful for many people.

[hermes-python] AttributeError: 'TimeIntervalValue' object has no attribute 'slot_value'

With Hermes Python 0.3.3, my apps work fine (build 49). For instance:

date = intent_message.slots.calendar_date.first()

With Hermes Python 0.4.0, the same code fails (build 48) with the following message:

  File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/hermes_python/ontology/dialogue/slot.py", line 63, in first
    return self[0].slot_value.value
AttributeError: 'TimeIntervalValue' object has no attribute 'slot_value'

Using the method first() on CustomValue and InstantTimeValue results in the same error message, and I guess other slot types too. The relevant build log parts from my Travis CI:

$ coverage run test_action_what_is_happening.py
....E.EE.
======================================================================
ERROR: test_get_calendar_from_intent_with_calendar (__main__.TestTools)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_action_what_is_happening.py", line 120, in test_get_calendar_from_intent_with_calendar
    self.assertEqual(tools.get_calendar(intent_message, ""), "computer")
  File "/home/travis/build/koenvervloesem/snips-app-what-is-happening/tools_what_is_happening.py", line 23, in get_calendar
    calendar = str(intent_message.slots.calendar_file.first().value)
  File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/hermes_python/ontology/dialogue/slot.py", line 63, in first
    return self[0].slot_value.value
AttributeError: 'CustomValue' object has no attribute 'slot_value'
======================================================================
ERROR: test_get_date_from_intent_with_interval (__main__.TestTools)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_action_what_is_happening.py", line 164, in test_get_date_from_intent_with_interval
    self.assertEqual(tools.get_date(intent_message), "20181105")
  File "/home/travis/build/koenvervloesem/snips-app-what-is-happening/tools_what_is_happening.py", line 47, in get_date
    date = intent_message.slots.calendar_date.first()
  File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/hermes_python/ontology/dialogue/slot.py", line 63, in first
    return self[0].slot_value.value
AttributeError: 'TimeIntervalValue' object has no attribute 'slot_value'
======================================================================
ERROR: test_get_date_from_intent_with_time (__main__.TestTools)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_action_what_is_happening.py", line 144, in test_get_date_from_intent_with_time
    self.assertEqual(tools.get_date(intent_message), "20181031")
  File "/home/travis/build/koenvervloesem/snips-app-what-is-happening/tools_what_is_happening.py", line 47, in get_date
    date = intent_message.slots.calendar_date.first()
  File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/hermes_python/ontology/dialogue/slot.py", line 63, in first
    return self[0].slot_value.value
AttributeError: 'InstantTimeValue' object has no attribute 'slot_value'
----------------------------------------------------------------------
Ran 9 tests in 0.153s
FAILED (errors=3)
The command "coverage run test_action_what_is_happening.py" exited with 1.

[Python] Segfault occurs when subscribing to an intent out of the context manager

Version
hermes-python 0.1.27
Python 2 and 3

Test script

from hermes_python.hermes import Hermes

def search_weather_callback(hermes, intent_message):
    print("received! {}".format(intent_message.intent.intent_name))

hermes = Hermes("localhost:1883")
hermes.subscribe_intent("SearchWeatherInfo", search_weather_callback)
hermes.loop_forever()

=> segfault at subscribe, should throw an exception instead.

Traces

exception, /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py:102
line, /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py:103
line, /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py:104
call, /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py:104
line, /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py:104
line, /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py:105
line, /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py:106
line, /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py:107
return, /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py:107
line, /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py:108
line, /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py:109
return, /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py:109
call, /Users/charles/.virtualenvs/hermes-py2.7/lib/python2.7/site-packages/hermes_python/hermes.py:53
line, /Users/charles/.virtualenvs/hermes-py2.7/lib/python2.7/site-packages/hermes_python/hermes.py:54
line, /Users/charles/.virtualenvs/hermes-py2.7/lib/python2.7/site-packages/hermes_python/hermes.py:58
return, /Users/charles/.virtualenvs/hermes-py2.7/lib/python2.7/site-packages/hermes_python/hermes.py:58
return, /Users/charles/.virtualenvs/hermes-py2.7/lib/python2.7/site-packages/hermes_python/hermes.py:60
line, /Users/charles/.virtualenvs/hermes-py2.7/lib/python2.7/site-packages/hermes_python/hermes.py:77
line, /Users/charles/.virtualenvs/hermes-py2.7/lib/python2.7/site-packages/hermes_python/hermes.py:78
call, /Users/charles/.virtualenvs/hermes-py2.7/lib/python2.7/site-packages/hermes_python/ffi/utils.py:21
line, /Users/charles/.virtualenvs/hermes-py2.7/lib/python2.7/site-packages/hermes_python/ffi/utils.py:22
[1]    14265 segmentation fault  python test_hermes.py

Simple publish

Allow for users to publish using the connected Hermes mqtt object with their own topic with message, external to the “Hermes” topics

Just because the incoming intent is snips, some intent code that reacts might want to send a topic to an IoT device
hermes/intent/my:intenttv
Now the react code needs to publish mytopics/tv/function {on}

But we don’t want to have to create another mqtt connection when the Hermes object is already connected to the broker

[Python] Exception when txt="" in publish_continue_session()

Version
0.4.1

Description
An exception occurs when providing an empty string to the tts parameters in "publish_continue_session"

Logs

2019-04-29 11:57:26,862 - INFO : SnipsPlatform.terminate - Snips Platform terminated
FAILED

============================================================================================================== FAILURES ===============================================================================================================
__________________________________________________________________________________________ TestContinueSession.test_publish_continue_session __________________________________________________________________________________________

self = <test_dialogue.TestContinueSession object at 0x10fea47b8>

    def test_publish_continue_session(self):
        """
        Given:
            - An assistant containing the weather application is installed.
            - The user utter "Hey Snips! What is the weather in Tokyo"
            - The assistant catch the intent and continue the session and utter some feedback.
    
        When:
            - The user utter "What is the weather in San Francisco?"
    
        Then:
            - The SearchWeatherForecast intent MUST be published.
            - The forecast_locality slot MUST contain the value San Francisco
            - The session is closed after publishing an end session using Hermes.
        """
    
        # Given
        with WeatherDemoAssistant() as weather_assistant:
    
            params = {
                "hijack": True,
                "no_mike": True,
                "sound_feedback_disabled_default": True,
                "assistant": weather_assistant.assistant_path
            }
    
            with SnipsPlatform(**params) as snips:
    
                intent_name = "searchWeatherForecast"
    
                with IntentListener(intent_name) as intent_listener:
                    snips.audio_server.inject_audio(get_asset("hey_snips-whats_the_weather_in_tokyo.wav"))
    
                    assert intent_listener.exists()
    
                    client: Hermes = intent_listener.queue[0].client
                    msg: IntentMessage = intent_listener.queue[0].message
    
>                   client.publish_continue_session(msg.session_id, "", [intent_name])

client     = <hermes_python.hermes.Hermes object at 0x10ff26320>
intent_listener = <snipsbox.hermes.IntentListener object at 0x10ff262b0>
intent_name = 'searchWeatherForecast'
msg        = <hermes_python.ontology.dialogue.intent.IntentMessage object at 0x10ff26978>
params     = {'assistant': '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant',
 'hijack': True,
 'no_mike': True,
 'sound_feedback_disabled_default': True}
self       = <test_dialogue.TestContinueSession object at 0x10fea47b8>
snips      = <snipsbox.services.SnipsPlatform object at 0x10fea4588>
weather_assistant = <snipsbox.assistant.WeatherDemoAssistant object at 0x10fb741d0>

tests/platform/test_dialogue.py:178: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../.virtualenvs/snips-tests/lib/python3.7/site-packages/hermes_python/hermes.py:188: in publish_continue_session
    self.ffi.dialogue.publish_continue_session(continue_session_msg)
../../.virtualenvs/snips-tests/lib/python3.7/site-packages/hermes_python/api/ffi/dialogue.py:135: in publish_continue_session
    message
../../.virtualenvs/snips-tests/lib/python3.7/site-packages/hermes_python/api/ffi/dialogue.py:192: in _call_foreign_function
    ptr_to_foreign_function_argument
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = (<hermes_python.api.ffi.dialogue.LP_CDialogueFacade object at 0x10e397bf8>, <cparam 'P' (0x10ff1c510)>), kwargs = {}, return_code = 1, empty_string = b''
error_p = <hermes_python.ffi.ontology.LP_c_char_p object at 0x10fec4598>, error_cause = 'could not borrow, unexpected null pointer\n'

    def wrapped_library_call(*args, **kwargs):
        return_code = lib_func(*args, **kwargs)
        if return_code > 0:  # An error occured
            empty_string = "".encode('utf-8')
            error_p = POINTER(c_char_p)(c_char_p(empty_string))
            # Retrieve the last error and put it in the memory location error_p points to
            lib.hermes_get_last_error(error_p)
            error_cause = string_at(error_p.contents).decode('utf-8')
>           raise LibException(error_cause)
E           hermes_python.ffi.LibException: could not borrow, unexpected null pointer

args       = (<hermes_python.api.ffi.dialogue.LP_CDialogueFacade object at 0x10e397bf8>,
 <cparam 'P' (0x10ff1c510)>)
empty_string = b''
error_cause = 'could not borrow, unexpected null pointer\n'
error_p    = <hermes_python.ffi.ontology.LP_c_char_p object at 0x10fec4598>
kwargs     = {}
lib_func   = <_FuncPtr object at 0x10fb54048>
return_code = 1

Allow Hermes MQTT client to set a client ID

It would be great if it were possible to also set a client ID for the Hermes MQTT client.

It could be a welcome addition to the existing MQTT options.

This would, for example, allow Hermes to play nice with other MQTT clients on the same system. This is common on smart home controllers. It would guarantee there is no overlap.

Currently I am experiencing disconnect issues. When MQTT detects a new connection it may kill the old one. Naming the clients can help avoid this.

'Continuing a session' from the 'Tutorial' does not work.

The example of 'Continuing a session' from the 'Tutorial' section does not work.

The line 'available_slots = json.loads(intent_message.custom_data)' gives the following error:

Nov 9 22:49:50 INFO:snips_skill_server_lib::runner: [script][err] Traceback (most recent call last):
Nov 9 22:49:50 INFO:snips_skill_server_lib::runner: [script][err] File "_ctypes/callbacks.c", line 234, in 'calling callback function'
Nov 9 22:49:50 INFO:snips_skill_server_lib::runner: [script][err] File "/var/lib/snips/skills/snips-script-skill/venv/lib/python3.5/site-packages/hermes_python/ffi/wrappers.py", line 61, in convert_arguments_when_invoking_function
Nov 9 22:49:50 INFO:snips_skill_server_lib::runner: [script][err] return func(hermes_client, *parsed_args)
Nov 9 22:49:50 INFO:snips_skill_server_lib::runner: [script][err] File "./action-script.py", line 247, in music_section
Nov 9 22:49:50 INFO:snips_skill_server_lib::runner: [script][err] available_slots = json.loads(intentMessage.custom_data)
Nov 9 22:49:50 INFO:snips_skill_server_lib::runner: [script][err] File "/usr/lib/python3.5/json/init.py", line 312, in loads
Nov 9 22:49:50 INFO:snips_skill_server_lib::runner: [script][err] s.class.name))
Nov 9 22:49:50 INFO:snips_skill_server_lib::runner: [script][err] TypeError: the JSON object must be str, not 'NoneType'

Mac OS X Installation failed

What is the issue

I want to install hermes on my Mac and followed the instructions as stated here, but the installation fails with 53 warnings and 5 errors. Building from the sources leads to the same results.

I'm just getting started with snips and hermes and am quite lost on how to fix this problem. Any suggestions?

Screenshot 2019-05-26 at 15 54 32

Logs

2019-05-26T13_49_20_998Z-debug.log

[Python] Missing a connect and disconnect methods

A behavior closer to what paho-mqtt offers could ease the onboarding to hermes.

In my case, I cannot use the context manager and I need to be in control of the loop and the connection to mqtt server.

Here is an e.g of a possible way to code a listening loop.

Blocking

from hermes_python.hermes import Hermes

def search_weather_callback(client, message, ...):
    # Some action scripts related to the intent.
    print("SearchWeatherIntent intent has been requested")

def connect_callback(hermes, ... ):
    hermes.dialog.subscribe("SearchWeatherInfo", search_weather_callback)
    # Other naming are also possible to reflect that we want to react to an event.
    # or hermes.dialog.on("...
    # or hermes.dialog.connect("....  

hermes = Hermes()

hermes.on_connect = connect_callback
hermes.connect("localhost", 1883, 60)

hermes.loop_forever() #Block here

Non Blocking

from hermes_python.hermes import Hermes
import time

class IntentListener(object):

    def __init__(self, host='localhost', port=1883):
        self._client = Hermes()
        self._host = host
        self._port = port
        self._client.on_connect = self._on_connect
        self.intent_stack = list()

    def __del__(self):
        self.stop()

    def search_weather_callback(self, client, message, ...):
        self.intent_stack.append(message)
    
    def _on_connect(self, client, ... ):
         self._client.dialog.subscribe("SearchWeatherInfo", search_weather_callback)

    def start(self):
        self._client.connect(self._host, self._port, 60)
        self.message_stack = list()
        self._client.loop_start()

    def stop(self):
        self._client.loop_stop()
        self._client.disconnect()


listener = IntentListener()
listener.start()
time.sleep(60)  # Talk to the device meanwhile
listener.stop()

print("Received {} SearchWeatherInfo intent(s)".format(len(listener.intent_stack)))

python injection callback

I'm making some injections using the python version. At least I hope so.

How can I get feedback from snips that learning the new injections has finished? Is it this method? If so, is there any indication when it will become available officially? Am I correct in understanding that Kotlin code does already support the call back?

The overview page explains that once one injection should ideally be called at any time. Currently I've set a time delay so that the injection gets called at most once every 10 minutes. On average, how long could an injection for 100 or 1000 words take? Seconds? Minutes?

[python] Missing __version__ attributes to easily check wrapper version.

What's missing

There is no convenience function to retrieve the version of the package.
One must use pip freeze or python -c "import pkg_resources; print(pkg_resources.get_distribution('hermes_python').version)" to retrieve the running version of hermes_python package.

Use cases

  • debug, support
  • application wrapper handling different version of hermes-python in case of breaking changes.

Envisioned Solution
The pythonic way to do it --> hermes_python.__version__

feature request

can we get MqttOptions a method to load its field values from snips.toml file

there would be cases for hermes-python to not load values, so that users can enter in values themselves...
but for snips-skill-server app skills, the MqttOptions should be using mqtt config set within the snips.toml file

We should not have to include all mqtt settings within every snips-skill-server app when this information is already setup in the snips.toml
I should be able to change a single item in the snips.toml and that's it
I should not have to change not only the snips.toml file but then also EVERY config.ini within every single skill folder also

snips.toml is the mecca for settings regarding my snips setup, and ALL snips programs should be using this as the basis for information, or at least provide a single method call on objects like MqttOptions to be able to know i want it to load information from there with me having to manually do it

[python] Add a methods to activate / deactivate the dialogue sounds feedbacks

What's the issue
There is no programmatic way using hermes python to deactivate / activate the sounds feedbacks

The current solution is to use MQTT and thus PAHO

Use cases targeted

  • "Hey snips, activate / deactivate the sounds feedbacks please"
  • Apps could deactivate the sound feedbacks if needed depending on the experience targeted.

[Python] RST rendering is broken on pypi

What is the issue
The rendering of the README is incorrect on pypi.

Logs

Running twine check on version 0.5.2 of the package returns the following output:

python3 -m twine check hermes_python-0.5.2-cp37-cp37m-macosx_10_9_x86_64.whl
Checking distribution hermes_python-0.5.2-cp37-cp37m-macosx_10_9_x86_64.whl: warning: `long_description_content_type` missing.  defaulting to `text/x-rst`.
Failed
The project's long_description has invalid markup which will not be rendered on PyPI. The following syntax errors were detected:
line 658: Warning: Inline literal start-string without end-string

allow subscription to hotword detection

Currently if you want to know if the wake word has been detected, you will need to create a second MQTT client that listen to that event specifically.

It would be great if the wakeword could also be subscribed to somehow via Hermes.

In my case I require this because Snips is unfortunately not able to create audio feedback after hearing the hotword. (The audio settings may not be changed, and pulse audio may not be installed). But Python has no trouble playing a sound. So currently I have created a second MQTT client which plays a sounds through aplay.

It would be great if the extra MQTT client was not required, and all the moments in the dialogue where Snips usually plays a feedback sound could also be taken over through python easily.

Add a guard to prevent missuse of commands in wrong topics

ATM we allays have to specifiy the topic while using a command :
HermesTopic::AudioServer(AudioServerCommand::PlayBytes).as_path().as_ref()

I would be nice not to have to write the HermesTopic::AudioServer part has the AudioServerCommand::PlayBytes ougth to be used in this topic

Will certainly need a clever trick for commands used in mutiple topics (ie version...)

subscribe_session_ended() call results in TypeError: session_ended_handler() takes 2 positional arguments but 3 were given

In the documentation for subscribe_session_ended() it is stated that session-ended-callback function will be called with two arguments: hermes & sessionEndedMessage. However, I am getting an error message

Traceback (most recent call last):
File "_ctypes/callbacks.c", line 234, in 'calling callback function'
File "/home/greg/environments/python3.6/lib/python3.6/site-packages/hermes_python/ffi/wrappers.py", line 61, in convert_arguments_when_invoking_function
return func(hermes_client, *parsed_args)
TypeError: session_ended_handler() takes 2 positional arguments but 3 were given

By trial and error I noticed that the following implementation does not result in error.
def session_ended_handler(hermes, undocumented_argument, sessionEndedMessage):
print('\tEnding session id=%s ' %(sessionEndedMessage.session_id))

LibException after building from Source (Win10)

I am trying to build hermes-python from source on Windows 10 and Python 3. I followed the instructions from here.

When I run the python setup.py bdist_wheel --include-extension=../../target/release/hermes_mqtt_ffi.dll command, it will copy the extension to hermes-protocol\platforms\hermes-python\hermes_python\dylib and then continue without errors (as far as I could see). Also the hermes_python-0.7.0-cp37-cp37m-win32.whl has been generated and I can install it, however it has only some 44KB which seemed wierd to me, as the extension alone has >5MB.

When I run some script which uses hermes_python like this
from hermes_python.hermes import Hermes
I get the following exception at
with Hermes(MQTT_ADDR) as h:
hermes_python.ffi.LibException: Trying to call mocked FFI library

Any hints to what could have gone wrong? Thanks in advance!

[Python] Enhancement to manage all the slots in order they were said

Hello,

I have developped my own skill to manage my shopping list with Snips.

In this skill, I have two kind of slots:

  • items (for example tomatoes)
  • optional quantities (for example when I want 4 tomatoes)

In this skill, I can ask to add more than one item in the same intent (for example to add tomatoes and bananas in the same phrase).

With the current implementation of Hermes in Python, when I add two items in one intent, I'm not able to make sure which quantity is for which item.

For example, if I ask to add "tomatoes and 4 bananas", I will get item[0] = "Tomatoes", item[1] = "Bananas" and quantity[0] = 4. But, I would get the exact same result if I asked to add "4 tomatoes and bananas".

Would it be possible to add a new function to get all the slots in a list. In my example, I would get slots[0] = "Tomatoes", slots[1] = 4 and slots[2] = "Bananas" ?

Thanks a lot,

publish_continue_session() error

Hi, I am getting the following error massage when calling publish_continue_session() to clarify a slot (intent filter is set to a single intent). From the MQTT bus monitor, I can see that NLU gets the slot correctly filled, however due to error below my callback function is not being called. Any suggestions?

Traceback (most recent call last):
File "_ctypes/callbacks.c", line 234, in 'calling callback function'
File "/home/greg/environments/python3.6/lib/python3.6/site-packages/hermes_python/ffi/wrappers.py", line 61, in convert_arguments_when_invoking_function
return func(hermes_client, *parsed_args)
File "/home/greg/environments/python3.6/lib/python3.6/site-packages/hermes_python/ffi/wrappers.py", line 60, in
parsed_args = (handler_argument_type.from_c_repr(arg.contents) for arg in (args))
File "/home/greg/environments/python3.6/lib/python3.6/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

Add a way to get the currently enabled intents

The new functionality to enable and disable intents on the fly is awesome! I used it in my app Keep quiet to ask your assistant to stop replying to your voice commands until you ask it to talk to you again.

This works like this:

  • koan:Quiet - I disable all intents except koan:Talk.
  • koan:Talk - I re-enable all intents that are enabled by default and I disable the other ones.

However, at any time other apps could have enabled intents that are disabled by default and/or disabled intents that are enabled by default. So to play nice with other apps, I really should do the following:

  • koan:Quiet - Store the currently enabled intents in a list, and disable all these intents except koan:Talk.
  • koan:Talk - Re-enable all intents that were enabled before receiving koan:Quiet. The ones that were disabled before are not in our list, so they stay disabled.

Currently the only way I see I could do that is by letting the app constantly monitor which intents get enabled or disabled and update this in a list. However, I think it would be useful if we could ask the Hermes object which intents are currently enabled. Not only for this app, but I guess for other apps it could be useful too, so they don't have to monitor this status of the intents themselves.

Would it be possible to add this functionality? For instance, just a method to ask whether a specific intent is currently enabled would already be very useful.

Installing hermes-python from source

I am trying to install hermes-python from source according to the instructions from:
https://pypi.org/project/hermes-python/

When running the following code using git bash:
mkdir -p platforms/hermes-python/target
CARGO_TARGET_DIR=platforms/hermes-python/target cargo rustc --lib --manifest-path hermes-mqtt-ffi/Cargo.toml --release -- --crate-type cdylib

several files and folders are created in the folder "/hermes-protocol/platforms/hermes-python/target/release":
build deps examples hermes_mqtt_ffi.d hermes_mqtt_ffi.dll hermes_mqtt_ffi.dll.d hermes_mqtt_ffi.dll.lib hermes_mqtt_ffi.lib incremental libhermes_mqtt_ffi.d libhermes_mqtt_ffi.rlib native

However the dynamically linked shared object library libhermes_mqtt_ffi.dylib is missing.
Do you know what the reason could be?

[Python] Registered callbacks are still invoked after disconnecting hermes client.

What is the issue
Registered callbacks are still invoked after disconnecting hermes client.
It leads to the following problems:

  • Invoke actions we don't want to trigger.
  • Program fault when the registered callback has been destroyed and garbage collected.

Protocol

  • Create an hermes client object and register a callback on an event
  • disconnect the client
  • Create an hermes client object and register an another callback on the same event.
  • Trigger the event

Observed

Both callbacks are invoked.

Logs

From a test suite using hermes invent listener embedded in a context manager. Exiting the context calls the correct method to disconnect the hermes client.

pytest tests -svv --cache-clear --showlocals --log-level=debug                                      

========================================================================================================= test session starts =========================================================================================================
platform darwin -- Python 3.7.2, pytest-4.4.1, py-1.8.0, pluggy-0.9.0 -- /Users/charles/.virtualenvs/snips-tests/bin/python3
cachedir: .pytest_cache
rootdir: /Users/charles/Workspace-snips/snips-platform-tests
collected 3 items                                                                                                                                                                                                                     

First tests starts and instantiate two listeners during its execution:

  • IntentListener-7b17
  • EndSessionListener-2216
tests/platform/test_dialogue.py::TestPublishEndSession::test_publish_end_session 2019-04-29 13:27:27,532 - DEBUG : SnipsPlatform.start - Snips Platform is starting...
2019-04-29 13:27:27,653 - DEBUG : SnipsAudioServer._start_process - Started - ['snips-audio-server', '--hijack', '0.0.0.0:8888', '--no-mike', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96067).
2019-04-29 13:27:27,786 - DEBUG : SnipsService._start_process - Started - ['snips-hotword', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96068).
2019-04-29 13:27:27,906 - DEBUG : SnipsService._start_process - Started - ['snips-asr', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96071).
2019-04-29 13:27:28,032 - DEBUG : SnipsService._start_process - Started - ['snips-nlu', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96072).
2019-04-29 13:27:28,158 - DEBUG : SnipsDialogue._start_process - Started - ['snips-dialogue', '--sound-feedback-disabled-default', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96073).
2019-04-29 13:27:28,283 - DEBUG : SnipsService._start_process - Started - ['snips-tts', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96074).
2019-04-29 13:27:28,284 - INFO : SnipsPlatform.start - Snips Platform started
2019-04-29 13:27:28,284 - DEBUG : IntentListener-7b17.start - Connecting to localhost:1883
2019-04-29 13:27:28,293 - DEBUG : IntentListener-7b17._subscribe_event - Subscribed to event
2019-04-29 13:27:28,294 - INFO : IntentListener-7b17.start - Listening started
2019-04-29 13:27:28,294 - INFO : SnipsAudioServer.inject_audio - Streaming /Users/charles/Workspace-snips/snips-platform-tests/tests/platform/assets/hey_snips-whats_the_weather_in_tokyo.wav to localhost:8888
2019-04-29 13:27:28,295 - DEBUG : SnipsAudioServer.inject_audio - Stream finished
2019-04-29 13:27:32,798 - DEBUG : IntentListener-7b17._on_event - Event received, queue length: 1
2019-04-29 13:27:32,802 - DEBUG : EndSessionListener-2216.start - Connecting to localhost:1883
2019-04-29 13:27:32,804 - DEBUG : EndSessionListener-2216._subscribe_event - Subscribed to event
2019-04-29 13:27:32,804 - INFO : EndSessionListener-2216.start - Listening started
2019-04-29 13:27:32,805 - DEBUG : EndSessionListener-2216._on_event - Event received, queue length: 1
2019-04-29 13:27:32,905 - DEBUG : EndSessionListener-2216.stop - Stop Listening 
2019-04-29 13:27:33,008 - INFO : EndSessionListener-2216.stop - Listening stopped
2019-04-29 13:27:33,009 - DEBUG : IntentListener-7b17.stop - Stop Listening 
2019-04-29 13:27:33,107 - INFO : IntentListener-7b17.stop - Listening stopped
2019-04-29 13:27:33,107 - DEBUG : SnipsPlatform.terminate - Snips Platform is terminating...
2019-04-29 13:27:33,110 - DEBUG : SnipsAudioServer.terminate - Terminated - ['snips-audio-server', '--hijack', '0.0.0.0:8888', '--no-mike', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96067).
2019-04-29 13:27:33,114 - DEBUG : SnipsService.terminate - Terminated - ['snips-hotword', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96068).
2019-04-29 13:27:33,119 - DEBUG : SnipsService.terminate - Terminated - ['snips-asr', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96071).
2019-04-29 13:27:33,135 - DEBUG : SnipsService.terminate - Terminated - ['snips-nlu', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96072).
2019-04-29 13:27:33,137 - DEBUG : SnipsDialogue.terminate - Terminated - ['snips-dialogue', '--sound-feedback-disabled-default', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96073).
2019-04-29 13:27:33,138 - DEBUG : SnipsService.terminate - Terminated - ['snips-tts', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96074).
2019-04-29 13:27:33,138 - INFO : SnipsPlatform.terminate - Snips Platform terminated
PASSED

Looks good, the second test starts

tests/platform/test_dialogue.py::TestPublishEndSession::test_session_timeout

We force the garbage collection of python objects here.

2019-04-29 13:27:33,149 - DEBUG : EndSessionListener-2216.__del__ - Delete object invoked
2019-04-29 13:27:33,150 - DEBUG : IntentListener-7b17.__del__ - Delete object invoked

The previous listeners are deleted by the garbage collector.

2019-04-29 13:27:33,150 - DEBUG : SnipsPlatform.start - Snips Platform is starting...
2019-04-29 13:27:33,283 - DEBUG : SnipsAudioServer._start_process - Started - ['snips-audio-server', '--hijack', '0.0.0.0:8888', '--no-mike', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96075).
2019-04-29 13:27:33,415 - DEBUG : SnipsService._start_process - Started - ['snips-hotword', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96076).
2019-04-29 13:27:33,537 - DEBUG : SnipsService._start_process - Started - ['snips-asr', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96077).
2019-04-29 13:27:33,662 - DEBUG : SnipsService._start_process - Started - ['snips-nlu', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96078).
2019-04-29 13:27:33,785 - DEBUG : SnipsDialogue._start_process - Started - ['snips-dialogue', '--sound-feedback-disabled-default', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96079).
2019-04-29 13:27:33,908 - DEBUG : SnipsService._start_process - Started - ['snips-tts', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96080).
2019-04-29 13:27:33,908 - INFO : SnipsPlatform.start - Snips Platform started
2019-04-29 13:27:33,908 - DEBUG : IntentListener-4de8.start - Connecting to localhost:1883
2019-04-29 13:27:33,909 - DEBUG : IntentListener-4de8._subscribe_event - Subscribed to event
2019-04-29 13:27:33,910 - INFO : IntentListener-4de8.start - Listening started
2019-04-29 13:27:33,910 - INFO : SnipsAudioServer.inject_audio - Streaming /Users/charles/Workspace-snips/snips-platform-tests/tests/platform/assets/hey_snips-whats_the_weather_in_tokyo.wav to localhost:8888
2019-04-29 13:27:33,911 - DEBUG : SnipsAudioServer.inject_audio - Stream finished
[1]    96066 illegal hardware instruction (core dumped)  pytest tests -svv --cache-clear --showlocals --log-level=debug

Here we crash. A method in a previously destroyed object was called.

The following logs shows what happen when the garbage collection is not forced.

tests/platform/test_dialogue.py::TestPublishEndSession::test_session_timeout 2019-04-29 13:37:14,449 - DEBUG : SnipsPlatform.start - Snips Platform is starting...
2019-04-29 13:37:14,581 - DEBUG : SnipsAudioServer._start_process - Started - ['snips-audio-server', '--hijack', '0.0.0.0:8888', '--no-mike', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96161).
2019-04-29 13:37:14,713 - DEBUG : SnipsService._start_process - Started - ['snips-hotword', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96162).
2019-04-29 13:37:14,841 - DEBUG : SnipsService._start_process - Started - ['snips-asr', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96163).
2019-04-29 13:37:14,968 - DEBUG : SnipsService._start_process - Started - ['snips-nlu', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96164).
2019-04-29 13:37:15,093 - DEBUG : SnipsDialogue._start_process - Started - ['snips-dialogue', '--sound-feedback-disabled-default', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96165).
2019-04-29 13:37:15,215 - DEBUG : SnipsService._start_process - Started - ['snips-tts', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96166).
2019-04-29 13:37:15,215 - INFO : SnipsPlatform.start - Snips Platform started
2019-04-29 13:37:15,215 - DEBUG : IntentListener-cf64.start - Connecting to localhost:1883
2019-04-29 13:37:15,217 - DEBUG : IntentListener-cf64._subscribe_event - Subscribed to event
2019-04-29 13:37:15,217 - INFO : IntentListener-cf64.start - Listening started
2019-04-29 13:37:15,217 - INFO : SnipsAudioServer.inject_audio - Streaming /Users/charles/Workspace-snips/snips-platform-tests/tests/platform/assets/hey_snips-whats_the_weather_in_tokyo.wav to localhost:8888
2019-04-29 13:37:15,218 - DEBUG : SnipsAudioServer.inject_audio - Stream finished
2019-04-29 13:37:19,671 - DEBUG : IntentListener-eeca._on_event - Event received by an inactive listener. Ignoring...

Hum, this listener was not instantiated in this tests, the method call backed as not been garbage collected yet.

2019-04-29 13:37:19,672 - DEBUG : IntentListener-cf64._on_event - Event received, queue length: 1
2019-04-29 13:37:19,733 - DEBUG : EndSessionListener-dfc6.start - Connecting to localhost:1883
2019-04-29 13:37:19,735 - DEBUG : EndSessionListener-dfc6._subscribe_event - Subscribed to event
2019-04-29 13:37:19,735 - INFO : EndSessionListener-dfc6.start - Listening started
2019-04-29 13:37:25,041 - DEBUG : EndSessionListener-dfc6._on_event - Event received, queue length: 1
2019-04-29 13:37:25,042 - DEBUG : EndSessionListener-ea75._on_event - Event received by an inactive listener. Ignoring...

This listener too

2019-04-29 13:37:25,073 - DEBUG : EndSessionListener-dfc6.stop - Stop Listening 
2019-04-29 13:37:25,177 - INFO : EndSessionListener-dfc6.stop - Listening stopped
2019-04-29 13:37:25,177 - DEBUG : IntentListener-cf64.stop - Stop Listening 
2019-04-29 13:37:25,260 - INFO : IntentListener-cf64.stop - Listening stopped
2019-04-29 13:37:25,260 - DEBUG : SnipsPlatform.terminate - Snips Platform is terminating...
2019-04-29 13:37:25,263 - DEBUG : SnipsAudioServer.terminate - Terminated - ['snips-audio-server', '--hijack', '0.0.0.0:8888', '--no-mike', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96161).
2019-04-29 13:37:25,267 - DEBUG : SnipsService.terminate - Terminated - ['snips-hotword', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96162).
2019-04-29 13:37:25,271 - DEBUG : SnipsService.terminate - Terminated - ['snips-asr', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96163).
2019-04-29 13:37:25,287 - DEBUG : SnipsService.terminate - Terminated - ['snips-nlu', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96164).
2019-04-29 13:37:25,289 - DEBUG : SnipsDialogue.terminate - Terminated - ['snips-dialogue', '--sound-feedback-disabled-default', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96165).
2019-04-29 13:37:25,291 - DEBUG : SnipsService.terminate - Terminated - ['snips-tts', '--assistant', '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant'] (pid=96166).
2019-04-29 13:37:25,291 - INFO : SnipsPlatform.terminate - Snips Platform terminated
PASSED

[Python 3] AttributeError: 'bytes' object has no attribute 'encode' in TimeIntervalValue.from_c_repr

In the class method from_c_repr of the class ontology.TimeIntervalValue from_date and to_date are encoded to UTF-8. Shouldn't that be decoded, like in the rest of the classes?

I get the following error after converting one of my apps from Python 2 to 3:

Jan 28 21:53:12 snips snips-skill-server[2635]: INFO:snips_skill_server_lib::runner: [what-is-happening][err]   File "_ctypes/callbacks.c", line 234, in 'calling callback function'
Jan 28 21:53:12 snips snips-skill-server[2635]: INFO:snips_skill_server_lib::runner: [what-is-happening][err]   File "/var/lib/snips/skills/snips-app-what-is-happening/venv/lib/python3.5/site-packages/hermes_python/hermes.py", line 63, in
 called_with_good_params                                                                              
Jan 28 21:53:12 snips snips-skill-server[2635]: INFO:snips_skill_server_lib::runner: [what-is-happening][err]     return func(self, *parsed_args)
Jan 28 21:53:12 snips snips-skill-server[2635]: INFO:snips_skill_server_lib::runner: [what-is-happening][err]   File "/var/lib/snips/skills/snips-app-what-is-happening/venv/lib/python3.5/site-packages/hermes_python/hermes.py", line 62, in
 <genexpr>                                                                                            
Jan 28 21:53:12 snips snips-skill-server[2635]: INFO:snips_skill_server_lib::runner: [what-is-happening][err]     parsed_args = (argtype.from_c_repr(arg.contents) for arg in (args))
Jan 28 21:53:12 snips snips-skill-server[2635]: INFO:snips_skill_server_lib::runner: [what-is-happening][err]   File "/var/lib/snips/skills/snips-app-what-is-happening/venv/lib/python3.5/site-packages/hermes_python/ontology.py", line 41,
in from_c_repr                                                                                                
Jan 28 21:53:12 snips snips-skill-server[2635]: INFO:snips_skill_server_lib::runner: [what-is-happening][err]     slots = SlotMap.from_c_repr(c_repr.slots.contents)
Jan 28 21:53:12 snips snips-skill-server[2635]: INFO:snips_skill_server_lib::runner: [what-is-happening][err]   File "/var/lib/snips/skills/snips-app-what-is-happening/venv/lib/python3.5/site-packages/hermes_python/ontology.py", line 72,
in from_c_repr                                                                                          
Jan 28 21:53:12 snips snips-skill-server[2635]: INFO:snips_skill_server_lib::runner: [what-is-happening][err]     nlu_slot = NluSlot.from_c_repr(c_slots_array_repr[i].contents)
Jan 28 21:53:12 snips snips-skill-server[2635]: INFO:snips_skill_server_lib::runner: [what-is-happening][err]   File "/var/lib/snips/skills/snips-app-what-is-happening/venv/lib/python3.5/site-packages/hermes_python/ontology.py", line 113,
 in from_c_repr                                                                                       
Jan 28 21:53:12 snips snips-skill-server[2635]: INFO:snips_skill_server_lib::runner: [what-is-happening][err]     slot = Slot.from_c_repr(c_repr.nlu_slot[0])
Jan 28 21:53:12 snips snips-skill-server[2635]: INFO:snips_skill_server_lib::runner: [what-is-happening][err]   File "/var/lib/snips/skills/snips-app-what-is-happening/venv/lib/python3.5/site-packages/hermes_python/ontology.py", line 148,
 in from_c_repr                                                                                               
Jan 28 21:53:12 snips snips-skill-server[2635]: INFO:snips_skill_server_lib::runner: [what-is-happening][err]     slot_value = SlotValue.from_c_repr(c_repr.value)
Jan 28 21:53:12 snips snips-skill-server[2635]: INFO:snips_skill_server_lib::runner: [what-is-happening][err]   File "/var/lib/snips/skills/snips-app-what-is-happening/venv/lib/python3.5/site-packages/hermes_python/ontology.py", line 186,
 in from_c_repr                                                                                       
Jan 28 21:53:12 snips snips-skill-server[2635]: INFO:snips_skill_server_lib::runner: [what-is-happening][err]     value = TimeIntervalValue.from_c_repr(c_repr_time_interval_value)      
Jan 28 21:53:12 snips snips-skill-server[2635]: INFO:snips_skill_server_lib::runner: [what-is-happening][err]   File "/var/lib/snips/skills/snips-app-what-is-happening/venv/lib/python3.5/site-packages/hermes_python/ontology.py", line 477,
 in from_c_repr                                                                                                           
Jan 28 21:53:12 snips snips-skill-server[2635]: INFO:snips_skill_server_lib::runner: [what-is-happening][err]     from_date = c_repr.from_date.encode('utf-8') if c_repr.from_date else None
Jan 28 21:53:12 snips snips-skill-server[2635]: INFO:snips_skill_server_lib::runner: [what-is-happening][err] AttributeError: 'bytes' object has no attribute 'encode'

The text for this time interval value was "in winter". It also happens with other TimeIntervalValue objects, like "from January to February", "this weekend" and so on. I'm running this on Python 3.5.3.

If I change the encode to decode in ontology.py, the error disappears and my apps work again.

git clone with authentication

I find in files:

  • platforms/hermes-python/documentation/source/installation.rst
  • platforms/hermes-python/README.rst

Instruction to clone reposititory:
git clone [email protected]:snipsco/hermes-protocol.git

It's clone authentication without it's that:
git clone https://github.com/snipsco/hermes-protocol.git

Or I have make a mistake ?

hermes-python segmentation fault with .loop_start() and later .publish_continue_session()

Hi,

I am creating an app with python code and hermes-python api.

If mqtt client creates the hermes object and subscribe and then executes .loop_start() - non blocking thread - the app is unable to finish any conversation as the .publish_continue_session() method generates a segmentation fault.
And even initiating a session programmatically with .publish_start_session_action() produces a segmentation fault too.

Exactly with the same configuration and deployment and python software but initiating with .loop_forever() works fine.

LOGS:

[13:37:08] [Hotword] detected on site safebase, for model hey_snips
[13:37:08] [Asr] was asked to stop listening on site safebase
[13:37:08] [Hotword] was asked to toggle itself 'off' on site safebase
[13:37:08] [Dialogue] session with id 'd8b5337c-9a90-426d-8154-49958be58106' was started on site safebase
[13:37:08] [AudioServer] was asked to play a wav of 41.1 kB with id '683bd537-808a-4b17-b776-64e93785dea4' on site safebase
[13:37:08] [AudioServer] finished playing wav with id '683bd537-808a-4b17-b776-64e93785dea4'
[13:37:08] [Asr] was asked to listen on site safebase
[13:37:12] [Asr] captured text "help me" in 3.0s
[13:37:12] [Asr] was asked to stop listening on site safebase
[13:37:12] [AudioServer] was asked to play a wav of 93.1 kB with id '29de05f9-d2fd-401f-ae70-74fb839325e2' on site safebase
[13:37:13] [AudioServer] finished playing wav with id '29de05f9-d2fd-401f-ae70-74fb839325e2'
[13:37:13] [Nlu] was asked to parse input "help me"
[13:37:13] [Nlu] detected intent maremoto:helpMe with confidence score 1.000 for input "help me"
[13:37:13] [Dialogue] New intent detected maremoto:helpMe with confidence 1.000

Apr 06 13:37:13 snips-base snips-skill-server[1237]: INFO:snips_skill_server_lib::runner: [app_safe][out] * Continue assistance

here the python code of the app is executing hermes.publish_continue_session(session_id, sentence, intent_filter) <<<

Apr 06 13:37:13 snips-base snips-skill-server[1237]: INFO:snips_skill_server_lib::runner: [app_safe][err] Segmentation fault
Apr 06 13:37:13 snips-base snips-skill-server[1237]: WARN:snips_skill_server_lib::handler::nosandbox: child app_safe has stopped with status exit code: 139

PLATFORM and configuration:

pi@snips-base:~ $ grep -v '#' /etc/snips.toml | grep ^.
[snips-common]
[snips-analytics]
[snips-asr]
[snips-asr-google]
[snips-audio-server]
bind = "safebase@mqtt"
[snips-dialogue]
[snips-hotword]
audio = ["safebase@mqtt", "safependant0@mqtt"]
[snips-injection]
[snips-nlu]
[snips-tts]
[snips-pegasus]

pi@snips-base:/app_home $ sam connect localhost
? Enter username for the device: pi
? Enter password for the device: [hidden]
✔ Connected to localhost
i A public key has been generated and copied to the device at localhost:
/.ssh/authorized_keys
pi@snips-base:~/app_home $ sam status

Connected to device localhost

OS version ................... Raspbian GNU/Linux 9 (stretch)
Installed assistant .......... SAFE
Language ..................... en
Hotword ...................... hey_snips
ASR engine ................... snips
Status ....................... Live

Service status:

snips-analytics .............. 0.62.3 (not running)
snips-asr .................... 0.62.3 (running)
snips-audio-server ........... 0.62.3 (running)
snips-dialogue ............... 0.62.3 (running)
snips-hotword ................ 0.62.3 (running)
snips-nlu .................... 0.62.3 (running)
snips-skill-server ........... 0.62.3 (running)
snips-tts .................... 0.62.3 (running)

pi@snips-base:/var/lib/snips/skills/snips-app-safe $ . venv/bin/activate
(venv) pi@snips-base:/var/lib/snips/skills/snips-app-safe $ pip list
Package Version


Adafruit-GPIO 1.0.3
Adafruit-PureIO 0.2.3
apa102-pi 2.2.0
enum34 1.1.6
future 0.17.1
hermes-python 0.4.1
pip 19.0.3
RPi.GPIO 0.6.5
setuptools 40.8.0
six 1.12.0
smbus2 0.2.3
spidev 3.4
typing 3.6.6
wheel 0.33.1

Add TTS register sound to hermes python

What's missing
Hermes protocol offers a route to register and play sound using the TTS.

The implementation of this feature is currently missing in hermes-python

Misc

mosquitto_pub -h my-platform.local -p 1883 -t hermes/tts/registerSound/mysound -f my_wav_file.wav
mosquitto_pub -h my-platform.local -p 1883 -t hermes/tts/say -m '{"siteId":"default", "lang":"en", "text": "Let's play a sound [[sound:mysound]]. Thanks for listening. ", "id": "someramdomid", "sessionId": "somerandomsessionid"}'

Can't install on raspberry pi

pi@raspberrypi:~ $ sudo pip install hermes-python
Collecting hermes-python
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 353, in run
wb.build(autobuilding=True)
File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 554, in _prepare_file
require_hashes
File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 568, in _get_pages
page = self._get_page(location)
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 792, in get_page
"Cache-Control": "max-age=600",
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 501, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 386, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py", line 47, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/adapters.py", line 423, in send
timeout=timeout
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 643, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 315, in increment
total -= 1
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.