[Asterisk-Users] Re: MOH native files

Matt Roth mroth at imminc.com
Thu Mar 2 10:28:03 MST 2006


Tomislav Parčina wrote:

>>sox out.wav -r 8000 out.gsm
>>    
>>
>
>I have problem with this command. It runs fine, but when I play that file it is twice long as it should be and double slow as it should be. So wav file that was 2 min long becomes 4 min long gsm file.
>
>How can I fix that?
>  
>
Tomislav,

 From the sox man page:

============================================================
Audio data can usually be totally described by four characteristics:

rate
    The sample rate is in samples per second.  For example, CD sample 
rates are at 44100.

data size
    The precision the data is stored in.  Most popular are 8-bit bytes 
or 16-bit words.

data encoding
    What encoding the data type uses.  Examples are u-law, ADPCM, or 
signed linear data.

channels
     How many channels are contained in the audio data.  Mono and Stereo 
are the two most common.
============================================================

In order to get the proper encoding for Asterisk, you must provide the 
correct values for each of these characteristics.  In your case, they 
are as follows:

    rate = 8000
    data size = 8-bit (byte)
    data encoding = gsm
    channels = 1 (mono)

Therefore, the command you would use to create your native MOH files is:

    sox in.wav -t gsm -r 8000 -b -c 1 out.gsm

I *believe* that will work, but we convert all of our MOH files to u-Law 
since all of our calls use the u-Law codec.  Your mileage may vary with 
GSM so please post your results to the list.

Here are the characteristics of the native MOH files we produce and the 
sox command we use to do so:

    rate = 8000
    data size = 8-bit (byte)
    data encoding = u-Law
    channels = 1 (mono)

    sox in.wav -t ul -r 8000 -b -c 1 out.pcm

Hope that helps,

Matthew Roth
InterMedia Marketing Solutions
Software Engineer and Systems Developer



More information about the asterisk-users mailing list