Sox format for stream with sample spec ‘s16le 1ch 16000Hz’, channel map ‘mono’

alsaaudiopulseaudiosox

I'm trying to pipe audio to sox and I get Error "sox FAIL formats: bad input format for `-': sampling rate was not specified"

parec -d alsa_output.pci-0000_00_1b.0.analog-stereo.monitor  --rate=16000 --channels=1 | sox -t raw - output.wav  silence 1 0.3 0.1% 1 0.3 0.1% : newfile : restart

This is output of the command

sox FAIL formats: bad input format for  `-': sampling rate was not specified
Opening a recording stream with sample specification 's16le 1ch 16000Hz' and channel map 'mono'.
Connection established.
Stream successfully created.
Buffer metrics: maxlength=4194304, fragsize=64000
Using sample spec 's16le 1ch 16000Hz', channel map 'mono'.
Connected to device alsa_output.pci-0000_00_1b.0.analog-stereo.monitor (index: 0, suspended: no).
write() failed: Broken pipe

Best Answer

A raw stream does not contain any meta-information about its format, so you have to tell sox about it:

parec ... | sox -t raw -r 16k -e signed -b 16 -c 1 ...
Related Question