Page 1 of 1

Returns string composed by audio files

Posted: Fri May 29, 2009 4:25 am
by soso
Hi,

I would like to create a function in javascript wich returns a message wich is composed of many audio files represents the digits number.

Exemple, I've many audio files like "0.wav", "1.wav", "2.wav", ...

If the user enter "123" on the phone number, like a "phone" field, the function returns "<audio src=".../1.wav" /><audio src=".../2.wav"><audio src=".../3.wav" />"

How do I write this code?

Thanks by advance.

IVR code for audio files

Posted: Fri May 29, 2009 11:07 am
by support
Hi,

You wouldn't be able to implement this with a javascript function. However, here is an alternative IVR example of how you could implement this:

digitaudiofiles.php:

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
<var name="userentry" expr=""/>
<form id="takeinput">
<field name="userinput" type="digits">
  <prompt>
    Please enter some digits.
  </prompt>
  
  <filled>
    <assign name="userentry" expr="userinput"/>
    <goto next="#confirmdigits"/>
  </filled>
</field>
</form>

<form id="confirmdigits">
<field name="confirm" type="boolean">
<prompt>
  <foreach array="userentry.split('')" item="tmp">
    <audio expr="tmp+'.wav'"/>
  </foreach>
</prompt>

<prompt>
  If this is correct press 1, otherwise press 2.
</prompt>

<filled>
  <if cond="confirm==1">
    <prompt>
      These digits were correct.
    </prompt>
  <else/>
    <prompt>
      These digits were not correct.
    </prompt>
  </if>
</filled>
</field>
</form>
</vxml>
From this IVR example, the user first enters a string of digits such as "123". Next, when we go to our IVR tag, <foreach>, in the next field, it splits up that string of digits into an array, which allows you to play your IVR audio files in this manner:

<audio src=".../1.wav" />
<audio src=".../2.wav">
<audio src=".../3.wav" />

Hope this helps.

Regards,
Plum Support