Compiling Grammars
Create grammar files in either plain text or compiled binary formats. A compiled grammar downloads faster than a plain text grammar file from the Web server, and loads faster into the client computer.
The Microsoft Speech Application SDK Version 1.1 (SASDK) creates grammar files in plain text, with a .grxml extension. Compile a .grxml grammar file into binary format using the command-line grammar compiler, SrGSGc.exe, that is installed with the SASDK. If the SASDK is installed in the default location, SrGSGc.exe can be found at:
%SystemDrive%\Program Files\Microsoft Speech Application SDK 1.1\SDKTools\Bin.
Syntax
SrGSGc [/O [drive:][path]CFG_OutputFile.cfg] [drive:][path]GRXML_InputFile.grxml
Parameter | Definition |
---|---|
CFG_OutputFile.cfg | Optional. Specifies the drive, path, and file name of the compiled .cfg output file.
|
GRXML_InputFile.grxml | Required. Specifies the drive, path, and file name of the .grxml file to compile. The compiler appends the .grxml extension to GRXML_InputFile.grxml by default. |
To create a compiled grammar file
- On the taskbar, click Start, point to All Programs, point to Microsoft Speech Application SDK Version 1.1, point to Debugging Tools, and then on the shortcut menu, click Microsoft Speech Application SDK Command Prompt.
- Enter the appropriate SrGSGc.exe syntax, and then press ENTER.
After compiling a file, change references to the file so that the application uses the compiled (.cfg) version rather than the plain text (.grxml) version.
Remarks
A speech application created using the SASDK can use either the plain text or compiled binary format of a grammar file. However, a grammar file is typically compiled only during application deployment, and when development of the grammar file is essentially complete.
The SASDK provides little support for compiled grammar files. For example, Speech Grammar Editor will not load a .cfg file. However, a RuleRef element can point to a rule in a .cfg file.
A grammar compiler that compiles Speech API (SAPI) grammar files is available for download from the Speech Technologies Web site at https://www.microsoft.com/speech/download/. The SASDK does not support the SAPI compiler.
Examples
The following example creates the compiled binary file samplegrammar.cfg from the XML text file samplegrammar.grxml.
srgsgc samplegrammar
The following example creates the compiled binary file newgrammar.cfg from the XML text file samplegrammar.grxml.
srgsgc /o newgrammar.cfg samplegrammar
See Also
Enabling Speech Recognition | Creating Grammars | Grammar Design