summaryrefslogtreecommitdiff
path: root/datasets/split44k.sh
blob: b679d29aa19f8b3d96fd8ba156ce64d1e1f00d94 (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
#/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  -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
    ffmpeg -hide_banner -loglevel error -ss $(($i * $chunk_size)) -t $chunk_size -i $converted "$dataset_path/$i.wav"
done
echo "done"
rm -f $converted