Converting WAV files
Converting WAV files
If you have a wav file (in what format?) you can convert it using the sox program.
– Raw linear, signed 16 bit, mono, 8000 Hz (.slin)
sox file.wav -t raw -r 8000 -c 1 -w -s file.slin
– Raw mu-law, mono, 8000 Hz (.mulaw or .u)
sox file.wav -t raw -r 8000 -c 1 -b 8 -U file.mulaw
– Raw A-law, mono, 8000 Hz (.alaw or .A)
sox file.wav -t raw -r 8000 -c 1 -b 8 -A file.alaw
– Raw GSM, mono, 8000 Hz (.gsm)
sox file.wav -t raw -r 8000 -c 1 -b 8 -g file.gsm (not all versions of sox support this conversion)
– SUN/SGI audio/basic file, mono 8000 Hz (.au) containing:
- Signed linear sox file.wav -r 8000 -c 1 -w -s file.au - alaw sox file.wav -r 8000 -c 1 -b 8 -A file.au - mulaw sox file.wav -r 8000 -c 1 -b 8 -U file.au
In addition basic format “conversion” if needed:
– WAV into RAW (tested with an A-law, mono, 8000 Hz riff wavefile)
sox file.wav file.raw
The SUN/SGI formats have the advantage of being easily playable in a Web browser and it also preserves the format information.
The output format should always be mono, 8 kHz as that is required for telephony.
Converting into WAV files
If you have a mono 8kHz raw data file you can convert it into wave file by using sox
– Raw A-law, mono, 8000 Hz (.alaw or .A)
sox -t raw -r 8000 -A -b 8 -c 1 file.alaw file.wav
– mulaw, mono 8000 Hz (.mulaw)
sox -t raw -r 8000 -U -b 8 -c 1 file.mulaw test.wav