Parameter grammars

A parameter grammar is an XML-formatted text file that assigns values for Recognizer to use for various recognition parameters. Its main body consists of Recognizer parameters, and the value assigned to each.

When the application loads and activates a parameter grammar, Recognizer takes and applies the parameters from the file before recognition. The parameters remain set as long as the parameter grammar remains activated, and their values can be changed only by a parameter passed from VoiceXML, or by the activation of another parameter grammar that has higher precedence.

You can use a parameter grammar directly on a VoiceXML page. In VoiceXML, the parameter grammar may be at a field, form, document, or application level scope. For example, for a single page and form, a VoiceXML fragment might appear as follows:

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

For a detailed discussion of parameter precedence, and a list of the parameters that can be set using a parameter grammar, see Rules of parameter precedence.

A short sample parameter grammar appears below:

<?xml version='1.0' encoding='UTF-8'?>
<SWIparameter version="1.0" id="myParams1" precedence="6" >
 <parameter name="incompletetimeout">
  <value>0</value>
 </parameter>
</SWIparameter>

The header in a parameter grammar consists of an optional XML declaration, and the opening <SWIparameter> element:

<?xml version='1.0' encoding='UTF-8'?>
<SWIparameter version="1.0" id="myParams1" precedence="6" >

The XML declaration is actually optional in this case. If not specified, the grammar inherits the XML and encoding from the parent grammar.

The attributes of the <SWIparameter> element are:

Attribute

Description

version

The version number (always set to 1.0).

id

An identifier for the parameter grammar. This name is used to identify the grammar in the call log. The name is logged with the GRNM token in the SWIrcst event.

precedence

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, overriding lower precedence).

When two or more parameter grammars are activated in parallel, Recognizer assigns values to the parameters in order of precedence. That is, if a given parameter is set in more than one parameter grammar, the precedence property determines which value Recognizer will actually use.

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: you cannot predict which file will determine the value of the parameter.

ignore_unknown_parameters

This optional attribute 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.

This attribute is a boolean: assign "1" to generate unknown parameter error messages or "0" to suppress them.

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

The main body of a parameter grammar consists of parameter value assignments, which are made using the <parameter> and <value> elements:

<parameter name="incompletetimeout">
 <value>0</value>
</parameter>

The syntax is fairly straightforward. As shown, you must specify the name of the parameter in the <parameter> element’s name attribute, list the desired value in an enclosed <value> element delimiter pair, and close the <parameter>.

The file must end with a closing </SWI_parameter> delimiter.