SOX - Sound Exchange
Useful application to convert sound files between different formats.
From the web site:
SoX is a sound file format converter for Unix and DOS PCs written by Lance Norskog and other invaluable contributors. It also does sample rate conversion and some sound effects. It's the swiss army knife of sound tools: the interface isn't great, but it does almost everything.
SoX uses file suffixes to determine the nature of a sound sample file. If it finds the suffix in its list, it uses the appropriate read or write handler to deal with that file. SoX has an auto-detect feature that attempts to figure out the nature of an unmarked sound sample. It works very well. This is the 'auto' file format.
If your sox does not know how to handle .gsm - Files, you will have to download the latest version and recompile. Some distributions (like SuSE 9.0) do not include a sox compiled with GSM support :-(
- SoX is now maintained by a different author. There have been many improvements, as well. You can visit the new home page for SoX at http://sox.sourceforge.net/
- Old home page: http://www.spies.com/Sox/
Sox script for normalizing and converting mp3 & wav files to an Asterisk friendly format
Here is a script to normalize and convert mp3 and wav files for to proper wav files for music on hold
It basically amplifies the volume by the max suggested amount by sox, converts to 16 bit 8000 mono wav file, and then reduces the volume by 1/2
You can't run the script on the same files twice right now, although that would be trivial to incorporate
NOTE! It deletes the mp3 files and converted files as it works. I usually copy the files to a staging directory for the conversion. If you don't want this to happen, remove the "rm -f" lines from the code!
Hope it helps someone
echo "** THIS SCRIPT REQUIRES LAME AND SOX TO WORK!**"
- Convert mp3 files to wav
for i in *.mp3; do
echo "** Converting mp3 to wav files if they exist"
lame --decode "$i" "$val.wav"
rm -f "$i"
echo "** $i MP3 to WAV is complete"
- Convert wav files
for i in *.wav; do
echo "** Checking volume levels for $i"
ampl=`sox "$i" -t wav /dev/null stat -v 2>&1 | grep -v sox:`
echo "** Amplifying volume by $ampl to fake a normalize and converting $val.wav to 16 bit 8000"
sox -v "$ampl" "$i" -t wav -r 8000 -c 1 -w -s "$val.converted.wav" resample
rm -f "$val.wav"
echo "** Reducing the volume"
sox -v .5 "$val.converted.wav" "$val.wav"
rm -f "$val.converted.wav"
echo "** $i is complete"
The ".5" in "line "sox -v .5 $val.converted.wav $val.wav" is what the amount (1/2) of volume changed (half seems to be good for our music on hold volume) YMMV, feel free to change it
- WavePad: Sound recorder and batch converter
- GX::Transcoder: Freeware tool for sound conversion, including g729 and g723 formats
- On-line audio conversion by asteriskguru.com, including G729 and g723 formats
- Asterisk sound files - example on how to convert from .wav to .gsm with sox
- Asterisk audio convert module - Loadable module for Asterisk to convert Asterisk audio formats from the * CLI - very cool!
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+