20 September 2010 0 Comments

[Asterisk] Audio File Format Conversion

One of the major problem in an Asterisk IVR production is the file audio conversion.
Asterisk is able to playback a wide variety of file formats but the prefferred are following:

- GSM
- A-law
- U-law

Sound eXchange is the better way to accomplish this job.
Sox installation is quite simple:


# apt-get install sox libsox-fmt-all

Command above will install sox engine and all needed formats. Now is possible to converts all kind of audio file types:


$ sox input-file.wav -t raw -r 8000 -c 1 -b 8 -A output-file.alaw
$ sox input-file.wav -t raw -r 8000 -c 1 -b 8 -U output-file.ulaw
$ sox input-file.wav -t raw -r 8000 -c 1 -b 8 -g output-file.gsm

-t: Override input file type header.
-r: Resample audio rate (8 Khz for traditional phone line).
-c: The number of audio channels (-c means mono audio form).
-b: Bit-depth store format.
-A: Encoding type alias (-A stands for A-law, etc).

For others options please read sox(1) manual.

HINT: For multiple file conversion following command is suggested:


for a in *.wav; do sox "$a" -t raw -r 8000 -c 1 -b 8 -A `echo $a|sed "s/.wav/.alaw/"`; done

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • Google Buzz

Leave a Reply

You must be logged in to post a comment.

Powered by WP Symposium - Social Networking for WordPress  12.01.14