Page 1 of 1

using PHP to record a wav file on remote server

Posted: Wed Mar 09, 2005 3:36 pm
by kimdom
Hi everyone-

I know I saw at least one other posting that had a <record> or dynamic scripting question but it really didn't answer my question. It is pretty similar to any posting on plum related to using <record> and then being able to access the wav file and finally copy that wav file to a remote server, all using PHP and vxml. Can someone help me?

Here is the vxml file to record:

<?xml version="1.0"?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">

<var name="myrecording" expr=""/>

<form id="record_audio">
<record name="aud" beep="true" type="audio/basic" dtmfterm="true"
maxtime="60s" finalsilence="2s">
<prompt>
After the beep, please record a message.
To cancel the recording and start over, press the star key.
</prompt>
<filled>
<if cond="aud$.termchar == '*'">
<clear/>
<reprompt/>
<else/>
<assign name="myrecording" expr="aud"/>
<goto next="#review_audio"/>
</if>
</filled>
<catch event="noinput nomatch">
Sorry, I didn't hear you.
<reprompt />
</catch>
</record>
</form>

<form id="review_audio">
<property name="inputmodes" value="dtmf"/>
<property name="interdigittimeout" value="1s"/>
<field name="myfield">
<!-- <grammar type="application/x-jsgf">1</grammar> -->
<prompt>
You recorded the following message
<value expr="myrecording"/>
To submit this recording, Press 1
Or press any other key to re-record your message
</prompt>
<filled>
Thank you. Please wait while your audio file is
submitted to the recording repository.
<submit next="http://dialogix.org/upload_vxml.php" method="post" namelist="myrecording"/>
<if cond="test.success">
<prompt>
File uploaded successfully.
</prompt>
<else/>
<prompt>
File upload failed.
</prompt>
</if>
</filled>

<noinput>
<reprompt/>
</noinput>

<nomatch>
<goto next="#record_audio"/>
</nomatch>

</field>
</form>

</vxml>

Note: Having trouble with <if cond="test.success">. It doesn't work. How to make it work? Thank you.

Here is the php script:

<?php

echo "<?xml=\"1.0\"?>";

foreach ($_FILES as $file ) {
move_uploaded_file($file['tmp_name'], "/tmp/$file[name].raw");
}
?>

<vxml version="2.0">
<form id="myform">
</form>
</vxml>

Note: How can access the wav file that was generated through plum where the sound file is stored? In short, what submit or icopy tag or any other tag do I use in php to get the wav files? Thank you very much.

IVR platform throws an error.recognition.nogrammars

Posted: Mon Mar 14, 2005 12:28 pm
by support
Hi,

There are a number of things going on here.

First, you have no active IVR grammar for the "myfield" field in the form named "review_audio"; thus, the IVR platform throws an error.recognition.nogrammars. To correct this, you should add an IVR grammar to the <field> (built-in or otherwise) that accepts any dtmf input, e.g.:

<field name="myfield" type="digits?maxlength=1">
<grammar>"#"|"*"</grammar>
</field>

Next, your filled block (in this same field) needs to evaluate the value of "myfield" and proceed accordingly:

<filled>
<if cond="myfield == '1'">
<!-- caller accepted the recording -->
... do something...
<else />
... do something else...
</if>
</filled>


Lastly, IVR application call flow will never return to your original script if you use the <submit> tag to post the audio data to your server. You have two options here:

- continue your call flow (including your "success"/"failure" evaluation) within the script that accepts the POSTed audio file
- (more advanced) use the <subdialog> tag to send the audio data to your IVR server and then return control to your original script.



Regards,

Plum Support