sox

 

Usage

sox [global-options] [format-options] infile1
[[format-options] infile2] ... [format-options] outfile
[effect [effect-options]] ...

-t, --type FILE-TYPE

Gives the input type of the audio file

-b BITS

bits in each encoded sample (MP3 or GSM 及 a/u-law 無呢個 opts)

# wav to sln32

8kHz        .sln
16kHz       .sln16
32kHz       .sln32

sox input.wav -t raw -b 16 -r 32k output.sln32

# mp3 to sln

apt-get install libsox-fmt-mp3

sox my-welcome.mp3 -t mp3 output.sln32

 


asterisk playback format

 

support: wav (mono, 8kHz sample rate, 16bit linear)

Recording a sound-file in Windows

http://audacity.sourceforge.net/

# mp3 to wav

sox my_welcome.mp3 tmp.wav

file tmp.wav

tmp.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 16000 Hz

# Unexpected frequency mismatch 16000 (expecting 8000)

sox my_welcome.mp3 -r 8k -c 1 /var/lib/asterisk/sounds/myfile/my-welcome.wav

sox tmp.wav -r 8k -e signed-integer -c 1 -b 16 my-welcome.wav

# -c1 option to convert to mono

# -e ENCODING, --encoding ENCODING

Sometimes needed with file-types that support more than one encoding type.

signed-integer (PCM  data  stored  as  signed (`two's complement') integers.)
unsigned-integer (Commonly used with an 8-bit encoding size)
a-law
u-law
gsm-full-rate

 

# mix | merge

-m|-M  Equivalent to --combine mix and --combine merge

 

 

Creative Commons license icon Creative Commons license icon