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

invalid wav format in posted audio files

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
sweetp123
Posts: 16
Joined: Wed May 24, 2006 9:22 am

invalid wav format in posted audio files

Post by sweetp123 »

I am posting my recordings as "audio/x-wav" in my application and saving them as .wav files on the server - they play fine - however when i then try to convert them using an mp3 encoder i always get an error, no matter which encoder i use, particularly with lame
i also get an error when i try to import them into flash or into another application...is there something i am not aware of with respect to these files - should i save them as something else before converting? what is the best way to save them so that i can compress them after? is there a way to compress them when they are posted?

sweetp123
Posts: 16
Joined: Wed May 24, 2006 9:22 am

Post by sweetp123 »

I've been reading a few posts concerning this and also info in the audio repository manual and it seems as if i should use audio/basic
if i save that as a .wav file will this have the proper format to convert to mp3?

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

All 3 IVR formats have the same data size, 8KHz 8bit data

Post by support »

Hello,

There are formats for audio files recorded by our VoiceXML browser:

Code: Select all

audio/x-wav: wav header + u-law data
audio/basic: headerless u-law data
audio/x-alaw-basic: headerless a-law data
All three of these IVR formats have the same data size, 8KHz 8bit data. So there is no compression gained by switching the format. The audio/x-wav format is the most portable of these because it contains a header describing the data format of the audio.

In order for most desktop software such as flash or lame to use this audio you will need to convert the u-law wav file to a data format that the software understands. You can think of wav as a header that describes the data and u-law as the data itself. Almost all audio tools can read a wav header, but most can not decode u-law data. You will need to convert the audio into linear pcm wav file with a tool like sox:

Code: Select all

sox ulawfile.wav -l -w pcmfile.wav
After you have it in linear pcm wav format you can play it back using flash software or convert it to an mp3 using lame.

Regards,
Plum Support
Last edited by support on Mon Jan 04, 2010 4:56 pm, edited 2 times in total.

sweetp123
Posts: 16
Joined: Wed May 24, 2006 9:22 am

Post by sweetp123 »

ok that's fine if i am just converting a few files here and there - what if i want to convert files on the fly in my application and don't have access to a command line (i.e. in coldfusion) then those .wav files are pretty much useless to me. I now need to process one file twice in order to use it? :roll:

do you know if sox has any conversion algorithms written in java or c++ that i can use - or if they have a web service i can access instead of a command line execution?

sweetp123
Posts: 16
Joined: Wed May 24, 2006 9:22 am

Post by sweetp123 »

i just tried this command line with sox and there is no w command
i tried without it and the file size is now huge...?

also lame is not really desktop software - it is an encoding algorithm - so it doesn't actually "use" the file, it just doesn't recognize the format so that it can convert it

sweetp123
Posts: 16
Joined: Wed May 24, 2006 9:22 am

Post by sweetp123 »

i have managed to convert the file to linear pcm and then to mp3 using lame but the quality is very poor, and if i use a VBR setting which improves the quality, then i have problems again with flash recognizing it
i need to stream the mp3s with flash so they need to be decent quality and proper format
do you have any suggestions on the best command line arguments to use with sox and then the best bit rate and quality settings to use for compressing? i do not work with audio often so your help is really appreciated esp with regards to formats...
should i just record the original message on the vxml platform using audio/basic or stick with the audio/x-wav?

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

Recording audio for IVR use

Post by support »

Hello,

You should be recording the audio in audio/x-wav for the IVR system. This format is exactly the same as audio/basic except that it comes in a file with a header at the beginning saying that it contains u-law data. This helps you by all the necessary information to the audio conversion software about the format of the internal audio.

Have you tried playing the audio back using the linear pcm in flash? This is a decent format for you to push audio around since it very portable and no data loss will occur. If you must convert it to mp3 a good IVR format option is:

Code: Select all

16KHz 16kbps mono:
lame -h test.wav -b 16 --resample 16 -a test.mp3
This IVR format should retain most of the audio data and allow for smaller file sizes (almost 1/3 of the original u-law file). You can also experiment with using a lowpass filter to remove data you don't want being sent anyway (for example: --lowpass 5).

Regards,
Plum Support

Post Reply