Upgrade 3CX to v18 and get it hosted free!

SOX – Sound Exchange

Author image

Useful application to convert sound files between different formats.

From the website:


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 writes a 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 do 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 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/

 

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

  1. !/bin/bash

echo “** THIS SCRIPT REQUIRES LAME AND SOX TO WORK!**”

  1. Convert mp3 files to wav

for i in *.mp3; do

val=${i%.mp3}

echo “** Converting mp3 to wav files if they exist”

lame –decode “$i” “$val.wav”

rm -f “$i”

echo “** $i MP3 to WAV is complete”

done

  1. Convert wav files

for i in *.wav; do

val=${i%.wav}

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”

done

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

See also

 


Article Reviews

Write a Review

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

Required Field. Minimum 5 characters.

Required Field. Minimum 5 characters, maximum 50.

Required field.There is an error with this field.

Required Field.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

There are no reviews for this article. Be the first one to write a review.

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.