VoiceXML Forum Community Message Board


Post New Topic  Post A Reply
my profile | register | search | faq | forum home
  next oldest topic   next newest topic
» VoiceXML Forum Community Message Board   » Newbies   » I need play many audio files in one time

 - UBBFriend: Email this page to someone!    
Author Topic: I need play many audio files in one time
Asier
Junior Member
Member # 3259

Icon 1 posted December 16, 2005 05:47 AM      Profile for Asier   Author's Homepage     Send New Private Message       Edit/Delete Post   Reply With Quote 
Hello there,

I want play a array filled with audio file,

var base = "audio/";
function many() {
var result = new Array(4);
result[0] = base + "1001.vox";
result[1] = base + "buendia.vox";
result[2] = base + "1002.vox";
result[3] = base + "1003.vox";
return ( result ) ;
}

And after play this array with de audio tag and expr attribute.

But not work, i dont know if is possible run this sample in other plattform for to work correctly, i use Envox 6.1.0.34 pllattform and here not work.

Really i need play many audio files in one time.

Thanks in Advance,
Asier

Posts: 7 | Registered: Sep 2005  |  IP: Logged
mheadd
Member
Member # 3181

Member Rated:
4
Icon 1 posted December 29, 2005 02:54 PM      Profile for mheadd   Author's Homepage   Email mheadd   Send New Private Message       Edit/Delete Post   Reply With Quote 
If you have multiple audio files that you want to play in sequence, then you can use the <foreach> element. This new element is part of the draft VoiceXML 2.1 specification.

You don't need to enclose your array in a function, just set up a standard JavaScript array with the URLs for your audio files. Use <foreach> to play each audio file in the array, see below:

code:
<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.0">

<script>
var result = new Array();
result[0] = 'audio/1.wav';
result[1] = 'audio/2.wav';
result[2] = 'audio/3.wav';
result[3] = 'audio/4.wav';
</script>

<form id="main">

<block>
<foreach item="many" array="result">
<prompt><audio expr="many"/><break/></prompt>
</foreach>
</block>

</form>
</vxml>

I tried this on the Voxeo platform and it works well.

If you want to play multiple audio files at the same time, then you may have to use some audio mixing software to create a single file, and then play that file in your VoiceXML dialog using the <audio> tag.

Hope this helps.

--------------------
Mark
VoiceinGov.org
http://www.voiceingov.org

Posts: 55 | Registered: Jun 2005  |  IP: Logged
Asier
Junior Member
Member # 3259

Icon 1 posted January 02, 2006 05:06 AM      Profile for Asier   Author's Homepage     Send New Private Message       Edit/Delete Post   Reply With Quote 
Hello mheadd,

My plattform not support VXML 2.1 specification.

If anybody know other way, please response to this ticket.

Thanks

Posts: 7 | Registered: Sep 2005  |  IP: Logged
mheadd
Member
Member # 3181

Member Rated:
4
Icon 1 posted January 02, 2006 02:30 PM      Profile for mheadd   Author's Homepage   Email mheadd   Send New Private Message       Edit/Delete Post   Reply With Quote 
It is possible to build a workaround using some more advanced JavaScript. The following should work (tested on Voxeo).
code:
  
<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.0">

<script>
<![CDATA[
var result = new Array();
result[0] = 'audio/1.wav';
result[1] = 'audio/2.wav';
result[2] = 'audio/3.wav';
result[3] = 'audio/4.wav';

var number = result.length;
var counter = -1;

function fetchAudio() {
return result[counter];
}

function keepTrack() {
counter++;
if (counter < number) {
return 'true';
} else {
return 'false';
}
}
]]>
</script>

<form id="main">

<block>
<if cond="keepTrack()=='true'">
<prompt><audio expr="fetchAudio()"/><break strength="weak"/></prompt>
<goto next="#main"/>
<else/>
<goto next="#allDone"/>
</if>
</block>

</form>

<form id="allDone">
<block><prompt>There is nothing left to do.</prompt>
<disconnect/>
</block>
</form>

</vxml>

There is probably a more elegant way of doing this, but this shows the general idea. Alternatively, you could use logic on the server side of the appliction (PHP, ASP, JSP, etc.) to render the appropriate VoiceXML markup. Here is an example using PHP:
code:
<?php 
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>

<vxml version="2.0">

<form id="main">
<block>
<prompt>

<?php
$result = array();
$result[0] = 'audio/1.wav';
$result[1] = 'audio/2.wav';
$result[2] = 'audio/3.wav';
$result[3] = 'audio/4.wav';

$number = count($result);

for($i=0; $i<$number; $i++) {

echo '<audio expr="'.$result[$i].'"/>';
echo '<break strength="weak"/>';

}

?>

</prompt>
</block>

</form>

</vxml>

Hope this helps.

[ January 02, 2006, 02:31 PM: Message edited by: mheadd ]

--------------------
Mark
VoiceinGov.org
http://www.voiceingov.org

Posts: 55 | Registered: Jun 2005  |  IP: Logged
Asier
Junior Member
Member # 3259

Icon 1 posted January 24, 2006 06:35 AM      Profile for Asier   Author's Homepage     Send New Private Message       Edit/Delete Post   Reply With Quote 
Thanks mheadd,

This were a great solution for my ex-problem, jeje.

Posts: 7 | Registered: Sep 2005  |  IP: Logged


All times are Eastern  
Post New Topic  Post A Reply Close Topic    Move Topic    Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:

Contact Us | VoiceXML Forum



Powered by Infopop Corporation
UBB.classicTM 6.3.1.2