Page 1 of 1

playing audio based on variable

Posted: Tue Oct 19, 2010 1:35 pm
by magicsoft
I'm trying to play an audio file based on the filename I get back from a <subdialog>:

Code: Select all

		<block>
			<assign name="varPrompt" expr="'IMPORTANT'"/>
		</block>
		<subdialog name="audiofile" namelist="varPrompt" src="audiofile.ashx"/>
		<audio expr="audiofile.varCompleteFileName">
			Hello, this is Continuing Care calling with an important message.  Please press one.
		</audio>
Apparently my syntax here is not quite correct, as it is treating "audiofile.varCompleteFileName" as a literal string, therefore not finding the file and playing the text using the synthesized voice. I've tried using single quotes, as well as using "src" instead of "expr", but neither works. Is it possible to do this?

Thanks,

Andrew

Re: playing audio based on variable

Posted: Wed Oct 20, 2010 9:39 am
by support
Hi Andrew,

To be able to pull the correct audio file, you would need to dynamically add it into the vxml. We would also recommend submitting to a new IVR script as opposed to using a subdialog.

Code: Select all

<submit next="output.php" namelist="list of necessary variables"/>
output.php:

Code: Select all

<?php
header("Content-type: text/xml");

//Do all necessary actions to determine file name here:
$name = 'need_to_choose';

echo "<?xml version=\"1.0\"?>";
?>
<vxml version="2.0">
  <form>
    <block>
      <audio src="<?= $name ?>.wav"/>
    </block>
  </form>
</vxml>
This builds an audio tag with a file source of 'need_to_choose.wav'.

Hope this helps!

Regards,
Plum Support