Grammar design

Grammar design is an intrinsic part of voice application design, and many of the tasks involved in it can be performed in parallel with the main application design.

The main overall goal of any grammar is to interpret required information from the user response as quickly and accurately as possible. A quick and accurate grammar makes it easy to use the voice application, and encourages repeat calls.

A good grammar balances these goals:

  • Thorough coverage: The grammar accepts and interprets any reasonable response from users.
  • Accuracy: The grammar correctly recognizes responses so users are not asked to repeat, and grammars do not pass incorrect values to the main application.
  • Speed: The grammar quickly recognizes responses without delays that frustrate users.
  • Resource use: The grammar processes efficiently.

Grammar writing is an iterative process. You create an initial grammar based on what you expect callers to say, collect some real data, refine the grammar, gather some more data, refine the grammar again, and so on. As you refine the grammar by adding and removing phrases, it more closely approximates the way callers speak to the application.

In practice, no grammar can include all of the responses that can occur in your application, because you cannot control how people speak. When a caller says a word or phrase that cannot be parsed by the grammar, the word or phrase is said to be out-of-grammar. As a rule of thumb, a 5% out-of-grammar rate is considered acceptable. Occasionally, even 10-20% out-of-grammar rates are not uncommon for certain types of recognition tasks.

The process of developing a grammar generally involves the following steps:

  1. Identify the information items and define the slots.

    What information must the user supply to the application, and is there a particular order in which it must be supplied?

  2. Design the dialog.

    Determine the most efficient dialog flow between the user and application.

  3. Design the prompts.

    Create prompts that will elicit the desired information.

  4. Anticipate the caller responses to the prompts.

    Consider the spoken words that the grammar will have to recognize.

  5. Identify the core and filler portions of your grammars.

    Identify the key words to look for in the responses.

  6. Plan your grammar strategy.

    Determine the best way to meet the requirements for each grammar, and choose a suitable approach or combination of approaches to address them.

  7. Write and deploy the grammars.

    Encode and compile the GrXML files, dictionaries, and other files.

  8. Test the grammars.

    Identify any problems, evaluate the grammar efficiency, and gather statistics for later refinements of the grammar.

  9. Adjust and refine the grammars.

    Solve any problems and optimize the grammar performance, optionally adding natural language features as you get results to work with.

These steps are flexible, and you may decide to go back and forth between them. For example, your chosen grammar strategy may lead you to go back and redesign your prompts, or your knowledge of natural language techniques may inform your grammar strategy from the very beginning.

For the next level of process detail, see Constructing a dialog and Grammar writing checklist.