Some
Questions on VoiceXML 2.0
In
this monthly column, an industry expert will answer
common questions about VoiceXML and related technologies.
Readers are encouraged to submit questions about VoiceXML,
including development, voice-user interface design,
and speech technology in general, or how VoiceXML is
being used commercially in the marketplace. If you have
a question about VoiceXML, e-mail it to speak.and.listen@voicexmlreview.org
and be sure to read future issues of VoiceXML Review
for the answer.
Q. I have
numerous references to recorded audio on a different host than my
VoiceXML content. I'm reluctant to hard-code the path to the audio
server throughout my VoiceXML documents since the host may change.
Does VoiceXML provide me with any alternatives?
A:
Your best bet is to use the expr attribute on your audio tags and
reference a variable declared at application scope. You initialize
the variable to the base URI of the audio and use the JavaScript
concatenation operator (+) to combine the variable with a static
string that specifies the path to the specific audio file. If you
move your audio to a different host, you need only
update the application-scoped variable.
In the following
example, the first document represents the application root.
This document declares a variable, baseAudioPath, that specifies
the base URI to your recorded audio. The second document references
the application root document and contains a block of audio
elements that reference the application-scoped variable.
<!-- acme_root.vxml --> <vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
<var name="baseAudioPath" expr="'http://audio.acmeairlines.org/'"/>
</vxml>
<!-- index.vxml -->
<vxml version="2.0"
xmlns="http://www.w3.org/2001/vxml"
application="acme_root.vxml">
<form id="welcome">
<block>
<audio expr="baseAudioPath + 'welcome.wav'">welcome
to ack me airlines</audio>
<audio expr="baseAudioPath + 'ads/ad3.wav'"/>
<goto next="#mainmenu"/>
</block>
</form>
<form id="#mainmenu">
<!-- app main menu goes here -->
</form>
</vxml>
|
Q. I read about
the xml:base attribute in Section 1.5.1 of the VoiceXML 2.0
specification (
http://www.w3.org/TR/voicexml20/#dml1.5.1).
Can't I just use the xml:base attribute to specify the base URI
to my recorded audio?
A. You could use
xml:base to specify the URI to your recorded audio, but there
are significant caveats you should be aware of.
According to the
specification, the xml:base attribute "defines the base URI for
all relative URI references throughout the document." That
means that, in addition to audio elements, your script, grammar,
subdialog, choice, link, goto, object, and submit elements are
candidates for xml:base resolution too if they specify relative URIs.
Of course, fetchaudio and application attributes that specify
relative URIs will also be resolved using the xml:base URI.
Here's a simple example:
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml" xml:base="http://audio.acmeairlines.org/" application="root.vxml">
<script>
// return a random ad index
function GetAdIndex(max)
{
return Math.floor(Math.random()*max) +1;
}
</script>
<form id="welcome">
<block>
<audio src="welcome.wav"/>welcome
to ack me airlines</audio>
<audio expr="'ads/ad' + GetAdIndex(5)
+ '.wav'"/>
<goto next="mainmenu.vxml"/>
</block>
</form>
</vxml>
|
Let's say the
document is hosted at
"http://reservations.acmeairlines.org/index.vxml". When
the interpreter parses and executes the document, it observes the
xml:base attribute and resolves the application attribute of the
vxml element to "http://audio.acmeairlines.org/root.vxml".
If the application root document happens to be located on the audio
Web server (unlikely), the interpreter continues to execute the
document and resolves the relative URI of the first audio file to
"http://audio.acmeairlines.org/welcome.wav". The second
audio element gets resolved to something like
"http://audio.acmeairlines.org/ads/ad7.vxml". The actual
URI will depend on what number the user-defined JavaScript function
GetAdIndex() returns. Finally, the interpreter attempts to navigates
to "http://audio.acmeairlines.org/mainmenu.vxml", once
again resolving the relative URI associated with the next attribute
using the xml:base attribute.
In conclusion, if your audio is hosted on a different server than
your application, you're better off defining a variable with that
base URI at application scope and referencing it via the expr
attribute of your audio elements.

back
to the top

Copyright
© 2001-2002 VoiceXML Forum. All rights reserved.
The VoiceXML Forum is a program of the
IEEE
Industry Standards and Technology Organization (IEEE-ISTO).
|