File: tutorial-check.sh

package info (click to toggle)
sphinxbase 0.8-6
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 9,932 kB
  • ctags: 4,006
  • sloc: ansic: 30,817; sh: 11,330; makefile: 706; cpp: 267; perl: 189; yacc: 93; python: 63; lex: 50
file content (119 lines) | stat: -rwxr-xr-x 3,671 bytes parent folder | download
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash -x

# Check if we're running under PBS and print information useful for debugging
if [ -n "$PBS_ENVIRONMENT" ]; then
    echo ""
    echo "This job was submitted by user: $PBS_O_LOGNAME"
    echo "This job was submitted to host: $PBS_O_HOST"
    echo "This job was submitted to queue: $PBS_O_QUEUE"
    echo "PBS working directory: $PBS_O_WORKDIR"
    echo "PBS job id: $PBS_JOBID"
    echo "PBS job name: $PBS_JOBNAME"
    echo "PBS environment: $PBS_ENVIRONMENT"
    echo ""
    echo "This script is running on `hostname` "
    echo ""
fi

# make sure that /usr/ucb is here, towards the beginning, to make sure
# that the 'ps' command in Solaris is compatible with the gnu one.
export PATH=/usr/ucb:/usr/local/bin:${PATH}

loopUntilSuccess () {
    cmd=$@
    # start loop to download code
    count=0;

    while ! $cmd; do
	count=`expr $count + 1`
	if [ $count -gt 50 ]; then
	    # not successful, and we attempted it too many times. Clean up and leave.
	    return $count
	fi
    done
}

# Check that we have all executables
if ! WGET=`command -v wget 2>&1`; then exit 1; fi
if ! SVN=`command -v svn 2>&1`; then exit 1; fi
if ! PERL=`command -v perl 2>&1`; then exit 1; fi
if ! MAKE=`command -v gmake 2>&1`; then 
  if ! MAKE=`command -v make 2>&1`; then exit 1; fi
fi
if ! TAR=`command -v gtar 2>&1`; then
  if ! TAR=`command -v tar 2>&1`; then exit 1; fi
fi
if ! MAIL=`command -v mhmail 2>&1`; then
  if ! MAIL=`command -v mailx 2>&1`; then
    if ! MAIL=`command -v sendmail 2>&1`; then
      if ! MAIL=`command -v mutt 2>&1`; then exit 1; fi
    fi
  fi
fi

# Create temp directory
temp_dir=/tmp/temp$$
mkdir $temp_dir
pushd $temp_dir > /dev/null

LOG=$temp_dir/log.txt
echo > $LOG
MAILLIST=cmusphinx-results@lists.sourceforge.net

# Get the data
${WGET} -q http://www.speech.cs.cmu.edu/databases/an4/an4_sphere.tar.gz
${TAR} -xzf an4_sphere.tar.gz
/bin/rm an4_sphere.tar.gz

# Get sphinxbase
if (loopUntilSuccess ${SVN} co https://cmusphinx.svn.sourceforge.net/svnroot/cmusphinx/trunk/sphinxbase > /dev/null &&
cd sphinxbase &&
./autogen.sh &&
./autogen.sh CFLAGS="-O2 -Wall" --prefix=`(cd ..; pwd)`/build &&
${MAKE} all install) >> $LOG 2>&1 ; then

# Get the trainer
if (loopUntilSuccess ${SVN} co https://cmusphinx.svn.sourceforge.net/svnroot/cmusphinx/trunk/SphinxTrain > /dev/null &&
cd SphinxTrain &&
./configure CFLAGS="-O2 -Wall" --with-sphinxbase=$temp_dir/sphinxbase && 
${MAKE} && 
${PERL} scripts_pl/setup_tutorial.pl an4) >> $LOG 2>&1 ; then

# Get the decoder
if (loopUntilSuccess ${SVN} co https://cmusphinx.svn.sourceforge.net/svnroot/cmusphinx/trunk/sphinx3 > /dev/null &&
cd sphinx3 &&
./autogen.sh &&
./autogen.sh  CFLAGS="-O2 -Wall" --prefix=`(cd ..; pwd)`/build --with-sphinxbase=$temp_dir/sphinxbase && 
${MAKE} all install && 
${PERL} scripts/setup_tutorial.pl an4) >> $LOG 2>&1 ; then

# Run it
cd an4 &&
perl scripts_pl/make_feats.pl -ctl etc/an4_train.fileids >> $LOG 2>&1 &&
perl scripts_pl/make_feats.pl -ctl etc/an4_test.fileids >> $LOG 2>&1 &&
perl scripts_pl/RunAll.pl >> $LOG 2>&1 &&
perl scripts_pl/decode/slave.pl >> $LOG 2>&1

# end of if (sphinx3)
fi
# end of if (SphinxTrain)
fi
# end of sphinxbase
fi

# Check whether the Word Error Rate is reasonable, hardwired for now
if SER=`grep 'SENTENCE ERROR' $LOG 2>&1`; then
SUCCESS=`echo $SER | awk '{d = $(3) - 57};{if (d < 0) d = -d};{if (d < 2) print "1"}'`;
fi;

# Send mail if we failed
if test x${SUCCESS} == x ; then
cat `find $temp_dir/an4/logdir/ -type f -print | tail -1` >> ${LOG}
$MAIL -s "Tutorial failed" ${MAILLIST} < ${LOG}
else
echo $SER | $MAIL -s "Tutorial succeded" ${MAILLIST}
fi

# Remove what we created
popd > /dev/null
/bin/rm -rf $temp_dir