<audio>

Plays a digital audio recording.

NVP supports the Microsoft RIFF (.wav), NIST Sphere (.nis or .nist), Sun audio (.au or .snd), and Raw (headerless) audio formats with the following encodings:

  • 8-bit, 8KHz, Mulaw encoding, single channel

  • 8-bit, 8KHz, A-law encoding, single channel

  • 16-bit, 8KHz, linear PCM encoding, single channel

The rate must match the rate of the current session and voice (8kHz).

The <audio> element also supports the following URLs:

  • dtmf:URL—Plays a sequence of DTMF digits, for example:

    <audio src="dtmf:1234"/>

    or

    <audio expr="'dtmf:'+digits"/>
  • pause:URL—Plays silence equal to the number of milliseconds specified in the URL, for example:

    <audio src="pause:1500"/> <!--1.5 seconds of silence-->

    or

    <audio expr="'pause:'+pauseMillis"/>

Note: Prompt playback runs as an independent process. As such, specifying a pause:URL only causes silence to be played—it does not introduce a pause in the VoiceXML document execution.

If the audio file specified in the src attribute cannot be played (for example, if the file is not found or is of a type not supported), then the content of the <audio> element is played instead. This may be PCDATA to be rendered using text-to-speech, speech markup, or other <audio> elements. For example:

<audio src="../prompts/welcome.wav">Welcome to V Phone!</audio>

Will play the pre-recorded welcome.wav prompt if this file is available. If not, the phrase “Welcome to V phone” will be rendered using text-to-speech.

If the prompt cannot be played and there is no backup text within the <audio> element, the system’s behavior is determined by the applicable setting of the ssml_validation parameter.

Attributes

This section describes the attributes you can set for the <audio> element.

Note: In the W3C SSML specification, only the src attribute is defined for <audio>. The other attributes are defined for <audio> in VoiceXML.

Name

Data type

Default
expr CDATA optional
fetchhint

(prefetch|safe)

optional
fetchtimeout CDATA optional
maxage CDATA optional
maxstale CDATA optional

src

CDATA optional

expr

The expr attribute is an ECMAScript expression that evaluates to the URI of the audio file to play. Only one of expr or src may be used in each <audio> element.

For example:

<prompt cond="entry == 'init'">
  <audio expr="PromptPath + 'GetPizzaSize_init.wav'"/>
</prompt>
<prompt cond="entry == 'reentry'">
  <audio expr="PromptPath + 'GetPizzaSize_reentry.wav'"/>
</prompt>

In addition, the expr attribute can also specify an ECMAScript value (like the guard variable for a recording) that evaluates to audio output.

For example:

<record name="greeting">
  <prompt>Please record your greeting</prompt>
</record>
<field type="boolean">
  <prompt>I heard <audio expr="greeting"/>, is this correct?</prompt>
</field>

fetchhint

Ignored.

The fetchhint attribute determines when the audio file is retrieved from the server. The settings for the fetchhint attribute are:

  • prefetch—Files or dialogs are downloaded when a page is loaded.

  • safe—Files or dialogs are downloaded only when they are actually needed.

NVP allows this attribute, but does not behave differently for prefetch mode.

fetchtimeout

The fetchtimeout attribute specifies the amount of time to wait for the audio content to be fetched before behaving as determined by the applicable setting of the ssml_validation parameter.

The value may be specified in seconds (s) or milliseconds (ms). If no unit is specified, the value is interpreted as milliseconds by default. If no value is specified, the fetchtimeout defaults to the value set an applicable <property> element, or to the value set for the browser.loading.fetchtimeout property in the Management Station if no <property> applies. If no other default applies, the platform default of 10000 milliseconds is used.

maxage

The maxage attribute specifies the maximum amount of time in seconds that a fetched resource may remain in the locale cache without requiring a server revalidation. The resource may still be used if the time specified in the maxstale attribute is greater than the maxage, but the refresh will always be triggered if the maxage has been exceeded.

The value must be an unsigned integer to specify the number of seconds, without units (“s” is not allowed). If a value for the maxage attribute is not specified, revalidation will occur after the expiration of the freshness lifetime.

maxstale

The maxstale attribute specifies the maximum amount of time in seconds that a stale file remains valid before a refetch is required. A file may still be used if it exceeds the maxage but does not exceed the maxstale value.

The value must be an unsigned integer to specify the number of seconds, without units (“s” is not allowed). If a value for the maxstale attribute is not specified, the stale document is refetched.

src

The src attribute specifies the URI for the audio file to be played. In the strict SSML implementation of <audio>, this is the only attribute defined.

Note: Only one of the src or expr attributes may be specified.

Children

This section lists the children elements for the <audio> element.

Parents

Sample code

<audio src="../prompts/greeting.wav"/>