Package: hss-server
Hermes Skill ServerModular intent handling server based on the Hermes MQTT protocol.FeaturesThe HSS Skill Server is built as platform for skills, and manages the MQTT connection to the voice assistant. Skills are running as separate processes in custody of the server, each with its own environment and configuration. Connection between skill server and skills is implemented using a simple RPC protocol, and therefore allows to run skills written in different programming languages. Currently, there are bindings for Python and Node.JS available (see below).The server will listen for intents on the hermes intent-topic (hermes/intent/#). When intents are processed, the responses will be published to the according hermes topics (such ashermes/dialogueManager/endSession). The skill implementation can make use of several hermes topics (e.g. to answer follow up questions, or start new sessions).When started, the server loads all available skills from the skills directory and start them as separate process. For every incoming intent which is published via MQTT, the skill-server tries to find a matching skill, and, if found, hands the intent over to the skill so it can be handled.Skills can be managed easily using thehss-clicommandline tool (see below).The HSS Skill Server is compatible with theRhasspy voice assistant.In order to ease the installation process further, a dedicated skill registry / marketplace was developed: TheHSS Skill Registry. It is running as heroku app athttps://hss-registry.herokuapp.com/. For details see theRegistrychapter below.Demo(hss) hss@ceres:/srv/hss $ hss-server
INFO:hss: Hermes Skill Server v0.5.0
INFO:hss: Using config directory: '/home/hss/.config/hss_server'
INFO:hss: Using skills directory: '/home/hss/.config/hss_server/skills'
INFO:hss_server.skillserver: Sending TTS response to 'http://calypso.universe:12101/api/text-to-speech'
INFO:hss_server.skillserver: Starting RPC server ...
INFO:hss_server.skillserver: Loading skills ...
INFO:hss_server.collection: Loaded hss-python skill 'hss-skill-s710-weather' v1.0.0
INFO:hss_server.collection: Loaded hss-python skill 'hss-s710-lightsha' v1.0.0
INFO:hss_server.collection: Loaded hss-node skill 'hss-s710-nodedemo' v0.2.3
INFO:hss_server.collection: Loaded 3 skills
INFO:hss_server.skillserver: Connecting to MQTT server ...
INFO:hss_server.mqtt: Connecting to MQTT server ...
INFO:hss_server.mqtt: Connecting to mqtt://ceres.universe:1883 ...
INFO:hss_server.mqtt: Subscribing to hermes/intent/# ...InstallationThe server is preferably installed within a virtualenv, and requires python >=3.7.Default user (venv)/home/s710 $> mkdir hss
/home/s710 $> cd hss
/home/s710/hss $> mkdir hss
/home/s710/hss $> python3.7 -m venv /home/s710/hss/venv

/home/s710/hss $> source venv/bin/activate
(venv) /home/s710/hss $> pip install hss_serverOwn user (venv)It is also advised to have it run under a dedicated user. To do so, follow those steps, for a user named "hss" to be created and used:pi@ceres:~ $ cd /srv
pi@ceres:/srv $ sudo useradd -rm hss
pi@ceres:/srv $ sudo mkdir hss
pi@ceres:/srv $ sudo chown hss:hss hss
pi@ceres:/srv $ sudo -u hss -H -s
hss@ceres:/srv $ cd hss
hss@ceres:/srv/hss $ python3 -m venv .
hss@ceres:/srv/hss $ source bin/activate
(venv) hss@ceres:/srv/hss $ python3 -m pip install pip --upgrade     # optional: update pip 
(venv) hss@ceres:/srv/hss $ pip install hss-serverConfig directoryAfter the initial start,hss-servercreates its configuration file ([USER_CONFIG_DIR]/hss_server/config.ini). The config file will contain several configuration options, especially the location where skills are installed, which by default is[USER_CONFIG_DIR]/hss_server/skills.On Linux, theUSER_CONFIG_DIRwill be~/.config, on MacOS it will be~/Library/Application Support.UpdatingJust simply usepipagain to update:pi@ceres:~ $ cd /srv/hss
pi@ceres:/srv/hss $ sudo -u hss -H -s
hss@ceres:/srv/hss $ source bin/activate
(venv) hss@ceres:/srv/hss $ pip install hss_server --upgradeConfigurationThe main configuration is stored within[USER_CONFIG_DIR]/hss_server/config.ini, and might look like the following:[server]
skill_directory = /home/hss/.config/hss_server/skills
rpc_start_port = 51000
tts_url = http://calypso.universe:12101/api/text-to-speech
node = /usr/local/bin/node
npm = /usr/local/bin/npm

[mqtt]
server = ceres.universe
port = 1883

[registry]
host = https://hss-registry.herokuapp.com/
svcroot = /services/v1/

[topics]
intents = hermes/intent/#
start_session = hermes/dialogueManager/startSession
continue_session = hermes/dialogueManager/continueSession
end_session = hermes/dialogueManager/endSessionParameters inconfig.iniAfter initial installation,hss-serverwill assume default values for the MQTT server. Topicsshouldnever be changed unless there is a good reason, since those are given by the hermes MQTT protocol.server/skill_directoryDirectory where skills are installed.server/rpc_start_portStarting port for RPC communication.Default:51000.server/tts_urlIf thetts_urlparameter is configured, replies from skills will be sent via HTTP instead of MQTT (this is for rhasspy 2.4 backwards compatibility).Default:None,server/nodePath to the Node.JS binarynode. Needed for running skills with platformhss-node.Default:None,server/npmPath to the Node.JS binarynpm. Needed for installing skills with platformhss-node.Default:None,mqtt/serverHostname of the MQTT server.Default:localhost.mqtt/portHostname of the MQTT server.Default:1883.registry/hostHostname of the HSS Skill Registry.Default:https://hss-registry.herokuapp.com/.registry/svcrootServices root path of the HSS Skill Registry.Default:/services/v1/.topcis/intentsMQTT topic on whichhss-serverlistens for intents.Default:hermes/intent/#.topcis/start_sessionMQTT topic wherehss-serverpublishes start-session messages.Default:hermes/dialogueManager/startSession.topcis/continue_sessionMQTT topic wherehss-serverpublishes continue-session messages.Default:hermes/dialogueManager/continueSession.topcis/end_sessionMQTT topic wherehss-serverpublishes end-session messages.Default:hermes/dialogueManager/endSession.Command lineIn Addition, several command line switches are available:Usage:
   $ ./hss-server [-dhv][-cl arg]

Options:

   -c [dir]           Directory path where the server's config.ini is located (default: user config dir)

   -l [file]          Log file to write log entries to (default: console)
   -d                 Enable debug log output

   --help             Show this help and exit
   -v, --version      Show version and exitCLIThehss-clitool is used to:list all installed skillsinstall a skilluninstall a skillupdate one or all installed skillsUsageUsage:
   $ hss-cli [options]

Skills:

   -l                             List all installed skills.

   -i ([name]) (--url [url])      Install a new skill using [name]. [name] must be a valid HSS registry skill name.
                                  Optionally, [url] can be used to directly install a skill from a git repository.
   -u ([name])                    Update an already installed skill named [name].
                                  If [name] is ommited, ALL skills will be updated.
   -r [name]                      Uninstall an already installed skill named [name]

Registry:

   --search                       Query HSS registry for a list of available skills
       (--type [type])            Restrict registry query to the given type
       (--platform [platform])    Restrict registry query to the given platform
       (--lang [language])        Restrict registry query to the given language

   --publish -s [dir] -t [token]        Publishes a skill to the HSS registry. Required parameters are the
                                        skill's directory [dir] (containing skill.json) and the token [token] which was obtained
                                        when registering at the HSS registry.

   --unpublish -s [name] -t [token]     Removes an already published skill from the HSS registry. Required parameters are the
                                        skill's name [name] and the token [token] which was obtained
                                        when registering at the HSS registry.

   --register                           Registers a new account at the HSS registry.
   --unregister                         Deletes an existing account from the HSS registry. Will also delete all associated skills.

Help:

   -h, --help      Show this help and exit
   -v, --version   Show version and exitFor theregistryrelated commands, see chapterRegistrybelow.InstallingWhen installing skills, the HSS Skill Registry (see chapter "Registry") is queried for details about the skill. Especially the git repo URL is determined. It is also possible to skip querying the registry and instead install directly from a git repo URL.Installing a skill involves the following steps:determine repository URL by querying HSS Skill Registrycloning the remote repositorycreating a virtualenvinstalling dependencies given by the skill developer (requirements.txt)asking the user for configuration parameters, if the skill provides theconfig.ini.defaultfile(optional) register sentences atrhasspy(if a skill provides its ownsentences.ini)(optional) register slots atrhasspy(if a skill provides its ownslots.json)(optional) triggerrhasspyfor training (if the skill provdes its own sentences/slots)The server is automatically triggered for reload after installation, so the new skill will be instantly available.Installing is done using the-iswitch forhss-clifollowed by the name of the skill as shown in the HSS Skill Registry. Optionally, instead of the skill name a direct git repo URL can be given with the--url [URL]switch.(venv) hss@ceres:/srv/hss $ hss-cli -i hss-s710-weather
Installing 'hss-s710-weather' into '/home/hss/.config/hss_server/skills/hss-s710-weather'
Cloning repository ...
Creating venv ...
Installing dependencies ...
Collecting hss_skill>=0.4.2 (from -r requirements.txt (line 1))
  Using cached https://files.pythonhosted.org/packages/
...  
Initializing config.ini ...
Section 'skill'
Enter value for parameter 'api_key': xxx
Enter value for parameter 'homecity': Frankfurt am Main
Updating sentences ...
The following intents already exist: [s710:getTemperature], [s710:getForecast], [s710:hasSun], [s710:hasRain], [s710:hasSnow]
Overwrite? (YES|no)

Sentences successfully updated
Updating slots ...
The following slots already exist: relative_time
Overwrite? (YES|no)

Slots successfully updated
Triggering traing ...
Training successful
Triggering hss-server with pid 35499 for reload

Skill 'hss-s710-weather' version 1.0.0 successfully installed.

(venv) hss@ceres:/srv/hss $UpdatingUpdating one or more skills is as easy as pulling changes from the remote GIT repository of the skill.In addition,hss-cliwill compare the existingconfig.ini(if it exists) with a newconfig.ini.default, to detect newly added configuration parameters, and then prompt the user for the parameters.Updating is done using the-uswitch forhss-clifollowed by a skill name. If no skill name is given, all skills will be updated.(venv) hss@ceres:/srv/hss $ hss-cli -u hss-s710-rmv
Updating skill 'hss-s710-rmv' ...

No update for skill 'hss-s710-rmv' available.

(venv) hss@ceres:/srv/hss $UninstallingUninstalling simply leads to the deletion of the skill's subfolder within the skill-directory. In addition, if the skill provides its own sentences, they will be removed fromrhasspy, and training is triggered.Note: Currently there is no way in therhasspyAPI to remove slots, therefore slots cannot be removed upon skill uninstall.Uninstalling is done using the-rswitch forhss-clifollowed by a skill name.(venv) hss@ceres:/srv/hss $ hss-cli -r hss-s710-weather
Uninstalling skill 'hss-s710-weather'
This will erase the directory '/home/hss/.config/hss_server/skills/hss-s710-weather'
WARNING: The operation cannot be undone. Continue? (yes|NO)
yes
Uninstalling ...
Removing sentences ...
The following intents will be deleted: [s710:getTemperature], [s710:getForecast], [s710:hasSun], [s710:hasRain], [s710:hasSnow]
Continue? (YES|no)

Sentences successfully updated
Trigger training? (YES|no)
Triggering training ...
Training successful
Triggering hss-server with pid 35499 for reload

Skill 'hss-s710-weather' successfully uninstalled.

(venv) hss@ceres:/srv/hss $BindingsPythonIn order to develop your own skill in Python, check out thehss_skillpackage atHSS - Skill.Node.JSIn order to develop your own skill with Node.JS, check out thenode-hss-skillpackage atHSS - Skill.Systemd serviceIn order to automatically start HSS at boot, and shut it down when the server is powering off, a systemd service could be created. It will also restart HSS in case of a failure.Create a service file, assuming you've installed HSS under the userhssand the location of the installation is/srv/hssas described above:pi@ceres:~ $ sudo vi /etc/systemd/system/hss.servicePut the following contents:[Unit]
Description=Hermes Skill Server
After=network-online.target

[Service]
Type=simple
User=hss
ExecStart=/srv/hss/bin/python3 /srv/hss/bin/hss-server
Restart=always
RestartSec=60

[Install]
WantedBy=multi-user.targetReload the daemon:pi@ceres:~ $ sudo systemctl daemon-reloadStart the service:pi@ceres:~ $ sudo systemctl start hss.serviceThe log will appear in/var/log/syslog:pi@ceres:~ $ tail -f /var/log/syslog
May  7 08:54:22 ceres systemd[1]: Started Hermes Skill Server.
May  7 08:54:23 ceres python3[19600]: INFO:hss: Hermes Skill Server v0.4.0
May  7 08:54:23 ceres python3[19600]: INFO:hss: Using config directory: '/home/hss/.config/hss_server'
May  7 08:54:23 ceres python3[19600]: INFO:hss: Using skills directory: '/home/hss/.config/hss_server/skills'If you need additional command line parameters, you can put them in the service file at the end of the following line:ExecStart=/srv/hss/bin/python3 /srv/hss/bin/hss-serverLike so:ExecStart=/srv/hss/bin/python3 /srv/hss/bin/hss-server -u http://calypso.universe:12101/api/text-to-speechRemember, when changing the service file, the daemon must be reloaded for the changes to take effect:Reload the daemon:pi@ceres:~ $ sudo systemctl daemon-reloadTo enable automatic startup, enable the service:Reload the daemon:pi@ceres:~ $ sudo systemctl enable hss.serviceRegistryIn order to ease the installation process further, a dedicated skill registry / marketplace was developed: TheHSS Skill Registry. It is running as heroku app athttps://hss-registry.herokuapp.com/.The website is currently pretty basic, and only servers as a quick overview. Thehss-clitool is used to interact with the registry. The following actions are available:register a new account at the registryunregister an existing accountpublish a skill to the registry (needs existing account)unpublish a skill (needs existing account)In addition, the registry can be browsed using thehss-clitool or the website.Currently, there isno interactionwith the user's e-mail at all, since the registry is in the state of a proof-of-concept. Similarly, the website is pretty simple, and no user profile administration whatsoever is available.ConceptThe registrydoes notactually host skills. Instead the idea is that it only maintains a list of meta information about each skill, especially its name, platform and git repository. As a consequence,hss-clican just query the registry to obtain the git repo URL, so the user does not need to know where a skill is hosted.Browsing skillsThe commandhss-cli --searchcan be used to search the registry. If no further parameters are given, all skills in the registry are shown. The parameters--type [type],--platform [platform]and--lang [language]can be used to filter the results.(venv) hss@ceres:/srv/hss $ hss-cli --search --lang de_DE
----------------------------------------------------------------------------------------------------------------------------------------
Name                                     Type           Platform        Author               Description
----------------------------------------------------------------------------------------------------------------------------------------
hss-s710-weather                         weather        hss-python      Patrick Jane         Queries weather from DarkSky.net

(venv) hss@ceres:/srv/hss $ hss-cli --search --lang en_GB
No skills found in registryAccount registrationUse the commandhss-cli --registerto register a new account:(venv) hss@ceres:/srv/hss $ hss-cli --register

Registering new user at HSS registry.
Username: myUser
E-Mail: me@mail.com
Password:
Password (confirm):
Creating account: myUser / me@mail.com, continue? (YES|no)


Registration successful. Your token is: XXXXXXXX

Please SAFELY store this token, as there is no way to recover it.
The token will be needed to publish/unpublish skills to the registry.

(venv) hss@ceres:/srv/hss $Account deletionUse the commandhss-cli --unregisterto delete your account. This will also delete all published skills.Publishing a skillUse the commandhss-cli --publishto publish an existing skill. As parameters the folder where the skill files are located (local filesystem) and the token which was received upon registration are required.The skill's foldermustcontain theskill.jsonfile, otherwise publishing will fail. SeeHSS - Skill (node)orHSS - Skill (python)for details on skill development.(venv) hss@ceres:/srv/hss $ hss-cli --publish -s /home/user/development/hss-skills/hss-s710-weather -t XXXXXXXX
Successfully published skill.

(venv) hss@ceres:/srv/hss $Unpublishing a skillUse the commandhss-cli --unpublishto remove a skill from the registry. As parameters the skill name as well as the token obtained during registration are required.(venv) hss@ceres:/srv/hss $ hss-cli --unpublish -s hss-s710-weather -t XXXXXXXX
Successfully unpublish skill.

(venv) hss@ceres:/srv/hss $