Plan your grammar strategy

Once you have a good idea of the structure required for your grammar, you can decide on the strategy to use to meet your requirements. Your overall strategy will depend on factors such as the extent of the vocabulary you have to cover, the length of the dialog, the computer and personnel resources at your disposal, and so on.

The different responses you anticipated can give you important clues regarding the grammars needed to recognize them. For example, consider the following:

How many donuts would you like?

One hundred and forty four.

This response is a single number: the built-in number grammar can be used.

Twelve dozen. Half chocolate, half plain.

This response expresses numbers in a complex way, with extra information. It will require an external grammar to cover.

A grammar covering the second response would be considerably more complicated than a grammar covering only the first response. You would have to balance that against other considerations, and choose a strategy accordingly.

Grammar source

Different grammar sources can be used to address different requirements:

  • Built-in grammars are most useful for simple responses with little filler.
  • Similarly, inline grammars are best used for very simple responses where no filler is expected, and the number of choices is small. The words are written directly in the VoiceXML file itself and interpreted at runtime.
  • External grammars are best when the grammar is complex, and/or must cover a great number of different words. External grammars themselves can be further divided between precompiled grammars, and grammars that are compiled at runtime. Each has its own advantages and disadvantages. See Compiling grammars.

Special grammars

There are also special types of grammars that are suited to particular tasks.

  • A constraint list filters the acceptable responses—for example, to accept only the alphanumeric strings that match a valid account number.
  • Pronunciation dictionaries to map pronunciations to text, including user dictionaries to define text-pronunciation pairings that override the system dictionary, to account for unusual words or local accents.
  • A wordlist (or directory-assistance) grammar is a fast-compiling grammar suitable for recognizing a single item from a very long list.
  • A parameter grammar defines values to be used for recognition parameters.
  • A dynamic-link grammar is generated at runtime, so it can be personalized for individual users—for example, to load information from a personal account.