如果 #channels 为 2,则连接 wav 文件忽略
Concatenate wav files ignore if # channels is 2
我需要将所有 wav 文件连接到一个文件夹中。
我尝试使用命令
sox folder_name/*.wav folder_name.wav
但是报错
sox FAIL sox: Input files must have the same # channels
原来那个文件夹中的 2864 个 wav 文件中只有 21 个有 2 个通道而不是 1 个。
我怎样才能忽略 21 个 2 个通道的文件,并将所有 2843 个 wavs 与 1 个通道连接起来?
使用soxi
获取所有一个频道文件,将它们放在一个数组中,然后调用sox
:
for file in folder_name/*.wav; do
if soxi "$file" | grep -q 'Channel.*1'; then
files+=("$file")
fi
done
sox "${files[@]}" folder_name.wav
我需要将所有 wav 文件连接到一个文件夹中。
我尝试使用命令
sox folder_name/*.wav folder_name.wav
但是报错
sox FAIL sox: Input files must have the same # channels
原来那个文件夹中的 2864 个 wav 文件中只有 21 个有 2 个通道而不是 1 个。
我怎样才能忽略 21 个 2 个通道的文件,并将所有 2843 个 wavs 与 1 个通道连接起来?
使用soxi
获取所有一个频道文件,将它们放在一个数组中,然后调用sox
:
for file in folder_name/*.wav; do
if soxi "$file" | grep -q 'Channel.*1'; then
files+=("$file")
fi
done
sox "${files[@]}" folder_name.wav