Share via


Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

Compile Grammar Usage Scenarios

You can use CompileGrammar to convert source grammar files into binary files of the format that the Microsoft Speech Platform Runtime 11 expects. Compiling grammars prior to loading reduces the processing that the Speech Platform Runtime 11 must perform when loading a grammar, which reduces the likelihood of application latency when loading grammars, in particular large grammars.

You will typically use CompileGrammar in the following scenarios:

  • You have a large grammar that may introduce latency into your application when it is loaded.

  • Your application loads and unloads grammars frequently.

  • Your application needs to fetch grammars over the internet.

  • You want to use an ARPA-format statistical language model (SLM) grammar with a Microsoft speech recognition engine.

CompileGrammar provides answers to the following questions:

  • How can I minimize the possibility of application latency when loading grammars?

  • How can I convert grammars of multiple source formats into the format expected by the Speech Platform Runtime 11?

CompileGrammar accepts as input XML-format grammar files that conform to the Speech Recognition Grammar Specification (SRGS) Version 1.0, or files that conform to the Advanced Research Projects Agency (ARPA) format. The tool generates compiled grammar files in binary format with the “.cfg” extension (a Microsoft format). CompileGrammar reduces the size of grammar files and optimizes them for use by the Speech Platform Runtime 11.

You can use the files that the Compile Grammar tool produces as input to PrepareGrammar.exe. See Prepare Grammar Reference Manual.