assistant.snowboy#

class platypush.backend.assistant.snowboy.AssistantSnowboyBackend(models, audio_gain=1.0, **kwargs)[source]#

Bases: AssistantBackend

Backend for detecting custom voice hotwords through Snowboy. The purpose of this component is only to detect the hotword specified in your Snowboy voice model. If you want to trigger proper assistant conversations or custom speech recognition, you should create a hook in your configuration on HotwordDetectedEvent to trigger the conversation on whichever assistant plugin you’re using (Google, Alexa…)

Triggers:

Requires:

  • snowboy (pip install snowboy)

Manual installation for snowboy and its Python bindings if the command above fails:

$ [sudo] apt-get install libatlas-base-dev swig
$ [sudo] pip install pyaudio
$ git clone https://github.com/Kitt-AI/snowboy
$ cd snowboy/swig/Python3
$ make
$ cd ../..
$ python3 setup.py build
$ [sudo] python setup.py install

You will also need a voice model for the hotword detection. You can find some under the resources/models directory of the Snowboy repository, or train/download other models from https://snowboy.kitt.ai.

__init__(models, audio_gain=1.0, **kwargs)[source]#
Parameters:
  • models (dict) –

    Map (name -> configuration) of voice models to be used by the assistant. See https://snowboy.kitt.ai/ for training/downloading models. Sample format:

    ok_google:    # Hotword model name
        voice_model_file: /path/models/OK Google.pmdl  # Voice model file location
        sensitivity: 0.5            # Model sensitivity, between 0 and 1 (default: 0.5)
        assistant_plugin: assistant.google.pushtotalk  # When the hotword is detected trigger the Google
                                                       # push-to-talk assistant plugin (optional)
        assistant_language: en-US   # The assistant will conversate in English when this hotword is
            detected (optional)
        detect_sound: /path/to/bell.wav   # Sound file to be played when the hotword is detected (optional)
    
    ciao_google:  # Hotword model name
        voice_model_file: /path/models/Ciao Google.pmdl  # Voice model file location
        sensitivity: 0.5            # Model sensitivity, between 0 and 1 (default: 0.5)
        assistant_plugin: assistant.google.pushtotalk    # When the hotword is detected trigger the Google
                                                         # push-to-talk assistant plugin (optional)
        assistant_language: it-IT   # The assistant will conversate in Italian when this hotword is
                                    # detected (optional)
        detect_sound: /path/to/bell.wav   # Sound file to be played when the hotword is detected (optional)
    

  • audio_gain (float) – Audio gain, between 0 and 1. Default: 1

hotword_detected(hotword)[source]#

Callback called on hotword detection

on_stop()[source]#

Callback invoked when the process stops

run()[source]#

Starts the backend thread. To be implemented in the derived classes if the loop method isn’t defined.