developer account - cannot save wav file?
Posted: Thu Oct 05, 2006 4:42 pm
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
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