Skip to main content

Python bindings for Snips Hermes Protocol

Project description

# Hermes Python
[![Build Status](https://travis-ci.org/snipsco/hermes-protocol.svg?branch=hermes-python-ffi)](https://travis-ci.org/snipsco/hermes-protocol)
[![PyPI version](https://badge.fury.io/py/hermes-python.svg)](https://badge.fury.io/py/hermes-python)

The `hermes-python` library provides python bindings for the Hermes protocol that snips components use to communicate together.
`hermes-python` allows you to interface seamlessly with the Snips platform and quick start development of Voice applications.

`hermes-python` abstracts away the connection to the MQTT bus and the parsing of incoming and outcoming messages from and to the components of the snips platform.

## Installation
The library is packaged as a pre-compiled platform wheel, available on [PyPi](https://pypi.org/project/hermes-python/).
It can be installed with :
```
pip install hermes-python
```

Or you can add it to your `requirements.txt` file.

### Requirements
The wheel is available for Python 2.7+ and Python 3.5

The wheel supports the following platform tags :
- `manylinux1_x86_64`
- `armv7l`, `armv6`
- `macos`

## Usage

The lifecycle of a script using `hermes-python` has the following steps :
- Initiating a connection to the MQTT broker
- Registering callback functions to handle incoming intent parsed by the snips platform
- Listening to incoming intents
- Closing the connection

Let's quickly dive into an example : Let's write an app for a Weather Assistant !
This code implies that you created a weather assistant using the [snips Console](https://console.snips.ai), and that it has a *`searchWeatherForecast`* intent.

Here is a code example for `python2.7` :

```
from hermes_python.hermes import Hermes

MQTT_ADDR = "localhost:1883" # Specify host and port for the MQTT broker

def subscribe_weather_forecast_callback(hermes, intentMessage): # Defining callback functions to handle an intent that asks for the weather.
print("Parsed intent : {}".format(intentMessage.intent.intent_name))


with Hermes(MQTT_ADDR) as h: # Initialization of a connection to the MQTT broker
h.subscribe_intent("searchWeatherForecast", subscribe_weather_forecast_callback) \ # Registering callback functions to handle the searchWeatherForecast intent
.start()

# We get out of the with block, which closes and releases the connection.

```

### Examples
#### Handling the `intent_message` object
*Coming soon.*

#### Providing TTS feedback for a voice application
*Coming soon.*

## Documentation
### Hermes protocol documentation
If you want to dive deeper into how Snips components communicate together, check out the specification of the `hermes-protocol` [here](https://docs.snips.ai/ressources/hermes-protocol).
You can also check this repository for other language bindings.

### API
*Coming soon.*

## History

### 0.1.25 (2018-12-13)
* Better error handling : Errors from wrapped C library throw a LibException with detailled errors.




Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for hermes-python, version 0.1.25
Filename, size File type Python version Upload date Hashes
Filename, size hermes_python-0.1.25-cp27-cp27m-macosx_10_13_x86_64.whl (3.6 MB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size hermes_python-0.1.25-cp27-cp27m-manylinux1_x86_64.whl (2.8 MB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size hermes_python-0.1.25-cp27-cp27mu-linux_armv6l.whl (2.7 MB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size hermes_python-0.1.25-cp27-cp27mu-linux_armv7l.whl (2.7 MB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size hermes_python-0.1.25-cp27-cp27mu-manylinux1_x86_64.whl (2.8 MB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size hermes_python-0.1.25-cp34-cp34m-manylinux1_x86_64.whl (2.8 MB) File type Wheel Python version cp34 Upload date Hashes View
Filename, size hermes_python-0.1.25-cp35-cp35m-linux_armv6l.whl (2.7 MB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size hermes_python-0.1.25-cp35-cp35m-linux_armv7l.whl (2.7 MB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size hermes_python-0.1.25-cp35-cp35m-manylinux1_x86_64.whl (2.8 MB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size hermes_python-0.1.25-cp36-cp36m-macosx_10_9_x86_64.whl (3.6 MB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size hermes_python-0.1.25-cp36-cp36m-manylinux1_x86_64.whl (2.8 MB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size hermes_python-0.1.25-cp37-cp37m-macosx_10_13_x86_64.whl (3.6 MB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size hermes_python-0.1.25-cp37-cp37m-manylinux1_x86_64.whl (2.8 MB) File type Wheel Python version cp37 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page