-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_find_duration_of_audio_file.sh
34 lines (27 loc) · 1.01 KB
/
bash_find_duration_of_audio_file.sh
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
26
27
28
29
30
31
32
33
34
#!/bin/bash
#Script to compute the duration of the audio clips into a list.
###Sample usage
#$bash bash_find_duration_of_audio_file.sh <testing/training/evaluation> <Audio Root Path> <Output Path>
#Define set
#$1 - testing/training/evaluation
#NOTE: Audio root path should only contain the .wav files
AUDIO_ROOT_PATH=$2
#Path where the list containing the duration of the clips will be written>
OUTPUT_PATH=$3
#Remove duration list if it exists
rm -rf $OUTPUT_PATH/duration_of_files_in_${1}_set.csv
cd $AUDIO_ROOT_PATH
wav_file=(*)
for i in "${wav_file[@]}"
do
a=`soxi -D $i`
if [ $1 == "testing" ]; then
echo -e $i ' \t '$a >> $OUTPUT_PATH/duration_of_files_in_testing_set.csv
elif [ $1 == "training" ]; then
echo -e $i ' \t '$a >> $OUTPUT_PATH/duration_of_files_in_training_set.csv
elif [ $1 == "evaluation" ]; then
echo -e $i ' \t '$a >> $OUTPUT_PATH/duration_of_files_in_evaluation_set.csv
else
echo "Duration File not created - Check your input - Argument 1 should be either testing, training or evaluation"
fi
done