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

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

save records as wav file

Post by Vlad »

I have a problem to save and open recorded messages as a wav file.

When i try to open the saved file i get an error that format is not

correct. I use type='audio/x-wav' in <record> tag and save all

input stream as a wav file.

Code: Select all

<form id='description1'>
  <record name='description1' type='audio/x-wav' beep='true'>
    <prompt>
      Please say description for your answer 
    </prompt>
    <filled>
      I heard, <value expr='description1'/> 
    </filled>
  </record>
  <block>
    <submit next='VxmlSaveAnswers.aspx' namelist='description1'   method='post' enctype='multipart/form-data'/>
  </block>
</form>


-----------------------------VxmlSaveAnswers.aspx.cs-------------------

StreamReader sr = new StreamReader(Request.InputStream);

string wavFile = sr.ReadToEnd();

byte[] ba = HttpUtility.UrlDecodeToBytes(wavFile);

FileStream fs = new FileStream(filePath, FileMode.CreateNew);

BinaryWriter bw = new BinaryWriter(fs);

bw.Write(ba);

bw.Flush();

fs.Close();

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

Please elaborate on the IVR error you are encountering.

Post by support »

Vlad:

More information is needed. Please elaborate on the IVR error you are encountering. Is it a vxml error that you are pulling from the IVR lastlog field on the hosted IVR site? Is it an IVR error in the asp page?

I'm not an expert on asp, most of our engineers here use php or jsp for serverside processing. It strikes me that you never reference the HTTP POST variable named "description1", unless you neglected to post in that part of your asp page. That's where the audio data is stored.

Post back with more details please.

Plum Support
Last edited by support on Thu Feb 25, 2010 1:49 pm, edited 2 times in total.

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

wav format

Post by Vlad »

Thank you for response.
I have succeed to save wav file on the server.
The problem is that i can't to open this file with Media Player.
I checked this file with hex editor and discovered that there are
some information was wroten before the header (before RIFF)
and chunk's size is not correct. After i changed this file in hex editor
i succeed to open it with Media Player.
So the question is i get not correct stream from PLUM or i must to
work with this stream for convert it to wav format?

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

IVR engineers use a utility called sox for conversions

Post by support »

Hi Vlad:


The reason it won't work by default is due to the fact that the audio file returned by the <record> tag is stored in headerless PCM, you'll have to apply a conversion to this to get into wav format. Our IVR engineers here use a utility called sox to do the conversion. A sample is in order:

Code: Select all

  sox -t ul -r 8000 /tmp/input.ul /tmp/ouput.wav
The preceding code takes a raw pcm file uploaded to /tmp, and turns it into an 8khz, 8 bit wav file

If you already have an audio conversion tool you can use that,
or you can use sox for windows:
http://www.spies.com/Sox/

hope this helps!

Plum Support Team
Last edited by support on Thu Jan 14, 2010 3:32 pm, edited 2 times in total.

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

Post by Vlad »

OK.
But if i use record tag with type='x-wav' i get a file with header.
Which type i should use?

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

IVR issue with ulaw

Post by support »

x-wav is fine for an audio format. You don't have to use sox; the IVR issue is that Windows

media player does not recognize ulaw. If you use a program that recognizes headerless ulaw

properly it will work (like cool edit or a similar program)

the sox command I supplied will make it playable in windows media player

cheers,

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

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

Post by Vlad »

Hi.
sox make my file readable for Media Player but data was
corrupted... may be you now why?

Thank you.

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

more information needed for IVR concern

Post by support »

Vlad:

I don't understand your last IVR post, can you please provide more information?

thanks,

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

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

Post by Vlad »

sox command make my file playable in windows media player

but i don't hear the same information that i saved to file.

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

IVR issue with hearing recording

Post by support »

If you don't hear what you recorded, then what are you hearing? We need to know to better understand your IVR issue.
Last edited by support on Thu Jan 14, 2010 3:35 pm, edited 1 time in total.

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

Post by Vlad »

Only noise.

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

Post by Vlad »

Could you send me a code example how you
save records as a wav file?

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

IVR code sample in PHP

Post by support »

we can post an IVR code sample but it will be in php...is that ok?

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

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

Post by Vlad »

OK
Thanks.

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

Post by Vlad »

What about code example?

Post Reply