[SOLVED] How to convert .mp3 to .wav for use with MOH

Get help with installing and running AsteriskNOW.

Moderators: Support, Moderator

[SOLVED] How to convert .mp3 to .wav for use with MOH

Postby mutineer612 » Wed May 04, 2011 8:44 pm

After scouring the Internet and a bit of trial and error I figured out how to convert .mp3 files easily to an acceptable .wav format for use with Asterisk MOH. In my case I was using Ubuntu Linux to convert the file prior to uploading to AsteriskNOW 1.7 using the FreePBX 2.8 interface.

Keeping in mind Asterisk can read only two kinds of WAV files formatted at 8000hz with 1 mono channel: Microsoft WAV format signed linear (with a lowercase .wav extension) or WAV-GSM, also called wav49, with an uppercase “WAV” extension.

Download and install Sox (Sound Exchange) and make sure to also install the MP3 format library. Once converted use the FreePBX MOH gui to upload your <output-file>.wav file... Enjoy!

Use the following command to convert MP3's to 8000 hz mono .wav files.
Code: Select all
$ sox <input-file>.mp3 -c1 -r 8000 <output-file>.wav

Files are uploaded to /var/lib/asterisk/moh which is the 'default' Music Category directory. I notice that FreePBX renamed the file inserting a 'wav_' at the beginning of the filename.
Last edited by mutineer612 on Fri Jul 15, 2011 3:05 pm, edited 1 time in total.
Posts: 30
Joined: Thu Nov 18, 2010 5:28 pm

Re: How to convert .mp3 to .wav for use with MOH

Postby malcolmd » Thu May 05, 2011 8:34 am

If you're using an underlying version of Asterisk that's at least 1.6.0, e.g. 1.6.0, 1.6.1, 1.6.2, 1.8, and you've got clients that use a 16kHz codec like G.722, then you might want to convert using "-r 16000" instead and put them to sln16, e.g.:

Code: Select all
sox input.wav -t raw -c 1 -r 16000 output.sln
mv output.sln output.sln16

So that your 16kHz clients get the best possible audio experience. Everyone else just gets those files automagically downsampled by Asterisk.
Malcolm Davenport
Digium, Inc. | Senior Product Manager
Moves Like Spencer
Posts: 2665
Joined: Wed Aug 03, 2005 3:53 pm
Location: Huntsville, AL, US

Re: How to convert .mp3 to .wav for use with MOH

Postby zachsis » Fri May 06, 2011 8:37 am

Make a shell script and do this where $1 is the original wav file, and $2 is the .ulaw file. e.g. sox -V pwsteal.wav -r 8000 -c 1 -t u1 -w pwsteal2.ulaw

Code: Select all

sox -V $1 -r 8000 -c 1 -t ul -w $2
Posts: 9
Joined: Tue Jan 25, 2011 1:25 pm

Return to AsteriskNOW Support

Who is online

Users browsing this forum: Google [Bot] and 9 guests