To configure custom commands, you will need to edit the sentences.ini file located inside the ~/.config/voice2json folder. You can find out a lot more information from the official documentation. The demo code will only be covering a subset of the available features.

Go ahead and make sure your sentences.ini file looks like the following:

[GetTime]
what is the time
what time is it
tell me the time

[ChangeLightColor]
light_name = (left | middle | right) {lightname}
color = (red | green | blue | yellow | orange | purple | white | off) {color}

set [the] <light_name> light [to] <color>
make [the] <light_name> light <color>

[DisplayPicture]
category = ((cat | adafruit) {category})
type = (picture | image | photo)
display [(a | an)] <category> <type>
show [me] [(a | an)] <category> <type>
find [me] [(a | an)] <category> <type>

There are 3 different intents here that can be communicated in a few different ways each. For the GetTime intent, there are a few ways of wording it that will yield the same result.

For the ChangeLightColor intent, this uses a few list variables to limit the responses to a manageable set. It also uses some optional words to give more flexibility to the phrasing.

For the DisplayPicture intent, this is similar to the previous intent, except with type, it is not returning value since it doesn't matter for the demo. It just makes it easier to expand the vocabulary without lots of extra typing.

Train the Profile

Before you can run the demo, you will need to train your profile. You can do that by running the following command:

voice2json train-profile

It usually only takes about 5 seconds on a Raspberry Pi 4. You can ignore the warning about the missing word. It just means that it didn't exist in the dictionary, but it seems to have no trouble recognizing it.

This guide was first published on Jun 09, 2021. It was last updated on 2021-06-09 16:53:21 -0400.

This page (Configuring Custom Commands) was last updated on Sep 21, 2021.

Text editor powered by tinymce.