We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

save records as wav file

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

sample IVR code still needed

Post by support »

We will have an example of IVR code up for you by the end of today (Tuesday, Aug 31st)

support
Last edited by support on Thu Jan 14, 2010 3:37 pm, edited 1 time in total.

Vlad
Posts: 11
Joined: Tue Aug 17, 2004 5:55 am

Post by Vlad »

Hi!
Doesn't you forget me? :)

Vlad
Posts: 11
Joined: Tue Aug 17, 2004 5:55 am

Post by Vlad »

I see that was done some changes in the platform.

I am waiting for a code sample yet.

Thank you in advance.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR code example

Post by support »

Hi Vlad:

Sorry it took so long to get this to you. In the following IVR example there are 2 files: The front end, which includes all the vxml to present to the caller, and the backend, which includes all of the php to save the file to a local directory:

Frontend.vxml:

Code: Select all

<?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="file_upload.php" 
		method="post" 
		enctype="multipart/form-data"
		namelist="myrecording"/> 
    </filled> 
    <noinput>
      <reprompt/>
    </noinput>
    <nomatch>
      <goto next="#record_audio"/>
    </nomatch>
  </field>
</form>

</vxml>

file_upload.php

Code: Select all

<?php

  // EXTRACT myrecording FROM POST VARIABLES
  if (!isset($_FILES['myrecording'])) {
    ////////////////////////ERROR CONDITION
    die("No file was uploaded."); 
  }
  $myrecording = $_FILES['myrecording'];
  $tmp_name = $myrecording['tmp_name'];
  $size = $myrecording['size'];
  $type = $myrecording['type'];


  GLOBAL $upload_dir;
  $upload_dir = "/usr/local/apache/htdocs/www.mysite.com/upload_folder/";

  // GENERATE A FILE NAME
  $targetname = $upload_dir . "myrecording.wav";

  // PLOP FILE INTO PLACE WITH NEW FILE ID
  if (move_uploaded_file($tmp_name, $targetname)==false) {
    ////////////////////////ERROR CONDITION
    unlink($tmp_name);
   die("Relocation of uploaded file failed.");
  }

?>
You'll have to change the global upload directory and make it writable by the webserver user, but those 2 changes should be all that's needed.

Hope This helps, again sorry it took so long!

Plum Support Team
Last edited by support on Thu Jan 14, 2010 3:38 pm, edited 1 time in total.

sdstuder
Posts: 16
Joined: Fri Mar 18, 2005 6:38 pm

ASPX Example for Uploading a Recording

Post by sdstuder »

Vlad,

Were you ever able to successfully upload an audio file with ASPX? I'm trying to do the same thing and haven't had much success. If you could share your source code (much like your original thread in this post) it would save me a MASSIVE amount of time. The Php example is useful... but not really.

Best,
Scott

ifusion
Posts: 1
Joined: Thu May 11, 2006 10:13 pm

Re: ASPX Example for Uploading a Recording

Post by ifusion »

sdstuder wrote:Vlad,

Were you ever able to successfully upload an audio file with ASPX? I'm trying to do the same thing and haven't had much success. If you could share your source code (much like your original thread in this post) it would save me a MASSIVE amount of time. The Php example is useful... but not really.

Best,
Scott
Turns out to be pretty simple. You can access the Request.Files property, which is an HttpFileCollection, and which returns instances of System.Web.HttpPostedFile - same as if you had used the ASP.NET file control on a form.

An example:

Code: Select all

    
if (Request.Files.Count > 0)
{
   System.Web.HttpPostedFile UploadedFile = Request.Files[0];
   UploadedFile.SaveAs(@"c:\inetpub\wwwroot\FileUpload\Sample.pdf");
}  
Hope that helps.

Jared

Post Reply