Write and deploy the grammars

In its uncompiled form, a grammar is simply a text file written in the XML extensible markup language format described in the W3C Speech Recognition Grammar Specification. Nuance refers to this format as “GrXML” for convenience. See Grammar file standards.

Recognizer limits

Recognizer has a few performance limits that affect grammars and recognition. Typical grammars will never encounter these limits, but they do exist, and can occasionally cause unexpected behaviors:

  • The maximum number of simultaneous languages allowed is 20.
  • The maximum size of the n-best list is 100 entries.
  • The maximum length of a rule name is 256 characters.
  • The maximum length of a word or underscored phrase is 256 characters.

Points to remember

Grammar file structure describes in detail the structure of a GrXML grammar file. Here are some points to keep in mind:

  • The encoding and the language specified in the grammar header must be compatible with each other.
  • Any rules that you wish to reference independently (without going to the grammar file’s root rule) must be public in scope.
  • A grammar can import other grammars.
  • The core parts of the grammar can be conveniently coded in separate rules, which can then be referenced from other rules.
  • Each language offers several built-in grammars for recognition of numbers, dates, times, and other items that appear frequently in user replies. You can use these built-ins to make your own grammar development easier.
  • You can create dictionaries to help recognize words that Recognizer may otherwise not be able to parse, or to handle uncommon pronunciations.
  • There are several strategies available for handling the filler portions of a user response. See the GARBAGE rule and the repeat attribute of <item>.
  • You can use ECMAScript within a grammar to assign the key/value pairs to be returned to the voice application for each recognized item.