forked from prosodylab/Prosodylab-Aligner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
align_ex.sh
executable file
·49 lines (40 loc) · 912 Bytes
/
align_ex.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# Example that does a single alignment
# Kyle Gorman <[email protected]>
# check args
if [ $# -lt 2 ]; then
echo "USAGE: ./align_ex.sh [align.py_args...] WAV LAB";
exit 1;
fi
# arguments logic
ARGS=("$@")
WAV=${ARGS[$#-2]}
LAB=${ARGS[$#-1]}
unset ARGS[$#]
unset ARGS[$#]
# check for existence of data
if ! ( [ -e $WAV ] ); then
echo "WAV file $WAV not found.";
exit 1;
fi
if ! ( [ -e $LAB ] ); then
echo "LAB file $LAB not found.";
exit 1;
fi
# make a temp directory to keep outcomes in
mkdir -p .dat;
# copy it to the tmp folder
cp $WAV $LAB .dat;
# perform alignment
python align.py ${ARGS[@]:0:$#-2} .dat/;
if [ $? != 1 ]; then
# name of output file
TextGrid=$(basename $WAV ); TextGrid=${TextGrid%.*}.TextGrid;
# move it
mv .dat/$TextGrid .;
echo "Output is in $TextGrid.";
rm -r .dat;
else
echo "Alignment failed."
exit 1;
fi