Personal Wake Words

The personal Wake Word allows you to define your own word to wake your assistant and initiate a conversation. To do so, the algorithm needs some samples of you saying this particular word. In this tutorial, a script will guide you through the recording of those samples and in a second part, we will show you how to test your model and incorporate it in your assistant.

In order for the model to perform well, the environment where you record your samples must be as quiet as possible so you must avoid place with background noise (music, tv, people speaking ...).

1. Clone the repository

Connect to the pi by ssh:

$ ssh username@hostname

Clone the repo (install git before if needed).

$ sudo apt-get install git
$ git clone https://github.com/snipsco/snips-record-personal-hotword.git
$ cd snips-record-personal-hotword/

2. Install dependencies

Use the following command to install the repository dependencies

$ sudo apt-get install python-numpy python-pyaudio python-soundfile

3. Record the samples

Enter the following command to record your wake word samples (where you can put your own wake word name instead of your_hotword_name):

$ sudo systemctl stop snips-audio-server; python script_recording.py your_hotword_name

The prompt will then guide you through the different steps.

We insist that the environment must be as quiet as possible to ensure the quality of your model. Some checks are made in the script to ensure that your records are not too long neither to different one from another. If that happens you might see some WARNING message that will ask you to record more samples.

You might encounter some warnings (ALSA... and/or jack server...) at each step, you can ignore them.

This script also performs some postprocessing on your samples, in order to remove silence at the beginning and the end of each record. For this postprocessing to perform well, you have to be sure not to make any noise between the "recording..." and the "finished recording" messages in the prompt for each wake word (the duration between those two messages should be 2 seconds, which lets you time to pronounce your wake word).

Once you are finished, take note of the place your model has been saved in the last prompt message (this will be the path_to_your_model in the next step). You are now ready to test and adjust its sensitivity.

<path_to_your_model> example:

/home/pi/snips-record-personal-hotword/personal_2018_10_00A00_00_00

4. Test your model and adjust its sensitivity

In order to test you model first run the following commands.

$ sudo systemctl stop snips-hotword; sudo systemctl stop snips-dialogue; sudo systemctl start snips-audio-server;

Then run the following one to launch the wake word detector:

$ snips-hotword --model <path_to_your_model>=<sensitivity>

where sensitivity is a number between 0 and 1 that allows you to adjust the model sensitivity (the higher the sensitivity the higher the false alarm rate, e.g cases where it is triggered when it shouldn't) and path_to_your_model is the path to your model. By default the sensibility is set to 0.5. You can play with different values of the sensitivity to find the best value for your model (usually between 0.4 and 0.6).

5. Update your assistant configuration to run your personal model

Once you are satisfied with your model, move the model directory (containing the waves and the config.json file) to /etc/snips/ (still with your own path_to_your_model):

$ sudo mkdir -p /etc/snips/; sudo mv <path_to_your_model> /etc/snips/

Your model now has a new path which we denote new_path_to_your_model

<new_path_to_your_model> exemple: /etc/snips/personal_2018_10_00A00_00_00

Then edit the /etc/snips.toml file with sudo nano /etc/snips.toml by updating the model entry in the [snips-hotword] section with the following line:

[snips-hotword]
model = ["<new_path_to_your_model>=<sensitivity>"]

Note that the # symbol must be erased in front on the model line.

If you want to run several models simultaneously, you first have to launch the script (step 3) as many times as you want personal hotword (use a different your_hotword_name for each one) and declare them one after the other in the model entry (model = ["<new_path_to_your_model_1>=<sensitivity_1>", "<new_path_to_your_model_2>=<sensitivity_2>"]).

Important: If you want the universal Wake Word model attached to your assistant to run simultaneously, add its path to the model entry: /usr/share/snips/assistant/custom_hotword. Note that if you do not provide sensivity the model will take 0.5 by default.

Finally, restart your assistant's wake word by running:

$ sudo systemctl restart snips-hotword; sudo systemctl restart snips-dialogue

You can then check that it works by running snips-watch -vvv (if not installed, run sudo apt-get install snips-watch).

Video Tutorial

You can find a short video about this full process just right here.