Jump to content

PHP voicexml help


st1ng81

Recommended Posts

I am recording user's voice using vxml and want to generate .wav file on the disk.I am using php for that.But there is  some error,and the file is not getting saved.please some1 help me.If the .wav is generated how can i link it to database?

<!---record.xml--->
<?xml version="1.0"?>
<vxml version="2.0">
    <form>
        <record beep="true" name="file" type="audio/x-wav" maxtime="5s"
        dtmfterm="true">
            <prompt>
              Say something. Press any key to stop recording.
            </prompt>
            <noinput>
              I can't heard you.
            </noinput>
            <filled>
                <prompt>
                    Your message <value expr="file" />
                </prompt>
<submit next="123.php" method="post" namelist="file" enctype="multipart/form-data" />
          </filled>
      </record>
  </form>
</vxml>    

 

//123.php
<?PHP
header('Cache-Control: no-cache');
error_reporting (0);
$filename = $_HTTP_POST_FILES["file"];

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

echo "<vxml version=\"2.0\">";

echo "<form id=\"main\">";
echo "<block>";

if ($HTTP_POST_FILES) {
  foreach ($HTTP_POST_FILES as $key => $value) {
    foreach ($value as $Filename) {

      if (strpos($Filename, "WIN7")) { $ServerSide = $Filename; }
      if (strpos($Filename, ".wav"))  { $ClientSide = $Filename; }
    }  // for each statement

    $ClientSide = str_replace("\\\\", "/", $ClientSide);

    if (!copy($ClientSide, "c:\audio-storage\temp.wav")) {
      echo "Could not save filename: " . $ClientSide;
    } // if statement
    else {
      echo "Successfully saved filename: " . $ClientSide;
    }  // else statement

  }  // for each statement
} 

echo "</block>";
echo "</form>";
echo "</vxml>";
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.