Audio

帶有樣本規格“s16le 1ch 16000Hz”、通道映射“單聲道”的流的 Sox 格式

  • January 31, 2019

我正在嘗試將音頻傳輸到 sox,但出現錯誤“sox FAIL 格式:`-’ 的輸入格式錯誤:未指定採樣率”

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

這是命令的輸出

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

原始流不包含有關其格式的任何元資訊,因此您必須告訴 sox :

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

引用自:https://unix.stackexchange.com/questions/497920