Semaphor blog
Blog: Semaphor

Convert WMA recorded files to asterisk

We are converting a lot of different files to our costumers.
Usually we get the files in WAV, or WMA files, most of them in WMA, as it is microsoft recorders favorite codec.
Unfortuneatly, Asterisk cannot use that codec, so we have to convert it to something that Asterisk understands.
To save time, and all the manual work we use this little handy script that converts WMA to both wav mono 16bit 8Khz, sln format, and gsm.
That way asterisk can choose the format that is most similar to the codec that runs in the channels.

#!/bin/sh
 tmpfile=/tmp/rescale$$.wav
 for i in *.wma; do 
	wav=$(basename $i .wma).wav
	sln=$(basename $i .wma).sln
	gsm=$(basename $i .wma).gsm
	ffmpeg -i $i -ar 8000 $wav
	sox $wav -t raw -r 8000 -s -2 -c 1 $sln
	scale=$(sox $wav /tmp/foo.wav stat -v 2>&1)
   	if [ $scale != "1.000" ]; then
     		echo -n "Rescale $i..."
	     	cp $wav $tmpfile
     		sox $tmpfile -v $scale $wav
     		echo
   	fi
done 
for i in *.wav; do sox $i -r 8000 -c 1 $gsm resample -ql; done

21-01-2014 10:09

0 Comments

Add comment

Name:
E-mail:
City:
Job:
Subject:
Comment:
 
It may take a moment until your comment is published.