Export (0) Print
Expand All
5 out of 6 rated this helpful - Rate this topic

Grammar Compiler (SAPI 5.3)

Speech API 5.3
Microsoft Speech API 5.3

Grammar Compiler

The SAPI grammar compiler (gc.exe) creates binary grammars from extensible markup language (XML) defined grammars.

The following topics are discussed in this section:

Introduction

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.

ms720180.Gram_Comp_2(en-us,VS.85).gif

Back to top

Using the grammar compiler

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 argumentDefinition
/OThe file name and path information associated with the compiled grammar output file. (CFG)
For example: My_CFG_Grammar.cfg
/HThe 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.xmlThe file name and path information associated with the grammar file. (XML)
For example: My_XML_Grammar.xml

ms720180.GC_CmdLine(en-us,VS.85).gif

Back to top

Specifying the grammar compiler /h option

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.

ms720180.GC_header(en-us,VS.85).gif

Back to top

Grammar compiler custom build settings

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.

Custom build settings

ms720180.dictmode_xml_settings(en-us,VS.85).gif

Back to top

Show:
© 2014 Microsoft. All rights reserved.