There are some tricks you can use to format voice commands.
For instance, say you would like to give a command that changes your television to a specific channel. You could do this by creating a voice command for every possible channel, but that's impractical. Instead, your voice command can contain ranges of words. The recognition engine will accept any one of the words. The command that will change your television to any channel would look like this:
TV channel (0|1|2|3|4|5|6|7|8|9)+
This configuration will accept any command like "tv channel 0 1", or "tv channel 1 3 6". You can substitute the actual word for the number in the command like this:
TV channel (zero|one|two) etc.
It works the same either way.
Nested parentheses "()" and brackets "[]" are not allowed. For example, the following configuration will not work: (hello|(bill|sue))
The string expression you supply can include square bracket characters ([ ]) to indicate optional words and vertical bar characters, (|) to indicate alternative strings. Alternates must be enclosed in parentheses. For example, "(hello [there] | hi)" tells the speech engine to accept "hello," "hello there," or "hi" for the command. Remember to include appropriate spaces between the text that's in brackets or parentheses and the text that's not in brackets or parentheses.
You can use the star (*) operator to specify zero or more instances of the words included in the group or the plus (+) operator to specify one or more instances. For example, the following expression results in grammar that supports "try this", "please try this", and "please please try this", with unlimited iterations of "please":
please* try this
The following grammar format excludes "try this" because the + operator defines at least one instance of "please":
please+ try this
The repetition operators follow normal rules of precedence and apply to the immediately preceding text item. For example, the following grammar results in "New York" and "New York York", but not "New York New York":
New York+
Therefore, you typically want to use these operators with the grouping characters. For example, the following grammar includes both "New York" and "New York New York":
(New York)+
Repetition operators are useful when you want to compose an expression that includes a repeated sequence such as a phone number or specification of a list of items:
call (one|two|three|four|five|six|seven|eight|nine|zero|oh)*
Id like (cheese|pepperoni|pineapple|canadian bacon|mushrooms|and)+
Although the operators can also be used with the optional square brackets grouping character, doing so may reduce the efficiency of the Speaker Client as it processes the grammar.
You can also use ellipses (…) to support word spotting. Word spotting is where you tell the speech recognition engine to ignore words spoken in this position in the phrase (sometimes called garbage words). When you use ellipses, the speech engine recognizes only specific words in the string regardless of whether they're spoken with adjacent words or phrases. For example, if you set this property to "[…] check mail […]", the speech recognition engine will match phrases like "please check mail" or "check mail please" to this command. Ellipses can be used anywhere within a string.
Be careful using this technique as voice settings with ellipses may increase the potential of unwanted matches.
When you need to recognize one or more of several possible words in a row, and you do not know how many of these words will be spoken, you may wish to enable the dictation mode of the voice recognition engine. The dictation mode is not designed for the purposes of dictating a memo, but rather for situations such as what is described above. A good example of a use for the dictation functionality is the sample shopping list script that is available from the HomeSeer Updater. Click here for more information about the dictation tag in voice recognition.
When defining the expression for your command, include at least one word that is required; that is, avoid supplying only optional words.
Make sure that the word includes only pronounceable words and letters. For numbers, it is better to spell out the word than use an ambiguous representation. For example, "345" is not a good grammar form. Similarly, instead of "IEEE", use "I triple E".
Omit any punctuation or symbols. For example, instead of "the #1 $10 pizza!” use "the number one ten dollar pizza". Including non-pronounceable characters or symbols for one command may cause the speech engine to fail to compile the grammar for all your commands.
Make your voice parameter as distinct as reasonably possible from other voice commands you define. The greater the similarity between the voice grammars for commands, the more likely the speech engine will make a recognition error. You can also use the confidence scores to better distinguish between two commands that may have similar or similar-sounding grammar.