473,395 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Trying to add audio content to an non-audio container.

li0pxh0
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:
Expand|Select|Wrap|Line Numbers
  1. use CGI;
  2. use Cwd;
  3. use File::Basename;
  4. use Time::localtime;
  5.  
  6. # ---------------------------------------------------------------------
  7. # These are here for debugging, in case you need more information
  8. # about exactly how the parameters were passed in.
  9.  
  10. if (defined($ENV{'REQUEST_METHOD'}))
  11. {
  12.     $method = $ENV{'REQUEST_METHOD'};
  13. }
  14.  
  15. if (defined($ENV{'CONTENT_TYPE'}))
  16. {
  17.     $content_type = $ENV{'CONTENT_TYPE'};
  18. }
  19.  
  20. if (defined($ENV{'CONTENT_LENGTH'}))
  21. {
  22.     $content_length = $ENV{'CONTENT_LENGTH'};
  23. }
  24.  
  25.  
  26. # Go ahead and print the HTTP headers here,
  27. # because we need them no matter what happens
  28. print "Content-type: application/voicexml+xml\n";
  29. print "\n";
  30. print "<?xml version='1.0'?>\n";
  31. print "<!DOCTYPE vxml PUBLIC \"-//BeVocal Inc//VoiceXML 2.0//EN\"\n";
  32. print "                      \"http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd\">\n";
  33. print "<vxml version='2.0' xmlns='http://www.w3.org/2001/vxml'>\n";
  34. print "  <form id='foo'>\n";
  35.  
  36.  
  37.  
  38. #print "Method is $method\n";
  39. #exit;
  40.  
  41. # Ask the CGI module to read the request
  42. my $q = new CGI;
  43.  
  44. # Find the "greeting" parameter, which has the recorded data in it
  45. my $audiodata = $q->param('voiceMessage');
  46.  
  47. # Figure out what directory this script lives in.
  48. # That's where we want to save the recorded file.
  49. # I'm not totally sure why the fileparse_set_fstype is necessary, but it is
  50. fileparse_set_fstype("MSDOS");
  51. my ($scriptName, $scriptDir, $scriptSuffix) = fileparse($0, (".pl"));
  52. print "<block><log>\$0 = $0</log></block>\n";
  53. print "<block><log>scriptDir = $scriptDir</log></block>\n";
  54. print "<block><log>scriptName = $scriptName</log></block>\n";
  55. print "<block><log>scriptSuffix = $scriptSuffix</log></block>\n";
  56.  
  57. if ($method eq "POST") {
  58.  
  59.     my $filename = "greeting.wav";
  60.  
  61.     print "<block><log>Content-Type = $content_type</log></block>\n";
  62.  
  63.     if ($content_type =~ /^multipart\/form-data;/) {
  64.         # For a multipart/form-data POST request, "greeting" has two meanings:
  65.         #  In a scalar context, it is the file name sent by the VXML Interpreter
  66.         #  In a filehandle context, it's a read-only filehandle for reading the data
  67.  
  68.         open(LOCAL, ">/$scriptDir/$filename"); 
  69.  
  70.         while (<$audiodata>) {
  71.             print LOCAL $_;
  72.         }
  73.         close LOCAL;
  74.     }
  75.     else {
  76.         # application/x-www-form-urlencoded
  77.         # The binary recorded data is in the "greeting" variable.
  78.  
  79.         open(LOCAL, ">/$scriptDir/$filename");
  80.         print LOCAL $audiodata;
  81.         close LOCAL;
  82.     }
  83.  
  84.  
  85. } else {
  86.      ("Not a POST request.");
  87. }
  88.  
  89.  
  90. # -------------------------------------------------------------------------
  91. # Now, let's return a nicely formed VXML file.
  92.  
  93. print "  <prompt>Do you want to quit?</prompt>\n";
  94.  
  95. print "  <help>Please say yes or no.</help>\n";
  96. print "  <filled>\n";
  97. print "    <if cond=\"hello=='yes'\">\n";
  98. print "      <prompt>OK. Goodbye.</prompt>\n";
  99. print "      <exit/>\n";
  100. print "    <else/>\n";
  101.  
  102. # Edit this next line, to point at the original record.vxml file.
  103. print "      <goto next=\"contact_post.vxml\"/>\n";
  104.  
  105. print "    </if>\n";
  106. print "  </filled>\n";
  107. print "  </field>\n";
  108.  
  109. print_footer();
  110.  
  111.  
  112. sub print_footer {
  113.     print "</form>\n";
  114.     print "</vxml>\n";
  115. }
  116.  
  117. sub error($) {
  118.     my ($error) = @_;
  119.     print "    <block>Error.  $error</block>\n";
  120.     print_footer();
  121.     exit 0;
  122. }
Jun 19 '09 #1
3 1900
eWish
971 Expert 512MB
Moved from insights to answers forum.
Jul 2 '09 #2
eWish,
Thanks for your help. I'll use the code tags and let you know how things work out.
Jul 3 '09 #3
KevinADC
4,059 Expert 2GB
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.
Jul 3 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: apchar | last post by:
I am trying to use php as a kind of servlet to act as a middle man between a java applet and mysql. I know java has jdbc but it's flakey and painful. php access to mysql is much nicer. So I have:...
14
by: mirnazim | last post by:
Hi, There are great Python Web Application Framework. But most of them are meant for content oriented web apps. Is there something that can ease the development of application that are not...
7
by: Matt Kruse | last post by:
This is a typical layout, but I have specific requirements. I'm trying to figure out a) if it's possible to meet the requirements and b) if so, how. +---------------+ | header |...
6
by: Fabri | last post by:
I shoul want to know the content o a certain span: ************************************************************************ <html> <head> <title>Documento senza titolo</title> <meta...
5
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As...
9
by: Water Cooler v2 | last post by:
I know what it is, and yet the knowledge of what a CMS is, is so vague that I find myself asking this question every now and then. I've googled and read the resources too. However, the knowledge is...
4
by: shypen42 | last post by:
Hi, I'd like to know how to serve web pages as "cleanly" as possible, maybe validating them if it's possible. How should I do to both respect standards *and* have it work under the various IE...
1
by: woodworthjames | last post by:
Hello, not sure i am using xpath correctly. have the following trivial xml. <?:xml version="1.0" standalone="yes" ?> <top attr="1"> content1 content2 <inner id="first" day="friday"> content3...
8
by: Neo Geshel | last post by:
Greetings. BACKGROUND: My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are delivered as application/xhtml+xml for all non-MS web clients, and as text/xml for all MS web...
5
by: Martin | last post by:
I get below error when trying to write unicode xml to a zipfile. zip.writestr('content.xml', content.toxml()) File "/usr/lib/python2.4/zipfile.py", line 460, in writestr zinfo.CRC =...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.