Debian Codegraph @

tools/flitechecks

raw
1 #!/bin/sh
2 ###########################################################################
3 ## ##
4 ## Language Technologies Institute ##
5 ## Carnegie Mellon University ##
6 ## Copyright (c) 2016 ##
7 ## All Rights Reserved. ##
8 ## ##
9 ## Permission is hereby granted, free of charge, to use and distribute ##
10 ## this software and its documentation without restriction, including ##
11 ## without limitation the rights to use, copy, modify, merge, publish, ##
12 ## distribute, sublicense, and/or sell copies of this work, and to ##
13 ## permit persons to whom this work is furnished to do so, subject to ##
14 ## the following conditions: ##
15 ## 1. The code must retain the above copyright notice, this list of ##
16 ## conditions and the following disclaimer. ##
17 ## 2. Any modifications must be clearly marked as such. ##
18 ## 3. Original authors' names are not deleted. ##
19 ## 4. The authors' names are not used to endorse or promote products ##
20 ## derived from this software without specific prior written ##
21 ## permission. ##
22 ## ##
23 ## CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK ##
24 ## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
25 ## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
26 ## SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE ##
27 ## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
28 ## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
29 ## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
30 ## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
31 ## THIS SOFTWARE. ##
32 ## ##
33 ###########################################################################
34 ## ##
35 ## Run tests for flite front ends ##
36 ## ##
37 ## flitechecks VOICE.flitechecks tests/tamil.flitecheck ##
38 ## ##
39 ###########################################################################
40
41 LANG=C; export LANG
42
43 if [ $# != 2 ]
44 then
45 echo "flitecheck VOICE.flitevox [TESTFILE.flitecheck]"
46 echo "if TESTFILE.flitecheck isn't give it will guess one from the library"
47 exit 1
48 fi
49
50 FLITE=$FLITEDIR/bin/flite
51 VOICE=$1
52 FC=$2
53
54 rm -f test.out.$$
55
56 cat $2 |
57 while read x
58 do
59 if [ "$x" = "INPUT" ]
60 then
61 read y
62 echo $y >fc.input.$$
63 fi
64 if [ "$x" = "OUTPUT" ]
65 then
66 read y
67 echo $y >fc.output.$$
68 fi
69 if [ "$x" = "PARAMS" ]
70 then
71 read PARAMS
72 fi
73 if [ "$x" = "TEST" ]
74 then
75 read TESTNAME
76 echo RUNNING TEST: $TESTNAME
77 fi
78 if [ "$x" = "DOIT" ]
79 then
80 echo TEST $TESTNAME >>fc.test.out.$$
81 $FLITE -voice $VOICE $PARAMS -f fc.input.$$ none >fc.output.real.$$
82 cat fc.input.$$ >>fc.test.out.$$
83 cat fc.output.$$ >>fc.test.out.$$
84 if diff -b fc.output.$$ fc.output.real.$$ >&2 >>fc.test.out.$$
85 then
86 echo TEST OKAY >>fc.test.out.$$
87 else
88 diff -b fc.output.$$ fc.output.real.$$
89 echo TEST NOT OKAY >>fc.test.out.$$
90 fi
91 fi
92 done
93
94 #
95 # Print out summary of tests
96 #
97 cat fc.test.out.$$ |
98 awk 'BEGIN { correct=0; total=0; wrong=0; }
99 {if ($1 == "TEST")
100 {
101 if ($NF == "OKAY")
102 {
103 if ($2 == "NOT")
104 {
105 wrong = wrong+1;
106 printf("FAILED: %s\n",testdescription);
107 }
108 else if ($2 == "OKAY")
109 {
110 correct = correct+1;
111 }
112 }
113 else
114 {
115 total=total+1;
116 testdescription = $0;
117 }
118 }}
119 END {if (correct == total)
120 printf("100%% correct ( %d / %d )\n",correct,total);
121 else
122 {
123 printf("%0.2f%% wrong ( %d / %d )\n",(wrong*100.0)/total,wrong,total);
124 printf("%0.2f%% correct ( %d / %d )\n",(correct*100.0)/total,correct,total);
125 }}'
126
127 rm -f fc.input.$$ fc.output.$$ fc.test.out.$$ fc.output.real.$$