Using sox to convert WAV files to a-law or u-law for IVR

Often I have to convert wav files to different and quite esoteric formats that can be used with IVR (Interactive voice response) and Phone systems of clients.
Most formats you can mix directly out of Pro Tools, or your DAW of choice, but sometimes I have to encode files as u-law, a-law or gsm which Pro Tools can’t do.
Do do this I use a handy command line tool for the Mac (it works on windows and linux as well) called SoX
http://sox.sourceforge.net/

Once you’ve downloaded the zip file you and extracted it you should have a folder called “sox-14.4.0” where 14.4.0 is the version number.
What I normally do is rename the folder simply “sox” and move it to my home folder. From here open the terminal (found in Applications->Utilities) and you can simply drag the executable file called sox on to the terminal window. Find the file you wish to covert and drag that on to the terminal window. This will then show the path on your system to the file to be converted. Then to create a 8000 kHz mono a-law encoded file type:

-r 8000 -c 1 -e a-law

or for u-law

-r 8000 -c 1 -e u-law

or gsm

-r 8000 -c 1 -e gsm

After this drag the folder where you want the file to end up, add a slash / and type the name of the output file ie /one-two-three-alaw.wav then hit enter and BOOM… you can use the time while it’s converting to practice pretending you don’t mind creating such low quality files…

The whole things should end up something like this:

/Users/homedir/sox/sox/ Users/homedir/audio-files/one-two-three.wav -r 8000 -c 1 -e a-law Users/homedir/audio-files/one-two-three-alaw.wav

SoX can do a lot more than this so it’s worth checking out the documentation at the SoX website.

One thought on “Using sox to convert WAV files to a-law or u-law for IVR

Leave a Reply

Your email address will not be published. Required fields are marked *


*