-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcheck_folder.sh
More file actions
executable file
·35 lines (29 loc) · 995 Bytes
/
check_folder.sh
File metadata and controls
executable file
·35 lines (29 loc) · 995 Bytes
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
35
#!/bin/bash
check_folder=$(readlink -f $1)
# First check that the folder is not empty
if [[ -z "$(ls -A $check_folder)" ]]; then
echo "data folder is empty!"
exit
else
echo "wavs and transcriptions found !"
fi
# Then, check the consistency of all the files -> check if
# the wav have no amplitude
# (credit to http://decided.ly/2013/02/06/find-silent-audio-files/)
## A quick hack like script to list all the files that have
## a low amplitude.
Max=0.0 # Any amplitude greater than this will NOT be listed
#OutList=~/output.list # The name of the file that contains a
# list of file names only of all the
# low-amplitude files.
# rm $OutList
for each in `ls $check_folder/*.wav`
do
amplitude=$(sox "$each" -n stat 2>&1 | grep "Maximum amplitude" | cut -d ":" -f 2 | sed 's/ //g')
if [[ $(echo "if (${amplitude} > ${Max}) 1 else 0" | bc) -eq 0 ]]
then
echo "$each --> $amplitude" >&2
echo "$each seems empty !"
fi
done
echo "Tests finished"