8

I have a test.wav file.  I need to use this file to process an application, with following properties:

  1. monochannel
  2. 16 kHz sample rate
  3. 16-bit

Now, I'm using the following commands to attain these properties:

sox disturbence.wav -r 16000 disturbence_16000.wav
sox disturbence_16000.wav -c 1 disturbence_1600_mono.wav
sox disturbence_1600_mono.wav -s -b 16 disturbence_1600_mono_16bit.wav

Here to get a single file, three steps are involved and two temporary files are created.  It is a time-consuming process.

I thought of writing a script to do these process but I'm keeping this is a last option.

In single command, can I convert a .wav file to the required format?

1
  • What should the -s-option do? Apr 4, 2016 at 8:43

2 Answers 2

23

sox disturbence.wav -r 16000 -c 1 -b 16 disturbence_16000_mono_16bit.wav

gives within one command

  • Sample rate of 16 kHz (-r 16000),
  • one channel (mono) (-c 1),
  • 16 bits bit depth (-b 16).
1

one-liner for all .wav files in the directory:

for file in *.wav; do sox $file -r 16000 -c 1 -b 16 "$(basename $file .wav)_16000_mono_16bit.wav" -V; done
1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Dec 27, 2021 at 23:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .