Understanding parameter grammars

A parameter grammar is an xml-formatted text file containing parameters to configure grammars and their recognition. When a parameter grammar is active, its parameters affect all active speech grammars.

When the application, or the voice browser, loads and activates a parameter grammar, Recognizer sets the parameters from the file before recognition. The parameters remain set as long as the parameter grammar remains activated, and the values can be changed only by a new message from Nuance Speech Server or by the activation of another parameter grammar that has higher precedence.

Tip: For a list of parameters allowed in a parameter grammar, see Parameters set in parameter grammar files.

Activating a parameter grammar

To activate a parameter grammar, a VoiceXML page can load it at the field, form, document, or application scope. For a single page and form the VoiceXML fragment might appear as follows:

<field name="x">
  <grammar src="http//www.company.com/swiparamgram.xml">
  <grammar src="./realgrammar.xml">
</field>

Here is the format of a parameter grammar:

<optional xml header with encoding>
<SWIparameter version="1.0" 
  id="grammar name" 
  precedence="n"
  ignore_unknown_parameters="1">
  …parameter definitions
</SWIparameter>

This table describes the format.

Grammar element

Description

<?xml>

Optional. A parameter grammar can have a header to indicate the xml version and file encoding. For example,

<?xml version='1.0' encoding='ISO-8859-1'?>

<SWIparameter>

Required. The grammar begins and ends with this tag.

id

Required. Specifies a name used to identify the grammar in the call log. The name is logged with the GRNM token in the SWIrcst event.

precedence

Required. When two or more parameter grammars are activated in parallel, Recognizer evaluates the parameters contained in the files in precedence order. In other words, if a given parameter is set in more than one parameter grammar, the precedence property determines which value is used.

The precedence, n, is an integer between 1 and 10 where lower numbers have low precedence (the grammar is evaluated first) and higher numbers have high precedence (evaluated last).

If there is more than one activated parameter grammar with the same precedence, and the same parameter appears in more than one of those files, the relative precedence is not defined (that is, you cannot predict which file will determine the value of the parameter).

ignore_unknown_parameters

Optional. Boolean. Indicates whether to generate errors when loading or activating a parameter grammar file that contains unknown or disallowed parameter. (For example, if the file contains a misspelling or a parameters that cannot be set via SWIrecRecognizerSetParameter.)

The default is 0 (unknown parameters generate an error).

..parameter definition..

Each parameter has the same format as would appear in a configuration file:

<parameter name="parameter_name">
  <value>value</value>
</parameter>

If the value is a URI, the full path must be provided. (Relative URI paths are not allowed in parameter grammars.)

Example

<SWIparameter version="1.0" 
  id="myParams1" 
  precedence="6" >  
  <parameter name="incompletetimout">
    <value>0</value>
  </parameter>
</SWIparameter>