Thursday, September 23, 2010

Converting WAV file to Asterisk Audio file?

You can use SOX command in linux

# man sox

# sox NONasteriskXXX.wav -c 1 -r 8000 asteriskXXX.gsm

(it resamples the non asterisk audio file in single channel audio with 8Khz sampling frequency)

If you have tons of wav file, it's waste of time to type a command for every individual wav files. So, you can do the following

Let's say you have WAV files in /tmp/recordings directory.

/tmp/recordings# for i in *
> do
> sox $i -c 1 -r 8000 `echo $i|sed "s/.wav/.gsm/"`
> done

Ooola.. it's done!!! You just converted all the files in /tmp/recordings directory from WAV to gsm.

Here, we are using for loop to go thru' each files in the /tmp/recordings directory. '$i' returns the file name. 'sed "s/.wav/.gsm/"' renames the file from .wav to .gsm

2 comments: