<audio>

Plays an audio clip to the user.

Syntax

 <audio
     src="URI"
     expr="js_expression"
     fetchhint="prefetch"|"safe"
     fetchtimeout="time_interval" 
     maxage="time_interval" 
     maxstale="time_interval" >
     bevocal:ssml="URI" >
     bevocal:ssmlexpr="js_expression"
 >
   Optional Content
 </audio>

Description

The audio clip is played in its entirety unless interrupted.

The Audio Library contains stored audio files with commonly used spoken prompts and other sounds that you can use in your applications.

If the bargein property is true, a user utterance can interrupt playing of the audio clip. If the bargeintype property is recognition, only an utterance that matches an active grammar can interrupt the audio clip. In the latter case, the bevocal.hotwordmin and bevocal.hotwordmax properties specify the minimum and maximum time duration, respectively, of the interrupting utterance.

Attribute Description
src

The URI of the audio file. Optional (as alternative to expr, bevocal:ssml, and bevocal:ssmlexpr; you must specify one of these 4 attributes).

If not specified or invalid (that is, the interpreter was unable to perform the fetch from the specified URI), any content of the <audio> element will be played instead. The content can include text or valid child tags.

expr

New in VoiceXML 2.0. JavaScript expression that evaluates to either a string or an array or strings, or can be the recorded audio from the input variable of a <record> item. If it evaluates to a string, the string is interpreted as a URI and the audio file at the location is fetched and played. Optional (as alternative to expr, bevocal:ssml, and bevocal:ssmlexpr; you must specify one of these 4 attributes).

If the expression evaluates to JavaScript undefined, then the element including its alternate content is ignored. For compatibility with previous releases the content is also ignored if the expression evaluates to null.

Extension. If it is an array, each element is treated as an audio file URI, each of which is fetched and played, in turn.

fetchhint

Specifies whether the interpreter can attempt to optimize dialog interpretation by prefetching the resource. See Prefetching Resources. Optional.

Note: The interpreter can prefetch an audio file specified by the src attribute, but not by the expr attribute.

fetchtimeout

Specifies the interval to wait for the resource to be returned before throwing a error.badfetch event. See Handling Fetching Delays. Optional.

maxage

New in VoiceXML 2.0. Specifies the maximum acceptable age, in seconds, of the cached resource. See Maximum Age. Optional.

maxstale

New in VoiceXML 2.0. Specifies the maximum acceptable time, in seconds, during which an expired cached resource can still be used. See Maximum Stale Time. Optional.

bevocal:ssml

Extension. A URI which refers to an SSML document. This SSML document should be compliant to the W3C SSML spec but may have certain extensions. See Chapter  9, Dynamic SSML for details. Optional (as alternative to src, expr, and bevocal:ssmlexpr; you must specify one of these 4 attributes).

bevocal:ssmlexpr

Extension. A JavaScript expression which resolves to the URI expected by the bevocal:ssml attribute. Optional (as alternative to src, expr, and bevocal:ssml; you must specify one of these 4 attributes).

(VoiceXML 1.0 only) The following attributes can be used in applications in which the version attribute of the <vxml> tag is set to 1.0.

Attribute Description
caching

VoiceXML 1.0 only. Specifies the caching policy for the resource being fetched. See Caching. Optional.

Used in place of the VoiceXML 2.0 attributes maxage and maxstale.

For playing prompts, the BeVocal interpreter supports popular formats including Wave (.wav), Sun audio (.au) and MP3. Because we use JMF technology, you can refer to the following reference for a complete list of audio formats supported: http://java.sun.com/products/java-media/jmf/2.1.1/formats.html.

Note: If the specified audio file is an unsupported type, any alternative audio content of the <audio> element (text, prompts, and so on) is played instead.

Tips:

 •  In production applications, you should consider using the Wave format for your audio files. The reasons for this recommendation are discussed in the Frequently Asked Questions, specifically in "How can I improve the sound quality in my audio files?" and "Echo cancellation is not working, and my prompts barge in on themselves!".

 

 •  You can use <audio> within a <prompt>. If you do, it will inherit the attributes of the <prompt> element, such as bargein.

 

 •  If you name your audio files consistently, you can use the expr attribute to simplify the way you construct audio file names in your VoiceXML. For example:
      <prompt>
         <audio expr="'resources/prompts/hello' + sign +'.wav'"/>
      </prompt>
      <prompt>
         <audio expr="'resources/prompts/' + sign +'.wav'"/>
      </prompt>

 

 •  If you use the expr attribute in place of the src attribute, the interpreter cannot prefetch the audio file, which may cause a minor performance degradation. Once a given file is in the interpreter's cache, however, this difference is typically not noticeable.

 

 •  Using JavaScript functions makes it easy to update the location of your audio files. For an expanded example, see Factorial on the VoiceXML Samples page of the BeVocal Café; as a simple example:
      function female1(a) { return("audio/female1/en_us/" + a); }
      function common(b) { return(female1("common/" + b + ".wav")); }
      function number(b) { return(female1("number/" + b + ".wav")); }

 

 •  When calling JavaScript functions, use apostrophes in place of double quotes:
      <audio expr="common('bevocal_chimes')"/>

 

 •  If a JavaScript expression contains any of the characters "<", ">", or "&", that character must be replaced with the corresponding escape sequence "&lt;", "&gt;", or "&amp;". For more information, see JavaScript Quick Reference.

Usage

Parents Children
<audio>
<bevocal:foreach>
<bevocal:listen>
<bevocal:register>
<bevocal:verify>
<bevocal:whisper>
<block>
<catch>
<choice>
<emphasis>
<enumerate>
<error>
<field>
<filled>
<help>
<if>
<initial>
<menu>
<noinput>
<nomatch>
<prompt>
<prosody>
<record>
<s>
<sentence>
<subdialog>
<transfer>
<voice>
<audio>
<break>
<emphasis>
<enumerate>
<mark>
<p>
<paragraph>
<phoneme>
<prosody>
<s>
<say-as>
<sentence>
<value>
<voice>

See Also

 •  VoiceXML 2.0 Specification: <audio>

Examples

Example 1--using src:

 <?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">
      <block>
       <prompt>
         Welcome to BeVocal Cafe, the number One place to
          build and deploy your voice applications.
       </prompt>       
       <audio maxage="0" 
src="http://cafe.bevocal.com/libraries/audio/female1/en_us/common/bevocal_cafe
.wav"/>
      </block>
    </form>
  </vxml>
 
 

Example 2--using expr:

 <?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">
   <!-- Define functions; one returns a string;
        many returns an array of strings -->
 
   <script>
     <![CDATA[
       var base = 
"http://cafe.bevocal.com/libraries/audio/female1/en_us/number/";
       function one() {
         return base + "6000-e.wav";
       }
 
       function many() {
         var result = new Array(4);
         result[0] = base + "6000-b.wav";
         result[1] = base + "300.wav";
         result[2] = base + "37_and.wav";
         result[3] = base + "1-32.wav";
         return result;
       }
     ]]>
 
   </script>
 
   <form>
     <block>
       <prompt>
         Playing result of one
         <audio expr="one()">one</audio>
         <break/>
         Playing result of many
         <audio expr="many()">many</audio>
       </prompt>
     </block>
   </form>
 </vxml>

[Show Frames]   [FIRST] [PREVIOUS] [NEXT]
BeVocal, Inc. Café Home | Developer Agreement | Privacy Policy | Site Map | Terms & Conditions
Part No. 520-0001-02 | © 1999-2005, BeVocal, Inc. All rights reserved | 1.877.33.VOCAL