Batch convert Asterisk GSM WAV files to mp3

I am working on a fun project at work to provide web based visual voice-mail for a ticketing system. I realized Flash audio players are not able to play WAV files so had to work around that. Since users are also using voicemail files in other ways I can't just change the output format from Asterisk. The type of file that I'm working with is identifed with file ms0012.WAV as: msg0012.WAV: RIFF (little-endian) data, WAVE audio, GSM 6.10, mono 8000 Hz

First I'll say that I found this post http://www.thiscoolsite.com/?p=73 but like some of the commenters I couldn't get the script to work. The author assumes some other format than Asterisk spits out by default. Lame would complain that Unsupported data format: 0x0031

The Tools
Sox: http://sox.sourceforge.net/
Lame: http://lame.sourceforge.net/

So here's what I do:
Convert GSM encoded wav to Microsoft PCM
sox msg0012.WAV -s msg0012.wav

Convert the PCM wav to mp3:
lame msg0012.wav msg0012.mp3

And here's a script to do this as a batch:


toddler said...

Thanks for this, I'm writing a converter so I can listen to my voice mail on my Android phone and encountered the same problem feeding the wav file to lame.

Anonymous said...

Thank you for this !
a big help

here said...

where's the path of the script? it will run in cron job or what?

Author said...

Thanks for the post..
Here is online free mp3 to wav converter
convert mp3 to wav

Anonymous said...

Have you tried Faasoft Audio Converter? A good gsm converter.

Clint Tepe said...
This comment has been removed by the author.
Clint Tepe said...

This works, but I found a simpler script that only converts once and in my testing results in better sound quality: http://community.spiceworks.com/how_to/890-converting-wav-files-into-mp3-s-automatically-for-asterisk-recordings.