blob: ddb1a57b22f6c8d06aba6ade153b23c373dc5d13 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#/bin/sh
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <filename.wav> <chunk size in seconds> <dataset path>"
exit
fi
fn=$1
chunk_size=$2
dataset_path=$3
converted=".temp2.wav"
rm -f $converted
ffmpeg -y -hide_banner -loglevel error -i $fn -ac 1 -ar 44100 $converted
mkdir $dataset_path
length=$(ffprobe -i $converted -show_entries format=duration -v quiet -of csv="p=0")
end=$(echo "$length / $chunk_size - 1" | bc)
echo "splitting..."
for i in $(seq 0 $end); do
id=$(printf "%04d" $i)
ffmpeg -y -hide_banner -loglevel error -ss $(($i * $chunk_size)) -t $chunk_size -i $converted "${dataset_path}/${dataset_path}_${id}.wav"
done
echo "done"
rm -f $converted
|