currency grammar

Collects currency amounts using local currency units, as described in the Language Supplement.

Return keys/values

Key

Value

MEANING

Contains a string in the form main_unit_amount.subunit_amount. If the caller omits the main unit or subunit amount, then that field is zero. The string contains a leading zero if the subunit amount is collected without the main unit. See the Language Supplement for examples of what the caller might say.

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.

The default values listed in this table are true for most available languages. Any differences are noted in the Language Supplement.

Property

Description

minallowed

Minimum amount recognized in the local currency (default 0).

maxallowed

Maximum amount; default 999999999.99 (nine digits plus two decimals).

minexpected

Minimum likely amount (default 0).

maxexpected

Maximum likely amount; default 999999 (six digits).

granularityallowed

Granularity of recognized results.

granularityexpected

Granularity of likely results.

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

Setting an expected range is meant to include the most likely 90% of amounts 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.00 to 1000.00 and you want to reject all others, set an allowed range of 1 to 1000. Or, if you want to accept any amount but you expect the caller to say an amount 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. While you may want to allow someone transferring funds or paying a bill to say "250 dollars and 30 cents," you probably want to restrict someone asking for a mortgage quote to say numbers in the thousands.

As with setting a range, the currency built-in grammar supports a notion of allowed and expected granularity. 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. Similarly, setting to .01 requires people to speak the subunit (for example, an amount including cents). Setting an expected granularity tells the Recognizer to accept any amount 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.

Example

builtin:grammar/currency?language=en-US;minallowed=100;
   maxallowed=2000;granularityallowed=10

DTMF interpretation

DTMF keys are interpreted according to the VoiceXML specification. Decimal points are specified by pressing the star (*) key on the telephone keypad.

Extensions to VoiceXML specification

The implementation of the currency built-in grammar allows values to 999,999,999.99, a limit not indicated in the specification. However, to improve recognition accuracy the default setting of the grammar limits values to below one million. To recognize numbers of a million or more, you must set the maxallowed property.