Convert audio files to ulaw or sln for use with a VoIP PBX (Updates for 2018)

August 13th, 2018 Leave a comment Go to comments

Converting high quality audio files to ulaw is easy, but making them sound good takes some effort.  Keep reading for the technique we use, updated for 2018.


Allison on Twitter writes:

This sounds like a great time to revisit this article and rerun tests with the latest versions of our audio tools.

In our opinion, the results of the following sounded best when played via Asterisk to a G.711-capable phone, and it was a very close second place when played to a G.722-capable phone.  This is what we plan to use going forward.
sox input.wav --rate 8000 --channels 1 --type raw output.sln lowpass 3400 highpass 300

Without the lowpass and highpass, we thought the audio sounded slightly better to a G.722 phone, but not as good to a G.711 phone.  However, the difference was subtle enough that we recommend you do your own testing with your own audio files, in case your opinion is different from ours.
sox input.wav --rate 8000 --channels 1 --type raw output.sln

NOTE: Depending on the type of CPU in your Asterisk server, if you hear a high-pitched screech instead of your audio file, you may need to use the --endian big switch like this:
sox input.wav --rate 8000 --channels 1 --type raw --endian big output.sln lowpass 3400 highpass 300

ulaw did not produce results that sounded as good as sln.
sox input.wav --rate 8000 --channels 1 --type ul output.ulaw lowpass 3400 highpass 300

In our tests with ulaw, ffmpeg and sox produced identical results.
ffmpeg -i input.wav -af "highpass=f=300, lowpass=f=3400" -ar 8000 -ac 1 -ab 64k -f mulaw output.ulaw

 
  1. Adam W
    July 18th, 2011 at 09:36 | #1

    Life.  Saver.  🙂
     

  2. Ivan
    April 10th, 2012 at 11:18 | #2

    Couldn't help to stop by to say thanks. I had some gsm files that I wanted to convert to ulaw, and the second line worked for me.
     

If you would like a reply to your comment, you must leave your email address! We receive dozens of questions every month from people who don't leave us with any way to contact them, so we have no choice but to ignore the question. We try to reply to as many questions as we can, if we know the email address of the person who asked the question. Thanks in advance for writing in :)

Allowed HTML: <b>, <i>, <em>, <strong>. All other < and > will be replaced with &lt; and &gt;.