Trying to add audio content to an non-audio container. 
June 19th, 2009, 07:43 PM
|  | Newbie | | Join Date: Jun 2009 Location: I live in Nebraska
Posts: 2
| |
Does anyone know how to fix this error?
ERROR error.badfetch: Trying to add audio content <prompt> to non-audio container <form>
Below is my code: -
use CGI;
-
use Cwd;
-
use File::Basename;
-
use Time::localtime;
-
-
# ---------------------------------------------------------------------
-
# These are here for debugging, in case you need more information
-
# about exactly how the parameters were passed in.
-
-
if (defined($ENV{'REQUEST_METHOD'}))
-
{
-
$method = $ENV{'REQUEST_METHOD'};
-
}
-
-
if (defined($ENV{'CONTENT_TYPE'}))
-
{
-
$content_type = $ENV{'CONTENT_TYPE'};
-
}
-
-
if (defined($ENV{'CONTENT_LENGTH'}))
-
{
-
$content_length = $ENV{'CONTENT_LENGTH'};
-
}
-
-
-
# Go ahead and print the HTTP headers here,
-
# because we need them no matter what happens
-
print "Content-type: application/voicexml+xml\n";
-
print "\n";
-
print "<?xml version='1.0'?>\n";
-
print "<!DOCTYPE vxml PUBLIC \"-//BeVocal Inc//VoiceXML 2.0//EN\"\n";
-
print " \"http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd\">\n";
-
print "<vxml version='2.0' xmlns='http://www.w3.org/2001/vxml'>\n";
-
print " <form id='foo'>\n";
-
-
-
-
#print "Method is $method\n";
-
#exit;
-
-
# Ask the CGI module to read the request
-
my $q = new CGI;
-
-
# Find the "greeting" parameter, which has the recorded data in it
-
my $audiodata = $q->param('voiceMessage');
-
-
# Figure out what directory this script lives in.
-
# That's where we want to save the recorded file.
-
# I'm not totally sure why the fileparse_set_fstype is necessary, but it is
-
fileparse_set_fstype("MSDOS");
-
my ($scriptName, $scriptDir, $scriptSuffix) = fileparse($0, (".pl"));
-
print "<block><log>\$0 = $0</log></block>\n";
-
print "<block><log>scriptDir = $scriptDir</log></block>\n";
-
print "<block><log>scriptName = $scriptName</log></block>\n";
-
print "<block><log>scriptSuffix = $scriptSuffix</log></block>\n";
-
-
if ($method eq "POST") {
-
-
my $filename = "greeting.wav";
-
-
print "<block><log>Content-Type = $content_type</log></block>\n";
-
-
if ($content_type =~ /^multipart\/form-data;/) {
-
# For a multipart/form-data POST request, "greeting" has two meanings:
-
# In a scalar context, it is the file name sent by the VXML Interpreter
-
# In a filehandle context, it's a read-only filehandle for reading the data
-
-
open(LOCAL, ">/$scriptDir/$filename");
-
-
while (<$audiodata>) {
-
print LOCAL $_;
-
}
-
close LOCAL;
-
}
-
else {
-
# application/x-www-form-urlencoded
-
# The binary recorded data is in the "greeting" variable.
-
-
open(LOCAL, ">/$scriptDir/$filename");
-
print LOCAL $audiodata;
-
close LOCAL;
-
}
-
-
-
} else {
-
("Not a POST request.");
-
}
-
-
-
# -------------------------------------------------------------------------
-
# Now, let's return a nicely formed VXML file.
-
-
print " <prompt>Do you want to quit?</prompt>\n";
-
-
print " <help>Please say yes or no.</help>\n";
-
print " <filled>\n";
-
print " <if cond=\"hello=='yes'\">\n";
-
print " <prompt>OK. Goodbye.</prompt>\n";
-
print " <exit/>\n";
-
print " <else/>\n";
-
-
# Edit this next line, to point at the original record.vxml file.
-
print " <goto next=\"contact_post.vxml\"/>\n";
-
-
print " </if>\n";
-
print " </filled>\n";
-
print " </field>\n";
-
-
print_footer();
-
-
-
sub print_footer {
-
print "</form>\n";
-
print "</vxml>\n";
-
}
-
-
sub error($) {
-
my ($error) = @_;
-
print " <block>Error. $error</block>\n";
-
print_footer();
-
exit 0;
-
}
Last edited by eWish; July 2nd, 2009 at 09:49 PM.
Reason: Please use the code tags when posting code
| 
July 2nd, 2009, 09:51 PM
|  | Moderator | | Join Date: Jul 2007 Location: Arkansas
Posts: 901
| | | re: Trying to add audio content to an non-audio container.
Moved from insights to answers forum.
| 
July 3rd, 2009, 05:05 AM
|  | Newbie | | Join Date: Jun 2009 Location: I live in Nebraska
Posts: 2
| | | re: Trying to add audio content to an non-audio container.
eWish,
Thanks for your help. I'll use the code tags and let you know how things work out.
| 
July 3rd, 2009, 06:19 AM
|  | Expert | | Join Date: Jan 2007 Location: Southern California USA
Posts: 4,097
| | | re: Trying to add audio content to an non-audio container.
To me that error looks like it is not coming from perl. Recreate your page as a regular HTML/XML document and see if it produces the same error.
| | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,662 network members.
|