digits grammar

Collects a continuously spoken string of up to 20 digits (that is, the caller is not required to pause after each digit).

Valid characters are the digits 0–9. Punctuation characters such as hyphens (-), dots (.), and underscores (_) are not recognized; if spoken they reduce recognition accuracy.

Return keys/values

Key

Value

MEANING

Contains a string of digits (ISO-8859-1 encoding), with no embedded spaces. For example, "12345".

SWI_literal

Contains the exact text that was recognized.

Properties

The more narrowly you set these properties, the higher the recognition accuracy. However, narrow settings also limit the range of possibilities that callers are allowed to speak. Your settings must balance the need for accuracy with the expectations of your callers.

Property

Description

entries

URI specifying a file that lists allowed entries, one per line (see below).

length

A list of the numbers of digits recognized. You can specify multiple lengths using %2B (the escape sequence for a plus sign) to delimit each length. For example, 6%2B9 means that lengths of 6 or 9 are valid.

minlength

The minimum number digits recognized (default 1).

maxlength

The maximum number digits recognized (default 20).

The upper limit is 50, but beware that adding to the length lowers accuracy and increases CPU usage.

By setting these variables properly for your application, you can improve recognition accuracy.

The properties are mutually exclusive. You can specify one of these:

  • The entries property
  • The length property
  • One or both of the minlength and maxlength properties

Specifying an incorrect combination of properties (for example, length and minlength) produces a runtime error.

The encoding, content, and header directives in the entries file are identical to the alphanum_lc entries property (see alphanum_lc grammar) except that the file may not contain alphanumeric characters (only digits are allowed).

Example

builtin:grammar/digits?language=en-US;minlength=7;maxlength=10
builtin:grammar/digits?language=en-US;length=6%2B9

DTMF interpretation

DTMF keys are interpreted according to the VoiceXML specification.

Extensions to VoiceXML specification

Allowing multiple lengths is an extension to the specification. The upper limit of 20 digits is an interpretation of the specification and is required for feasible accuracy and computation.