3.6. choice

Element typechoice
Attributesaccept (2.0) | caching (1.0) | dtmf | event | expr | fetchaudio | fetchhint | fetchtimeout | maxage (2.0) | maxstale (2.0) | next
Parentsmenu
ChildrenPCDATA | audio | break | emphasis | enumerate | grammar | mark | paragraph | phoneme | prosody | say-as | sentence | value | voice
DescriptionDeclares one of the choices in a menu. A choice element can have an associated speech grammar fragment and/or DTMF grammar fragment. It can also be used to reference an URI to go to when selected. The contents of a choice are used to form the enumerate prompt string.

Language model



DTD

<!ELEMENT choice (%audio; | grammar | %tts;)* >
<!ATTLIST choice
  %cache.attrs;
  %accept.attrs;
  dtmf           CDATA        #IMPLIED
  event          %event.name; #IMPLIED
  fetchaudio     %uri;        #IMPLIED
  %next.attrs; >

Attributes

accept : (exact | approximate)

Text of the choice element with the value exact must match the exact phrase, while with the value approximate it can match a subset of the phrase.

caching : (fast | safe)

Offers the same functionality as fetchhint.

dtmf : CDATA

The dtmf sequence for this choice.

event : event.name

Specifies an event to be thrown instead of going to a next.

expr : expression

Specifies an expression to evaluate instead of going to a next.

fetchaudio : uri

The URI of the audio to play while fetching a document.

fetchhint : (prefetch | safe)

Indicates whether the interpreter may prefetch the destination document specified by this element's next attribute. A value of prefetch indicates the resource may be retrieved at the time the containing VoiceXML document is retrieved. A value of safe indicates that the resource specified by this element should not be prefetched, but should instead be retrieved at the time that the interpreter executes this element.

fetchtimeout : duration

The interval to wait for the content to be returned before throwing an error.badfetch event. If this attribute is not specified, the interpreter derives a value from the most locally scoped fetchtimeout property.

maxage : integer

Indicates the maximum allowable age of the fetched document in seconds. If the cached copy is older than the specified maxage, a new copy will be fetched when the interpreter executes this element. If this attribute is not specified, the interpreter derives a value from the most locally scoped maxage property. If no maxstale attribute is defined and it is impossible to fetch a new copy on the content the interpreter will throw an error.badfetch instead of using stale content.

maxstale : integer

Indicates that the interpreter may use stale content for this element as long as its age is no older than maxage plus the value of maxstale in seconds. If this attribute is not specified, the interpreter derives a value from the most locally scoped maxstale property.

next : uri

The URI of the next dialog or document to visit if this choice is selected.

Children

audible and tts elements

Represent the audio rendition of this choice element to be used by enumerate, and used to specify a recognition grammar for this choice when an explicit grammar is not provided.

grammar

Describes the user response that would select this choice.

CDATA

Is used by the interpreter to both produce an audio rendition of this choice and to automatically create a grammar for this choice.

Examples

Example 3-8. A menu with four choices
<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="1.0">
  <menu>
    <prompt>
      Press 1 or say balance to check your account balance.
      Press 2 or say address change to change your billing address.
      Press 0 or say operator to speak to a customer service 
        representative.
      Press * or say quit to exit.
    </prompt>
    <choice dtmf="1" next="http://www.e-bank.com/balance.vxml">
      Balance
    </choice>
    <choice dtmf="2" next="http://www.e-bank.com/address.vxml" 
            fetchaudio="http://www.e-bank.com/filler.au">
      Address Change
    </choice>
    <choice dtmf="0" next="http://www.e-bank.com/operator.vxml">
      Operator
    </choice>
    <choice dtmf="*" event="telephone.disconnect.hangup" 
            caching="safe" fetchtimeout="5s">
      Quit
    </choice>
  </menu>
</vxml>

In Example 3-8, the corresponding choice element will become active based on the DTMF value pressed (1, 2, 0, or *). A DTMF 1, 2, or 0 will cause the interpreter to retrieve the document URL given by the next attribute. The fetchaudio attribute for choice corresponding to DTMF 2 will play the audio file while the document is being downloaded. The choice for DTMF * does not fetch another document, but instead throws an event, telephone.disconnect.hangup, that will cause the interpreter to terminate the call.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.22.9