Sox in between two pipes

audiopipesox

I'm trying to put the "sox" utility in a two pipes command to resample a mono 44kHz audio file to a 16kHz audio file.

It works fine with a single pipe :

$ speexdec toto.oga - | sox -V -t raw -b 16 -e signed -c 1 -r 44.1k - -r 16k toto.wav

But when I add onather pipe, the sox utility complains :

$ speexdec toto.oga - | sox -V -t raw -b 16 -e signed -c 1 -r 44.1k - -r 16k - | cat - > toto.wav
sox FAIL formats: can't determine type of `-'

Any idea ?

Best Answer

You need to declare the type of the sox output by adding -t wav before the second -.

When it's a file name, sox peeps at the name and deduces the type from there, but when it's stdout, the type needs to be declared.

You might also want to declare all other settings as well (-b 16 -e signed -c 1) rather than assuming they are transferred from the input; all before the last - that nominates the output.

Related Question