Page 1 of 1

developer account - cannot save wav file?

Posted: Thu Oct 05, 2006 4:42 pm
by bluematrix
This is probably not the best place to post this question but on the offhand that I am doing something stupid with my vxml I'll ask here first...

I am recording a message - I output the message back with <audio> no problem, but when it comes to saving the audio I run into trouble. The parameter used to store the message, instead of holding the wav binary, stores the name of the variable i.e. "msg" or "message" depending what I name the variable.

Is this because I have a developer account? What's going on?
I swear I am not doing anything stupid on the server side

my $message = $cgi->param('msg') || '';
if ($message){

my $rnd = rand(1)*10000000000;
$rnd = substr($rnd,0,5);

my $file = '/nas/web/clients/audio/files/voice'.$rnd.'.wav';
my $temp_file = '/tmp/temp'.$rnd.'.wav';
my $mp3 = '/nas/web/clients/audio/files/voice'.$rnd.'.mp3';



my $bytes_read=0;
my $buff='';open(WFD,">$file");
binmode WFD;
print WFD $message;
close(WFD);

### find the length of the wav file
#my $wav = new Audio::Wav;
#my $read = $wav -> read($file);
#my $size = $read -> length_seconds();

system("/usr/bin/sox -t ul -r 8012 $file -s -w $temp_file >/dev/null");
system("/usr/local/bin/lame $temp_file $mp3 >/dev/null");
system("rm $temp_file");

$mode = 'confirm';
$msg_id = $rnd;
}

Here is my dynamic vxml through perl

Code:

<?xml version="1.0" ?>

<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml" xml:lang="en-US">
<meta name="maintainer" content="" />
<property name="universals" value="all" />
<var name="callerid" expr="session.telephone.ani"/>

<form id="rec">
<property name="sensitivity" value="0.85" />
<record name="msg" beep="true" maxtime="1800s" finalsilence="10000ms" dtmfterm="true" type="audio/basic">
<prompt bargein="false">
Please re-cord your message. Begin at the beep and press pound when complete.
<break time="2500ms"/>
</prompt>
<noinput> I didn't hear anything, please try again. </noinput>
<nomatch>I didn't get that. <reprompt /> </nomatch>
<error>An error occured. <reprompt/> </error>
</record>
<field name="confirm" type="digits">
<property name="inputmodes" value="dtmf" />
<prompt>
Thank you!
Press 1, to save the recording.
Press 2, to replay the recording.
Press 3, to discard the recording and start over.
Press 4, to go back.
Press 0, to return to the main menu.
</prompt>
<filled>
<if cond="confirm==0">
<clear />
<goto next="http://audio.bluematrix.com/bluematrix/ ... de=topMenu"/>
<elseif cond="confirm==4" />
<clear/>
<goto next="http://audio.bluematrix.com/bluematrix/ ... =skipInput" />
<elseif cond="confirm==1"/>
<prompt bargein="false">please wait for the confirmation code.</prompt>
<submit next="http://audio.bluematrix.com/bluematrix/ ... ice_msg.pl" method="post" enctype="multi
part/form-data" />
<elseif cond="confirm==2"/>
<prompt bargein="false">
<audio expr="msg"/>
</prompt>
<clear namelist="confirm"/>
<reprompt/>
<elseif cond="confirm==3"/>
<goto next="http://audio.bluematrix.com/bluematrix/ ... ode=record"/>
<else/>
<prompt bargein="false">Unknown command or interruption. Your message is being saved.</prompt>
<submit next="http://audio.bluematrix.com/bluematrix/ ... ice_msg.pl" method="post"/>
</if>
</filled>
</field>
<help>I'm sorry. There's no help available here. <reprompt /></help>
<noinput>I'm sorry. I didn't get anything. <reprompt /> </noinput>
<nomatch>I didn't get that. <reprompt /> </nomatch>
<error>An error occured. <reprompt/> </error>
</form>
</vxml>



Thanks for any help

IVR platform is not a perl shop

Posted: Fri Oct 06, 2006 12:53 am
by support
Hello,

IVR platform is not a perl shop here so we can't lend much advice on the best practices for handling file uploads. However, it is worth mentioning that a file upload variable is rarely handled in the same way as a normal form item. There is a useful perl file upload tutorial here:
File uploads from our voice browser are identical to those created by any other web browser. You should be able to follow the server side script part of this IVR example to accept the audio recording.

Regards,
Plum Support

Posted: Fri Oct 06, 2006 11:01 am
by bluematrix
Thanks,

I know the perl works because the same code and vxml works on a different vxml hosting...

I was just wondering if there is any limitiations on the developer account such that it will not actually post the file.

Thanks anyway

Explicitly provide namelist attribute to submit tag in IVR

Posted: Fri Oct 06, 2006 1:22 pm
by support
Hello,

The only change that we could suggest to your IVR code is explicitly providing the namelist attibute to the <submit> tag. That will at least remove any ambiguity about what variables will and will not be sent.

Regards,
Plum Support

Posted: Fri Oct 06, 2006 1:31 pm
by bluematrix
Thanks,

I already tried that too :)

Hopefully, its something stupid I will stumble over.