<grammar>
Last updated
Last updated
The <grammar>
element is used to provide a speech (or DTMF) grammar that:
Specifies a set of utterances or DTMF key presses that a user may speak or type to perform an action or supply information.
Returns a corresponding semantic interpretation for a matching input.
Name | Data type | Description |
---|---|---|
Plum DEV includes support for JSGF and SRGS+XML. The default grammar format is JSGF. Grammar types are specified using the “type” attibute. For JSGF, use “application/x-jsgf” and for SRGS+XML, use “application/srgs+xml”.
The output of the above script would be:
Computer: Say or enter any number of the digits one or two. Human: (enters DTMF-5) Computer: You did not say or enter any ones or twos. Computer: Say or enter any number of the digits one or two. Human: (silently waits for prompt to timeout) Computer: You did not enter anything. Computer: Say or enter any number of the digits one or two. Human: One two one two. Computer: You entered one two one two.
<lexicon>, <meta>, <metadata>, <rule>
fetchhint
This attribute is not supported.
fetchtimeout
(defaults to “fetchtimeout” global property value) The timeout for fetches. Must be specified with the appropriate time units (e.g., “120s” for 120 seconds).
maxage
(defaults to “grammarmaxage” global property value) Tells the platform the maximum acceptable age, in seconds, of cached grammars.
maxstale
(defaults to “grammarmaxstale” global property value) Tells the platform the maximum acceptable staleness, in seconds, of expired cached grammars.
scope
Accepted values include "document" or "dialog".
“document” makes the grammar active in all dialogs of the current document (and relevant application leaf documents).
“dialog” makes the grammar active throughout the current form. If this attribute is omitted, the grammar scoping is resolved by looking at the parent element.
src
The URI specifying the location of the grammar.
Specifying the rule name within the URI is not supported. If you wish to load a particular rule from a grammar, declare that rule “public”.
See Section 3.2 for details.
srcexpr
Dynamically determine the URI to fetch by evaluating this ECMAScript expression.
type
The media type of the grammar. Supported values are “application/x-jsgf” and “application/srgs+xml”.
This attribute takes precedence over other possible sources of the media type (for instance, the “Content-type” field in an HTTP or RTSP exchange, or the file extension).
xml:base
Declares the base URI from which relative URIs are resolved.
tag-format
This attribute is not supported.
version
This attribute is not supported.
xml:lang
The language declaration provides the language identifier that indicates the primary language contained by the grammar and optionally indicates a country or other variation.
root
Declares a single rule to be the root rule of the grammar. Becomes required when specifying inline SRGS+XML grammars.
The declared rule 1) must be defined within the scope of the grammar and 2) may be scoped as either public or private.
mode
Defines the type of grammar to be loaded. Accepted values are “dtmf” or “voice”.
weight
Specifies the weight of the grammar.
maxdigits
Specifies the maximum digits allowed for your grammar.
Can be used with the property type, termmaxdigits.