Declares an input field in a form.
<field
name="string"
expr="js_expression"
cond="js_expression"
type="boolean"|"currency"|"date"|"digits"|"number"|"phone"|"time"
slot="string"
modal="true"|"false"
bevocal:urlexpr="js_expression"
>
Child Elements
</field>
Input item that prompts user for a value that matches a particular grammar.
| Attribute | Description |
name |
Name of the input variable that will hold the recognition result. The variable name may not be a JavaScript reserved keyword. The input variable has dialog (form) scope; its name must be unique among all VoiceXML and JavaScript variables within the form's scope. |
expr |
JavaScript expression that assigns the initial value of the input variable for this field. Optional (default is If you set the input variable to a value other than |
cond |
JavaScript boolean expression that also must evaluate to If not specified, the value of the input variable alone determines whether or not the field can execute. |
type |
Specifies a built-in grammar. Optional (as alternative to |
slot |
If this field is part of a mixed-initiative dialog, the name of the grammar slot that will be used to assign a value to the input variable for this field. Optional (defaults to variable name). This attribute is ignored by a field-level grammar. See the Grammar Reference for more information on grammar slots. |
modal |
Boolean value that must be Lets you alter default behavior so that only this field's grammars are active while the field executes. |
bevocal:urlexpr |
JavaScript expression that evaluates to the URI of an audio file or a local audio variable. The local audio variable can be from a Lets you perform recognition against input from the specified audio file or from a local audio variable. |
Properties of the Shadow Variable
Corresponding to the input variable name is a "shadow variable" called name$. After the input variable is filled, some additional information is available in the following properties of this shadow variable:
| Property | Description |
The recognition confidence level (with 0.0 representing the lowest confidence and 1.0 representing the highest). |
|
A string representation of the words actually spoken by the user. |
|
If the You can send the captured audio to a server using a |
|
recording |
If the You can send the captured audio to a server using a |
recordingsize |
The size of the recording in bytes, or undefined if no audio is collected. |
recordduration |
The duration of the recording in milliseconds, or undefined if no audio is collected. |
interpretation |
The interpretation returned from the recognition result, or undefined if no interpretation is available. |
For a field whose name is name, you access the property propName of the shadow variable with the syntax:
name$.propName
For example, you access the confidence property for the color field as:
color$.confidence
Some built-in field types can be parameterized to affect the built-in type's behavior. The following table shows the types that can be parameterized and indicates which input parameters must be specified.
A parameter is specified within the type attribute with syntax of the form:
typeName?parameter=value
For example the following element specifies a field of type digits that must contain exactly five digits:
<field name="mydigits" type="digits?length=5">
More than one parameter may be specified; the parameters are separated by semicolons.
Note: The interpreter throws a error.badfetch event if it retrieves a VoiceXML file that contains a field type with inconsistent parameters, such as:
<!-- ERROR: Inconsistent parameters for field type --> <field ... type="digits?minlength=5;maxlength=1">
In VoiceXML 2.0 the field's type attribute no longer defines an implicit <say-as> type to output the field's value. Instead it plays the value in normal TTS. You must now use the type attribute of <say-as> for a type-specific readout of the value.
|
|||
|
| Parents | Children |
|
|
error.semantic - Thrown if no grammars are active.
| | VoiceXML 2.0 Specification: <field> |
| | Grammar Reference |
| | Related tags: <filled>, <grammar> |
<?xml version="1.0" ?>
<!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN"
"http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
<form id="foo">
<field name="name">
<prompt> What is your favorite color? </prompt>
<grammar type="application/x-nuance-gsl">
[ red green yellow blue orange ]
</grammar>
<filled>
<prompt> Your favorite color is <value expr="name"/> </prompt>
</filled>
</field>
</form>
</vxml>
<?xml version="1.0" ?>
<!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN"
"http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
<form id="form1">
<field name="new_file" type="boolean">
<prompt>
Do you want to play the game again?
</prompt>
<filled>
<prompt>
Your answer is <value expr="new_file"/>
</prompt>
</filled>
</field>
</form>
</vxml>
<?xml version="1.0" ?>
<!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN"
"http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
<form id="form1">
<field name="today" type="date">
<prompt>
What date is today? Please say or enter month day and year.
</prompt>
<filled>
<prompt>
Your answer is
<say-as type="date"><value expr="today"/></say-as>
</prompt>
</filled>
</field>
</form>
</vxml>
<?xml version="1.0" ?>
<!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN"
"http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
<form id="form1">
<field name="card_num" type="digits">
<prompt>
Please say or enter the last four digits of your credit card.
</prompt>
<filled>
<if cond="card_num.length != 4">
<prompt>
Sorry, I didn't hear exactly four digits.
</prompt>
<clear/>
<reprompt/>
<else/>
<prompt>
The number you entered is
<say-as type="number:digits"> <value expr="card_num"/> </say-as>
</prompt>
</if>
</filled>
</field>
</form>
</vxml>
<?xml version="1.0" ?>
<!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN"
"http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
<form id="form1">
<field name="ticket_cost" type="currency">
<prompt>
Please say the cost of your ticket.
</prompt>
<filled>
<prompt>
The cost you entered is
<say-as type="currency"><value expr="ticket_cost"/></say-as>
</prompt>
</filled>
</field>
</form>
</vxml>
<?xml version="1.0" ?>
<!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN"
"http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
<form id="form1">
<field name="num_count" type="number">
<prompt>
Please say the number of computers you want to order.
</prompt>
<filled>
<prompt>The number you entered is <value expr="num_count"/></prompt>
</filled>
</field>
</form>
</vxml>
<?xml version="1.0" ?>
<!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN"
"http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
<form id="form1">
<field name="phone_num" type="phone">
<prompt>
Please say or enter your phone number.
</prompt>
<filled>
<prompt>
The phone number you entered is
<say-as type="telephone"> <value expr="phone_num"/></say-as>
</prompt>
</filled>
</field>
</form>
</vxml>
<?xml version="1.0" ?>
<!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN"
"http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
<form id="form1">
<field name="meeting_time" type="time">
<prompt>
Please say the meeting time.
</prompt>
<filled>
<prompt>
The meeting time is
<say-as type="time"> <value expr="meeting_time"/> </say-as>
</prompt>
</filled>
</field>
</form>
</vxml>
| Café Home |
Developer Agreement |
Privacy Policy |
Site Map |
Terms & Conditions Part No. 520-0001-02 | © 1999-2007, BeVocal, Inc. All rights reserved | 1.877.33.VOCAL |