number grammar

Collects whole numeric numbers (the caller must not speak the individual digits).

Up to two decimal places are recognized by default; this can be extended to 9 using the maxdecimal property. The caller must speak individual digits after the decimal point (natural numbers not allowed).

Return keys/values

Key

Value

MEANING

Contains a string of ISO-8859-1 digits, with no embedded spaces. For example, if the caller says "twenty five," the result is "25."

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

minallowed

Minimum number (default 0)

maxallowed

Maximum number (default 999,999,999.99).

maxdecimal

Maximum number of decimal places (default 2, maximum 9)

minexpected

Minimum likely number (default 0).

maxexpected

Maximum likely number (default 999999.99).

granularityallowed

Granularity of recognized results. This must be an integer. If set, fractional entries are not recognized. To control allowed decimal precision, use the maxdecimal property.

granularityexpected

Granularity of likely results.

Setting an allowed range tells the Recognizer to only allow numbers inside the range you specify. Numbers outside the range are not recognized as part of the vocabulary.

Setting an expected range is meant to include the most likely 90% of numbers callers may speak, and is used by the recognition engine to improve accuracy on those currencies. For example, if you only want values from 1 to 1000 and you want to reject all others, set an allowed range of 1 to 1000. Or, if you want to accept any number but you expect the caller to say an number under 100, set an expected range of 1 to 100. You can use both allowed and expected ranges at the same time. The expected range must fall within the allowed range or an error is returned.

Additionally, depending on your application, you may want to allow varying degrees of granularity in the caller’s response. Setting an allowed granularity tells the Recognizer to allow utterances that match only the allowed granularity. For example, if you set an allowed granularity of 1000 then the Recognizer returns success only if a person says a multiple of 1000. Setting an expected granularity tells the Recognizer to accept any number the caller says that matches the allowed granularity but to give higher preference to recognition hypotheses that match the expected granularity. If you use both allowed and expected granularities at once, the expected granularity must be a multiple of the allowed granularity or an error is returned.

DTMF interpretation

DTMF keys are interpreted according to the VoiceXML specification. Decimal points are specified by pressing the star (*) key on the telephone keypad. If the star key is the only key pressed, the grammar returns a zero (0).

Example

builtin:grammar/number?language=en-US;minallowed=50;
   maxallowed=600