-
Notifications
You must be signed in to change notification settings - Fork 0
/
compute_capt_accuracy.sh
executable file
·54 lines (44 loc) · 1.88 KB
/
compute_capt_accuracy.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
50
51
52
53
54
#!/usr/bin/env bash
. ./cmd.sh
. ./path.sh
stage=0
phonemap="conf/phones.60-48-39.map"
should_say="data/test_l2_should_say/text"
actual_say="data/test_l2/text"
predict_say=
capt_dir=
. parse_options.sh || exit 1;
if [ -z $predict_say ] || [ -z $capt_dir ]; then
echo "local/compute_capt_accuracy.sh --should_say data/test_l2_should_say/text --actual_say data/test_l2/text --predict_say exp/chain/tdnn1k_sp/decode_test_l2/scoring/4.tra --capt-dir exp/chain/tdnn1k_sp/decode_test_l2/capt"
exit 0;
fi
if [ ! -d $capt_dir ]; then
mkdir -p $capt_dir;
fi
# Map reference to 39 phone classes
if [ $stage -le 0 ]; then
cat $should_say | local/timit_norm_trans.pl -i - -m $phonemap -from 48 -to 39 > $capt_dir/should_say.txt
cat $actual_say | local/timit_norm_trans.pl -i - -m $phonemap -from 48 -to 39 > $capt_dir/actual_say.txt
cat $predict_say | local/timit_norm_trans.pl -i - -m $phonemap -from 48 -to 39 > $capt_dir/predict_say.txt
# remove sil or not?
for fn in $capt_dir/should_say.txt $capt_dir/actual_say.txt $capt_dir/predict_say.txt; do
sed -i "s/sil//g" $fn
done
fi
# Alignment
if [ $stage -le 1 ]; then
# Annotation
align-text --special-symbol="'***'" ark:$capt_dir/should_say.txt ark:$capt_dir/actual_say.txt ark,t:- | \
utils/scoring/wer_per_utt_details.pl --special-symbol "'***'" > $capt_dir/annotation.txt
# Prediction
align-text --special-symbol="'***'" ark:$capt_dir/should_say.txt ark:$capt_dir/predict_say.txt ark,t:- | \
utils/scoring/wer_per_utt_details.pl --special-symbol "'***'" > $capt_dir/prediction.txt
fi
eval "$(/share/homes/teinhonglo/anaconda3/bin/conda shell.bash hook)"
# Performance (recall, precision, and f1)
if [ $stage -le 2 ]; then
# python
python local/compute_capt_accuracy.py --anno $capt_dir/annotation.txt \
--pred $capt_dir/prediction.txt > $capt_dir/results.log
fi
cat $capt_dir/results.log