Command Control and Dictation

Top  Previous  Next

The speech recognition module can be configured in one of the two modes:

The dictation mode: The module performs recognition on any vocabulary. To enable the dictation mode, use the SetDictation function.
The command and control mode: The module performs recognition on a list of commands (which may contain multiple words) defined by the application, and ignores any words out of this list. The commands can be specified in the following ways:
oUse the BuildGrammarFromStringList function to create the list of predefined words.
oUse the BuildGrammarFromFile function to create the command and control grammar from a Java Speech Grammar Format (JSGF) file. See Java Speech Grammar Format for details.

It is possible to create multiple grammars and activate one of them through the SetGrammar function.

The application can switch between modes during speech recognition.

Example 78 shows how to create a list of commands: "One", "Two", and "Three".

C++ Example 78: Configure the Command and Control List

// sr is a PXCSpeechRecognition instance.

pxcCHAR *cmds[3]={ L"One", L"Two", L"Three" };

 

// Build the grammar.

sr->BuildGrammarFromStringList(1, cmds, 0, 3);

 

// Set the active grammar.

sr->SetGrammar(1);

C# Example 78: Configure the Command and Control List

// sr is a PXCMSpeechRecognition instance.

String[] cmds=new String[3]{ "One", "Two", "Three" };

 

// Build the grammar.

sr.BuildGrammarFromStringList(1, cmds, null);

 

// Set the active grammar.

sr.SetGrammar(1);

Java Example 78: Configure the Command and Control List

// sr is a PXCMSpeechRecognition instance.

string[] cmds=new string[3];

cmsd[0]="One";

cmds[1]="Two";

cmds[2]="Three";

 

// Build the grammar.

sr.BuildGrammarFromStringList(1, cmds, null);

 

// Set the active grammar.

sr.SetGrammar(1);