-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_utts.sh
32 lines (27 loc) · 971 Bytes
/
generate_utts.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
#!/bin/bash
# A script for creating utt2path and utt2label files, required by the lidbox tool.
if [ $# != 1 ]; then
echo "Usage: ./generate_utts.sh [WAV_DIR]"
echo ""
echo "Creates utt2path and utt2label files from the files"
echo "in the WAV_DIR. All files within WAV_DIR are assumed"
echo "to be .wav files. The 'utt' ids are formed from the"
echo "basenames of the wav files. In absence of true labels,"
echo "all labels are set to 'en' because lidbox requires"
echo "placeholder labels."
exit 1;
fi
SRCDIR="$1"
echo "Creating utt2path and utt2label from '$SRCDIR' IN $PWD."
if [ ! -f utt2label ] && [ ! -f utt2path ]; then
echo "Writing new utt2label and utt2path files."
for i in $(find $(realpath "$SRCDIR") -type f)
do
FNAME=$(basename $i)
echo "${FNAME%.*} ${i}" >> utt2path
echo "${FNAME%.*} en" >> utt2label
done
echo "Finished."
else
echo "An utt2* file exists already, will not overwrite. Remove both utt2* files and try again."
fi