forked from prosodylab/Prosodylab-Aligner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalign_ex.sh
executable file
·47 lines (38 loc) · 885 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
#!/bin/bash
# align_ex.sh: do a single alignment
# Kyle Gorman <gormanky@ohsu.edu>
# fail if any non-zero return codes
set -e
# 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
TMP=$(mktemp -d -t $(basename $0))
echo "$TMP"
# copy it to the tmp folder
cp "$WAV" "$LAB" "$TMP"
# perform alignment
python align.py ${ARGS[@]:0:$#-2} "$TMP"
# name of output file
TextGrid=$(basename "$WAV" );
TextGrid=${TextGrid%.*}.TextGrid
# move it
mv "$TMP"/"$TextGrid" .
echo "Output in '$TextGrid'."