The VoiceXML browser supports the complete set of built-in field types that are defined in VoiceXML 2.1. These built-in field types specify the built-in grammar to load (which determines valid spoken and DTMF input) and how the TTS engine will pronounce the value in a prompt, are documented here.
Because these grammars provide support for many possible input values, developers may wish to write custom versions to constrain user input and to increase accuracy. Additional examples of the types of input you might specify when using the built-in field types are shown in Table 1. For information about writing your own application-specific grammars, see Grammars.
Table 1 shows the implementation details for US English only. Refer to the appropriate appendix for implementation details in another language.
Type | Implementation details |
---|---|
boolean | Users can say positive responses such as yes, okay, sure,
and true, or negative responses such as no, false,
and negative. Users can also provide DTMF input: 1 is
yes, and 2 is no. The return value sent is a boolean true or false. If the field name is subsequently used in a value element within a prompt, the TTS engine will speak either yes or no. |
currency | Users can say US currency values in dollars and
cents from 0 to $999,999,999.99 including common constructs such as
“a buck fifty” or “nine ninety nine.” Users can also provide DTMF input using the numbers 0 through 9 and optionally the * key (to indicate a decimal point), and must terminate DTMF entry using the # key. The return value sent is a string in the format UUUddddddddd.cc, where UUU is a currency indicator or null. The only supported currency type is USD for U.S. dollars. If the field name is subsequently used in a value attribute within a prompt, then the TTS engine will speak the currency value. The currency is expressed as a floating point number, followed by the currency type (such as U.S. dollars). For example, the TTS engine speaks “a buck fifty” as one point five zero U.S. dollars and “nine ninety nine” as nine point nine nine. |
date | Users can say a date using months, days, and years,
as well as the words yesterday, today, and tomorrow.
Common constructs such as “March 3rd, 2000” or “the third of March
2000” are supported. Users can also provide DTMF input in the form yyyymmdd. Note: The date grammar does not perform
leap year calculations. February 29 is accepted as a valid
date regardless of the year. If desired, your application or servlet
can perform the required calculations.
The return value sent is a string in the format yyyymmdd, with the VoiceXML browser returning a ? in any positions omitted in the spoken input. If the value is subsequently spoken in <say-as> with the interpret-as value vxml:date, then it is spoken as a date appropriate to the current language. |
digits | Users can say numeric integer values as individual
digits (0 through 9). For example, a user could say 124356 as “one
two four three five six.” Users can also provide DTMF input using the numbers 0 through 9, and must terminate DTMF entry using the # key. The return value sent is a string of one or more digits. If the result is subsequently used in <say-as> with the interpret-as value vxml:digits, it will be spoken as a sequence of digits appropriate to the current language. In the above example, the TTS engine speaks 124356 as one two four three five six. Note: Use this type instead of the
number type if you require very high recognition accuracy for your
numeric input.
|
number | Users can say natural numbers (that is, positive
and negative integers, 0, and decimals) from –999,999,999 to 999,999,999 as
well as the words point or dot (to indicate a decimal
point) and minus or negative (to indicate a negative
number). Numbers can be spoken individually or in groups. For example,
a user could say 123456 as “one hundred twenty-three thousand four
hundred and fifty-six” or as “one twenty-three four fifty-six.” Users can also provide DTMF input using the numbers 0 through 9 and optionally the * key (to indicate a decimal point), and must terminate DTMF entry using the # key. Only positive numbers can be entered using DTMF. The return value sent is a string of one or more digits, 0 through 9, with a decimal point and a + or - sign as applicable. If the field is subsequently spoken in <say-as> with the interpret-as value vxml:number, then it is spoken as a number appropriate to the current language. In the above example, the TTS engine speaks 123456 as one hundred twenty-three thousand four hundred fifty-six. Note: Use this
type to provide flexibility when collecting numbers; users can speak
long numbers as natural numbers, single digits, or groups of digits.
If you want to force the TTS engine to speak the number back in a
particular way, use <say-as interpret-as=“vxml:type”> where type is
the built-in type you want to specify. For example, use <say-as
interpret-as=“vxml:digit”> to speak the number back as a string
of digits.
|
phone | Users can say a telephone number, including the
optional word extension. Users can also provide DTMF input using the numbers 0 through 9 and optionally the * key (to represent the word “extension”), and must terminate DTMF entry using the # key. The return value sent is a string of digits without hyphens, and includes an x if an extension was specified. If the field is subsequently spoken in <say-as> with the interpret-as value vxml:phone, then it is spoken as a phone number appropriate to the current language. Note: For
tips on minimizing recognition errors that are due to user pauses
during input, see Using the built-in phone grammar.
|
time | Users can say a time of day using hours and minutes
in either 12- or 24-hour format, as well as the word now.
Users can also provide DTMF input using the numbers 0 through 9. The return value sent is a string in the format hhmmx, where x is a for AM, p for PM, h for 24-hour format, or ? if unspecified or ambiguous; for DTMF input, the return value will always be h or ?, since there is no mechanism for specifying AM or PM. If the field is subsequently spoken in <say-as> with the interpret-as value vxml:time, then it is spoken as a time appropriate to the current language. |