Grammar Compiler (SAPI 5.3)
The SAPI grammar compiler (gc.exe) creates binary grammars from extensible markup language (XML) defined grammars.
The following topics are discussed in this section:
The SAPI grammar compiler is divided into two parts, the front-end section and the back-end section. The front end parses the grammars described in XML and optimizes the XML text formatted grammar if requested by the application. For example, the front end can remove the left recursion. The front end then calls the back-end compiler to convert the internal representation into the SAPI binary format.
The SAPI 5 grammar compiler (gc.exe) can be used from the command line, or added to the Microsoft Visual C++ custom build environment.
Using GC from the command line
When compiling XML grammars from the command line, the following options are available:
|Command line argument||Definition|
|/O||The file name and path information associated with the compiled grammar output file. (CFG)|
For example: My_CFG_Grammar.cfg
|/H||The file name and path information associated with the header file that receives the # define information. |
For example: My_Header.h
See specifying the grammar compiler /h option for more information.
|file_name.xml||The file name and path information associated with the grammar file. (XML)|
For example: My_XML_Grammar.xml
The SAPI grammar compiler can add the XML ID tag NAME and VAL contents to a specified header file. By choosing the /h compile option, the contents of the XML ID tags are added to the specified header file in the standard C-style #define format.
The following illustration shows the result of the /h command line argument while compiling the dictmode.xml file.
Notice the contents of the XML ID tags NAME and VAL are added to the dictmode.h file as c-style #define statements.
The SAPI 5 grammar compiler (gc.exe) can be added to the Microsoft Visual C++ custom build environment. The XML grammar compile settings can be pre-configured in the project custom build settings. Each time the XML grammar is compiled, the grammar compiler uses the settings that are specified in the custom build settings.
The Speech SDK 5.3 sample application Dictation Pad illustrates the use of the grammar compiler in the project custom build settings. Compile the dictpad.dsp project and review the Dictation Pad sample application project settings to learn more about how the grammar compiler can be added to the Microsoft Visual C++ custom build environment.
The Dictation Pad SDK sample application can be found in the following location: C:\Program Files\Microsoft Speech SDK5.0\Samples\CPP\DictPad\dictpad.dsp.