Commit 6db49dab669240bb1584c51a8979070935faee2b

Authored by Jean-François Rey
1 parent 630a18786e
Exists in master

bugfix arguments

Showing 3 changed files with 13 additions and 13 deletions Inline Diff

main_tools/ConfPass.sh
1 #!/bin/bash 1 #!/bin/bash
2 2
3 ##################################################### 3 #####################################################
4 # File : ConfPass.sh # 4 # File : ConfPass.sh #
5 # Brief : Process the ASR Confidence pass # 5 # Brief : Process the ASR Confidence pass #
6 # Author : Jean-François Rey # 6 # Author : Jean-François Rey #
7 # (base on Emmanuel Ferreira # 7 # (base on Emmanuel Ferreira #
8 # and hugo Mauchrétien works) # 8 # and hugo Mauchrétien works) #
9 # Version : 1.0 # 9 # Version : 1.0 #
10 # Date : 17/06/13 # 10 # Date : 17/06/13 #
11 ##################################################### 11 #####################################################
12 12
13 echo "### ConfPass.sh ###" 13 echo "### ConfPass.sh ###"
14 14
15 #Check OTMEDIA_HOME env var 15 #Check OTMEDIA_HOME env var
16 if [ -z ${OTMEDIA_HOME} ] 16 if [ -z ${OTMEDIA_HOME} ]
17 then 17 then
18 OTMEDIA_HOME=$(dirname $(dirname $(readlink -e $0))) 18 OTMEDIA_HOME=$(dirname $(dirname $(readlink -e $0)))
19 export OTMEDIA_HOME=$OTMEDIA_HOME 19 export OTMEDIA_HOME=$OTMEDIA_HOME
20 fi 20 fi
21 21
22 22
23 # where is ConfPath.sh 23 # where is ConfPath.sh
24 MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0)) 24 MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0))
25 25
26 # Scripts Path 26 # Scripts Path
27 SCRIPT_PATH=$OTMEDIA_HOME/tools/scripts 27 SCRIPT_PATH=$OTMEDIA_HOME/tools/scripts
28 28
29 # Include scripts 29 # Include scripts
30 . $SCRIPT_PATH"/Tools.sh" 30 . $SCRIPT_PATH"/Tools.sh"
31 . $SCRIPT_PATH"/CheckConfPass.sh" 31 . $SCRIPT_PATH"/CheckConfPass.sh"
32 32
33 # where is FirstPass.cfg 33 # where is FirstPass.cfg
34 CONFPASS_CONFIG_FILE="$OTMEDIA_HOME/cfg/ConfPass.cfg" 34 CONFPASS_CONFIG_FILE="$OTMEDIA_HOME/cfg/ConfPass.cfg"
35 if [ -e $CONFPASS_CONFIG_FILE ] 35 if [ -e $CONFPASS_CONFIG_FILE ]
36 then 36 then
37 . $CONFPASS_CONFIG_FILE 37 . $CONFPASS_CONFIG_FILE
38 else 38 else
39 echo "ERROR : Can't find configuration file $CONFPASS_CONFIG_FILE" >&2 39 echo "ERROR : Can't find configuration file $CONFPASS_CONFIG_FILE" >&2
40 exit 1 40 exit 1
41 fi 41 fi
42 42
43 #---------------# 43 #---------------#
44 # Parse Options # 44 # Parse Options #
45 #---------------# 45 #---------------#
46 while getopts ":hDv:cr" opt 46 while getopts ":hDv:cr" opt
47 do 47 do
48 case $opt in 48 case $opt in
49 h) 49 h)
50 echo -e "$0 [OPTIONS] <INPUT_DIRECTORY> <TREIL_DIRECTORY_NAME>\n" 50 echo -e "$0 [OPTIONS] <INPUT_DIRECTORY> <TREIL_DIRECTORY_NAME>\n"
51 echo -e "\t Options:" 51 echo -e "\t Options:"
52 echo -e "\t\t-h :\tprint this message" 52 echo -e "\t\t-h :\tprint this message"
53 echo -e "\t\t-D :\tDEBUG mode on" 53 echo -e "\t\t-D :\tDEBUG mode on"
54 echo -e "\t\t-v l :\tVerbose mode, l=(1|2|3) level mode" 54 echo -e "\t\t-v l :\tVerbose mode, l=(1|2|3) level mode"
55 echo -e "\t\t-c :\t Check process, stop if error detected" 55 echo -e "\t\t-c :\t Check process, stop if error detected"
56 echo -e "\t\t-r :\tForce to rerun confpas without deleting existing files" 56 echo -e "\t\t-r :\tForce to rerun confpas without deleting existing files"
57 exit 1 57 exit 1
58 ;; 58 ;;
59 D) 59 D)
60 DEBUG=1 60 DEBUG=1
61 ;; 61 ;;
62 v) 62 v)
63 VERBOSE=$OPTARG 63 VERBOSE=$OPTARG
64 ;; 64 ;;
65 c) 65 c)
66 CHECK=1 66 CHECK=1
67 ;; 67 ;;
68 r) 68 r)
69 RERUN=1 69 RERUN=1
70 ;; 70 ;;
71 :) 71 :)
72 echo "Option -$OPTARG requires an argument." >&2 72 echo "Option -$OPTARG requires an argument." >&2
73 exit 1 73 exit 1
74 ;; 74 ;;
75 \?) 75 \?)
76 echo "BAD USAGE : unknow opton -$OPTARG" 76 echo "BAD USAGE : unknow option -$OPTARG"
77 #exit 1 77 #exit 1
78 ;; 78 ;;
79 esac 79 esac
80 done 80 done
81 81
82 # mode debug enable 82 # mode debug enable
83 if [ $DEBUG -eq 1 ] 83 if [ $DEBUG -eq 1 ]
84 then 84 then
85 set -x 85 set -x
86 echo -e "## Mode DEBUG ON ##" 86 echo -e "## Mode DEBUG ON ##"
87 fi 87 fi
88 88
89 # mode verbose enable 89 # mode verbose enable
90 if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ;fi 90 if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ;fi
91 91
92 # Check USAGE by arguments number 92 # Check USAGE by arguments number
93 if [ $(($#-($OPTIND-1))) -ne 2 ] 93 if [ $(($#-($OPTIND-1))) -ne 2 ]
94 then 94 then
95 echo "BAD USAGE : ConfPass.sh [OPTIONS] <INPUT_DIR> <TREIL_DIRECTORY_NAME>" 95 echo "BAD USAGE : ConfPass.sh [OPTIONS] <INPUT_DIR> <TREIL_DIRECTORY_NAME>"
96 echo "$0 -h for more info" 96 echo "$0 -h for more info"
97 exit 1 97 exit 1
98 fi 98 fi
99 99
100 shift $((OPTIND-1)) 100 shift $((OPTIND-1))
101 # check input directory - first argument 101 # check input directory - first argument
102 if [ ! -e $1 ] 102 if [ ! -e $1 ]
103 then 103 then
104 print_error "can't open $1" 104 print_error "can't open $1"
105 exit 1 105 exit 1
106 fi 106 fi
107 # check treil input directory - second argument 107 # check treil input directory - second argument
108 if [ ! -e $1/$2 ] 108 if [ ! -e $1/$2 ]
109 then 109 then
110 print_error "can't open $1/$2" 110 print_error "can't open $1/$2"
111 exit 1 111 exit 1
112 fi 112 fi
113 113
114 print_info "[${BASENAME}] => Conf Pass start | $(date +'%d/%m/%y %H:%M:%S')" 1 114 print_info "[${BASENAME}] => Conf Pass start | $(date +'%d/%m/%y %H:%M:%S')" 1
115 115
116 #-------------# 116 #-------------#
117 # GLOBAL VARS # 117 # GLOBAL VARS #
118 #-------------# 118 #-------------#
119 INPUT_DIR=$(readlink -e $1) 119 INPUT_DIR=$(readlink -e $1)
120 OUTPUT_DIR=$INPUT_DIR 120 OUTPUT_DIR=$INPUT_DIR
121 BASENAME=$(basename $OUTPUT_DIR) 121 BASENAME=$(basename $OUTPUT_DIR)
122 RES_NAME=$2 122 RES_NAME=$2
123 RES_P="${INPUT_DIR}/${RES_NAME}" 123 RES_P="${INPUT_DIR}/${RES_NAME}"
124 USF_FILE=${INPUT_DIR}/${BASENAME}.${RES_NAME}.usf 124 USF_FILE=${INPUT_DIR}/${BASENAME}.${RES_NAME}.usf
125 CONF_DIR="$OUTPUT_DIR/conf/$RES_NAME" 125 CONF_DIR="$OUTPUT_DIR/conf/$RES_NAME"
126 RES_CONF_DIR="$OUTPUT_DIR/conf/$RES_NAME/scored_ctm" 126 RES_CONF_DIR="$OUTPUT_DIR/conf/$RES_NAME/scored_ctm"
127 LOGFILE="${OUTPUT_DIR_BASENAME}/info_conf.log" 127 LOGFILE="${OUTPUT_DIR_BASENAME}/info_conf.log"
128 ERRORFILE="${OUTPUT_DIR_BASENAME}/error_conf.log" 128 ERRORFILE="${OUTPUT_DIR_BASENAME}/error_conf.log"
129 129
130 #------------------# 130 #------------------#
131 # Create Workspace # 131 # Create Workspace #
132 #------------------# 132 #------------------#
133 # Lock directory 133 # Lock directory
134 if [ -e "$OUTPUT_DIR/CONFPASS.lock" ] && [ $RERUN -eq 0 ] 134 if [ -e "$OUTPUT_DIR/CONFPASS.lock" ] && [ $RERUN -eq 0 ]
135 then 135 then
136 print_warn "[${BASENAME}] Confpass is locked -> exit" 2 136 print_warn "[${BASENAME}] Confpass is locked -> exit" 2
137 exit 1 137 exit 1
138 fi 138 fi
139 rm "$OUTPUT_DIR/CONFPASS.unlock" > /dev/null 2>&1 139 rm "$OUTPUT_DIR/CONFPASS.unlock" > /dev/null 2>&1
140 touch "$OUTPUT_DIR/CONFPASS.lock" > /dev/null 2>&1 140 touch "$OUTPUT_DIR/CONFPASS.lock" > /dev/null 2>&1
141 if [ $RERUN -eq 0 ]; then rm -r $CONF_DIR > /dev/null 2>&1; fi 141 if [ $RERUN -eq 0 ]; then rm -r $CONF_DIR > /dev/null 2>&1; fi
142 if [ $RERUN -eq 1 ]; then rm $USF_FILE > /dev/null 2>&1; fi 142 if [ $RERUN -eq 1 ]; then rm $USF_FILE > /dev/null 2>&1; fi
143 mkdir -p $CONF_DIR > /dev/null 2>&1 143 mkdir -p $CONF_DIR > /dev/null 2>&1
144 mkdir -p $RES_CONF_DIR > /dev/null 2>&1 144 mkdir -p $RES_CONF_DIR > /dev/null 2>&1
145 rm $LOGFILE $ERRORFILE > /dev/null 2>&1 145 rm $LOGFILE $ERRORFILE > /dev/null 2>&1
146 146
147 #---------------# 147 #---------------#
148 # Check Pass # 148 # Check Pass #
149 #---------------# 149 #---------------#
150 print_info "[${BASENAME}] Check Conf Pass directory ${RES_NAME}" 1 150 print_info "[${BASENAME}] Check Conf Pass directory ${RES_NAME}" 1
151 # if usf contains more than 49% of 0.600 confidence -> usf error 151 # if usf contains more than 49% of 0.600 confidence -> usf error
152 if [ -s $USF_FILE ] 152 if [ -s $USF_FILE ]
153 then 153 then
154 conftozerosix=$(grep -c -E 'confidence="0.600"' "${USF_FILE}") 154 conftozerosix=$(grep -c -E 'confidence="0.600"' "${USF_FILE}")
155 confall=$(grep -c -E 'confidence=' "${USF_FILE}") 155 confall=$(grep -c -E 'confidence=' "${USF_FILE}")
156 if [ $confall -gt 0 ] 156 if [ $confall -gt 0 ]
157 then 157 then
158 pourcentageofzerosix=$((($conftozerosix*100)/$confall)) 158 pourcentageofzerosix=$((($conftozerosix*100)/$confall))
159 if [ $pourcentageofzerosix -gt 49 ] 159 if [ $pourcentageofzerosix -gt 49 ]
160 then 160 then
161 print_warn "[${BASENAME}] ${BASENAME}.${RES_NAME}.usf got $pourcentageofzerosix% of 0.600 confidence" 2 161 print_warn "[${BASENAME}] ${BASENAME}.${RES_NAME}.usf got $pourcentageofzerosix% of 0.600 confidence" 2
162 print_info "[${BASENAME}] bad usf ${RES_NAME}, will do it again" 1 162 print_info "[${BASENAME}] bad usf ${RES_NAME}, will do it again" 1
163 mv "${USF_FILE}" "${USF_FILE}.back" 163 mv "${USF_FILE}" "${USF_FILE}.back"
164 rm -r $CONF_DIR > /dev/null 2>&1 164 rm -r $CONF_DIR > /dev/null 2>&1
165 else 165 else
166 print_warn "[${BASENAME}] ${USF_FILE} already done, skipping it" 1 166 print_warn "[${BASENAME}] ${USF_FILE} already done, skipping it" 1
167 exit 0 167 exit 0
168 fi 168 fi
169 fi 169 fi
170 else 170 else
171 print_info "[${BASENAME}] No USF file already done, continue..." 1 171 print_info "[${BASENAME}] No USF file already done, continue..." 1
172 fi 172 fi
173 173
174 # Check if treil are here 174 # Check if treil are here
175 nbres_p1=$(cat ${INPUT_DIR}/plp.lst | wc -l) 175 nbres_p1=$(cat ${INPUT_DIR}/plp.lst | wc -l)
176 nbtreil_p=$(ls $RES_P/*.treil 2> /dev/null | wc -l) 176 nbtreil_p=$(ls $RES_P/*.treil 2> /dev/null | wc -l)
177 if [ $nbtreil_p -eq 0 ] 177 if [ $nbtreil_p -eq 0 ]
178 then 178 then
179 print_error "[${BASENAME}] No ${RES_NAME} Pass, No .treil -> exit ConfPass" 179 print_error "[${BASENAME}] No ${RES_NAME} Pass, No .treil -> exit ConfPass"
180 if [ $CHECK -eq 1 ]; then print_log_file $ERRORFILE "No ${RES_NAME} Pass, No .treil -> exit ConfPass" ;fi 180 if [ $CHECK -eq 1 ]; then print_log_file $ERRORFILE "No ${RES_NAME} Pass, No .treil -> exit ConfPass" ;fi
181 exit 1 181 exit 1
182 else 182 else
183 #Check if more then 89% of treil are done 183 #Check if more then 89% of treil are done
184 if [ $nbres_p1 -gt 0 ] 184 if [ $nbres_p1 -gt 0 ]
185 then 185 then
186 pourcentage=$((($nbtreil_p*100)/$nbres_p1)) 186 pourcentage=$((($nbtreil_p*100)/$nbres_p1))
187 if [ $pourcentage -gt 89 ] 187 if [ $pourcentage -gt 89 ]
188 then 188 then
189 print_info "[${BASENAME}] ${RES_NAME}/*.treil are here" 1 189 print_info "[${BASENAME}] ${RES_NAME}/*.treil are here" 1
190 else 190 else
191 print_warn "[${BASENAME}] not enough ${RES_NAME} treil" 2 191 print_warn "[${BASENAME}] not enough ${RES_NAME} treil" 2
192 if [ $CHECK -eq 1 ]; then print_log_file $ERRORFILE "Not enough ${RES_NAME} treil " 192 if [ $CHECK -eq 1 ]; then print_log_file $ERRORFILE "Not enough ${RES_NAME} treil "
193 fi 193 fi
194 fi 194 fi
195 fi 195 fi
196 196
197 #------# 197 #------#
198 # Save # 198 # Save #
199 #------# 199 #------#
200 cp $CONFPASS_CONFIG_FILE $OUTPUT_DIR/ConfPass.cfg 200 cp $CONFPASS_CONFIG_FILE $OUTPUT_DIR/ConfPass.cfg
201 echo "RES_CONF_DIR=$RES_CONF_DIR" >> $OUTPUT_DIR/ConfPass.cfg 201 echo "RES_CONF_DIR=$RES_CONF_DIR" >> $OUTPUT_DIR/ConfPass.cfg
202 echo "CONF_DIR=$CONF_DIR" >> $OUTPUT_DIR/ConfPass.cfg 202 echo "CONF_DIR=$CONF_DIR" >> $OUTPUT_DIR/ConfPass.cfg
203 print_info "[${BASENAME}] Save config in $OUTPUT_DIR_BASENAME/ConfPass.cfg" 1 203 print_info "[${BASENAME}] Save config in $OUTPUT_DIR_BASENAME/ConfPass.cfg" 1
204 204
205 #--------------------# 205 #--------------------#
206 # CONFIDENCE MEASURE # 206 # CONFIDENCE MEASURE #
207 #--------------------# 207 #--------------------#
208 208
209 # Check pourcentage of scored_ctm already done, if < 85% do confidence measure 209 # Check pourcentage of scored_ctm already done, if < 85% do confidence measure
210 nbres_p=$(ls ${RES_P}/*.treil | wc -l) 210 nbres_p=$(ls ${RES_P}/*.treil | wc -l)
211 nbconf=$(ls ${RES_CONF_DIR}/*.res | wc -l) 211 nbconf=$(ls ${RES_CONF_DIR}/*.res | wc -l)
212 if [ $nbres_p -gt 0 ] 212 if [ $nbres_p -gt 0 ]
213 then 213 then
214 pourcentageres=$((($nbconf*100)/$nbres_p)) 214 pourcentageres=$((($nbconf*100)/$nbres_p))
215 if [ $pourcentageres -lt 85 ] 215 if [ $pourcentageres -lt 85 ]
216 then 216 then
217 print_info "[${BASENAME}] Calcul Confidence $INPUT_DIR $RES_NAME" 1 217 print_info "[${BASENAME}] Calcul Confidence $INPUT_DIR $RES_NAME" 1
218 $MAIN_SCRIPT_PATH/ConfidenceMeasure.sh $INPUT_DIR $RES_NAME 218 $MAIN_SCRIPT_PATH/ConfidenceMeasure.sh $INPUT_DIR $RES_NAME
219 219
220 else 220 else
221 print_info "[${BASENAME}] Skipping Confidence Calcul $INPUT_DIR/$RES_NAME" 1 221 print_info "[${BASENAME}] Skipping Confidence Calcul $INPUT_DIR/$RES_NAME" 1
222 fi 222 fi
223 fi 223 fi
224 224
225 ### Check scored_ctm number res files ! 225 ### Check scored_ctm number res files !
226 if [ $CHECK -eq 1 ] 226 if [ $CHECK -eq 1 ]
227 then 227 then
228 nbconf=$(ls ${RES_CONF_DIR}/*.res | wc -l) 228 nbconf=$(ls ${RES_CONF_DIR}/*.res | wc -l)
229 if [ $nbres_p -ne $nbconf ] 229 if [ $nbres_p -ne $nbconf ]
230 then 230 then
231 print_warn "WARN : ConfPass $INPUT_DIR/$RES_NAME number of res files differ" 2 231 print_warn "WARN : ConfPass $INPUT_DIR/$RES_NAME number of res files differ" 2
232 print_log_file $LOGFILE "WARN : ConfPass $INPUT_DIR/$RES_NAME number of res files differ" 232 print_log_file $LOGFILE "WARN : ConfPass $INPUT_DIR/$RES_NAME number of res files differ"
233 fi 233 fi
234 fi 234 fi
235 235
236 #---------------------------# 236 #---------------------------#
237 # FROM RES WITH CONF => USF # 237 # FROM RES WITH CONF => USF #
238 #---------------------------# 238 #---------------------------#
239 print_info "[${BASENAME}] Create USF file for $RES_P" 1 239 print_info "[${BASENAME}] Create USF file for $RES_P" 1
240 for f in `ls ${RES_CONF_DIR}`; do $SCRIPT_PATH/formatRES.pl $RES_CONF_DIR/$f; done 240 for f in `ls ${RES_CONF_DIR}`; do $SCRIPT_PATH/formatRES.pl $RES_CONF_DIR/$f; done
241 # create USF configuration file 241 # create USF configuration file
242 echo -e "name $AUTHOR\nfileName $BASENAME\nfileExt wav\nsegFile $OUTPUT_DIR/$BASENAME.seg" > $OUTPUT_DIR/$BASENAME.usf_cfg 242 echo -e "name $AUTHOR\nfileName $BASENAME\nfileExt wav\nsegFile $OUTPUT_DIR/$BASENAME.seg" > $OUTPUT_DIR/$BASENAME.usf_cfg
243 # create USF file 243 # create USF file
244 print_info "$SCRIPT_PATH/res2out.pl --dir $RES_CONF_DIR --format USF --ignore $RULES/asupp --out $USF_FILE.tmp --usf_config $OUTPUT_DIR/$BASENAME.usf_cfg" 3 244 print_info "$SCRIPT_PATH/res2out.pl --dir $RES_CONF_DIR --format USF --ignore $RULES/asupp --out $USF_FILE.tmp --usf_config $OUTPUT_DIR/$BASENAME.usf_cfg" 3
245 $SCRIPT_PATH/res2out.pl --dir $RES_CONF_DIR --format USF --ignore $RULES/asupp --out $USF_FILE.tmp --usf_config $OUTPUT_DIR/$BASENAME.usf_cfg 245 $SCRIPT_PATH/res2out.pl --dir $RES_CONF_DIR --format USF --ignore $RULES/asupp --out $USF_FILE.tmp --usf_config $OUTPUT_DIR/$BASENAME.usf_cfg
246 rm $OUTPUT_DIR/$BASENAME.usf_cfg > /dev/null 2>&1 246 rm $OUTPUT_DIR/$BASENAME.usf_cfg > /dev/null 2>&1
247 cat $USF_FILE.tmp | $SCRIPT_PATH/BdlexUC.pl $RULES/basic -f > $USF_FILE 247 cat $USF_FILE.tmp | $SCRIPT_PATH/BdlexUC.pl $RULES/basic -f > $USF_FILE
248 cp $USF_FILE ${OUTPUT_DIR}/${BASENAME}.usf 248 cp $USF_FILE ${OUTPUT_DIR}/${BASENAME}.usf
249 rm $USF_FILE.tmp > /dev/null 2>&1 249 rm $USF_FILE.tmp > /dev/null 2>&1
250 250
251 #----------------# 251 #----------------#
252 # Check USF file # 252 # Check USF file #
253 #----------------# 253 #----------------#
254 if [ $CHECK -eq 1 ] 254 if [ $CHECK -eq 1 ]
255 then 255 then
256 check_conf_pass_usf "$OUTPUT_DIR/$BASENAME.usf" 256 check_conf_pass_usf "$OUTPUT_DIR/$BASENAME.usf"
257 if [ $? -eq 1 ] 257 if [ $? -eq 1 ]
258 then 258 then
259 print_error "[${BASENAME}] Wrong confidence measures in USF file : $OUTPUT_DIR/$BASENAME.usf" 259 print_error "[${BASENAME}] Wrong confidence measures in USF file : $OUTPUT_DIR/$BASENAME.usf"
260 print_log_file $ERRORFILE "ERROR : Wrong confidence measures in USF file : $OUTPUT_DIR/$BASENAME.usf" 260 print_log_file $ERRORFILE "ERROR : Wrong confidence measures in USF file : $OUTPUT_DIR/$BASENAME.usf"
261 exit 1 261 exit 1
262 fi 262 fi
263 fi 263 fi
264 264
265 #-------# 265 #-------#
266 # CLOSE # 266 # CLOSE #
267 #-------# 267 #-------#
268 # Seem OK 268 # Seem OK
269 print_info "[${BASENAME}] <= ConfPass End | $(date +'%d/%m/%y %H:%M:%S')" 1 269 print_info "[${BASENAME}] <= ConfPass End | $(date +'%d/%m/%y %H:%M:%S')" 1
270 270
271 # unlock directory 271 # unlock directory
272 mv "$OUTPUT_DIR/CONFPASS.lock" "$OUTPUT_DIR/CONFPASS.unlock" 272 mv "$OUTPUT_DIR/CONFPASS.lock" "$OUTPUT_DIR/CONFPASS.unlock"
273 273
274 274
main_tools/OneScriptToRuleThemAll.sh
1 #!/bin/bash 1 #!/bin/bash
2 2
3 ##################################### 3 #####################################
4 # File: OneScriptToRuleThemAll.sh # 4 # File: OneScriptToRuleThemAll.sh #
5 # Brief : Script to launch OTMEDIA # 5 # Brief : Script to launch OTMEDIA #
6 # Version : 1.0 # 6 # Version : 1.0 #
7 # Date : 23/07/2013 # 7 # Date : 23/07/2013 #
8 # Author : Jean-François Rey # 8 # Author : Jean-François Rey #
9 ##################################### 9 #####################################
10 10
11 # Color variables 11 # Color variables
12 txtgrn=$(tput setaf 2) # Green 12 txtgrn=$(tput setaf 2) # Green
13 txtylw=$(tput setaf 3) # Yellow 13 txtylw=$(tput setaf 3) # Yellow
14 txtblu=$(tput setaf 4) # Blue 14 txtblu=$(tput setaf 4) # Blue
15 txtpur=$(tput setaf 5) # Purple 15 txtpur=$(tput setaf 5) # Purple
16 txtcyn=$(tput setaf 6) # Cyan 16 txtcyn=$(tput setaf 6) # Cyan
17 txtwht=$(tput setaf 7) # White 17 txtwht=$(tput setaf 7) # White
18 txtrst=$(tput sgr0) # Text reset. 18 txtrst=$(tput sgr0) # Text reset.
19 #/color 19 #/color
20 20
21 21
22 echo -e "#### OneScriptToRuleThemAll ####" 22 echo -e "#### OneScriptToRuleThemAll ####"
23 LORD=" Three::rings 23 LORD=" Three::rings
24 for:::the::Elven-King 24 for:::the::Elven-King
25 under:the:sky,:Seven:for:the 25 under:the:sky,:Seven:for:the
26 Dwarf-Lords::in::their::halls:of 26 Dwarf-Lords::in::their::halls:of
27 stone,:Nine for:Mortal 27 stone,:Nine for:Mortal
28 :::Men::: ________ doomed::to 28 :::Men::: ________ doomed::to
29 die.:One _,-'...:... \`-. for:::the 29 die.:One _,-'...:... \`-. for:::the
30 ::Dark:: ,- .:::::::::::. \`. Lord::on 30 ::Dark:: ,- .:::::::::::. \`. Lord::on
31 his:dark ,' .:::::zzz:::::. \`. :throne: 31 his:dark ,' .:::::zzz:::::. \`. :throne:
32 In:::the/ ::::${txtpur}OTMEDIA${txtrst}:::: \ Land::of 32 In:::the/ ::::${txtpur}OTMEDIA${txtrst}:::: \ Land::of
33 :Mordor:\ ::::${txtpur}SCRIPTS${txtrst}:::: / :where:: 33 :Mordor:\ ::::${txtpur}SCRIPTS${txtrst}:::: / :where::
34 ::the::: '. '::::YEEEP::::' ,' Shadows: 34 ::the::: '. '::::YEEEP::::' ,' Shadows:
35 lie.::One \`. \`\`:::::::::'' ,' Ring::to 35 lie.::One \`. \`\`:::::::::'' ,' Ring::to
36 ::rule:: \`-._\`\`\`:'''_,-' ::them:: 36 ::rule:: \`-._\`\`\`:'''_,-' ::them::
37 all,::One \`-----' ring::to 37 all,::One \`-----' ring::to
38 ::find::: them,:One 38 ::find::: them,:One
39 Ring:::::to bring::them 39 Ring:::::to bring::them
40 all::and::in:the:darkness:bind 40 all::and::in:the:darkness:bind
41 them:In:the:Land:of:Mordor 41 them:In:the:Land:of:Mordor
42 where:::the::Shadows 42 where:::the::Shadows
43 :::lie.:::" 43 :::lie.:::"
44 44
45 45
46 # Check OTMEDIA_HOME env var 46 # Check OTMEDIA_HOME env var
47 if [ -z ${OTMEDIA_HOME} ] 47 if [ -z ${OTMEDIA_HOME} ]
48 then 48 then
49 OTMEDIA_HOME=$(dirname $(dirname $(readlink -e $0))) 49 OTMEDIA_HOME=$(dirname $(dirname $(readlink -e $0)))
50 export OTMEDIA_HOME=$OTMEDIA_HOME 50 export OTMEDIA_HOME=$OTMEDIA_HOME
51 fi 51 fi
52 52
53 # where is OneScriptToRuleThemAll.sh 53 # where is OneScriptToRuleThemAll.sh
54 MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0)) 54 MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0))
55 55
56 RING="" 56 RING=""
57 p1=0 57 p1=0
58 p2=0 58 p2=0
59 conf=0 59 conf=0
60 exploitconf=0 60 exploitconf=0
61 p3=0 61 p3=0
62 recompose=0 62 recompose=0
63 scoring=0 63 scoring=0
64 64
65 #---------------# 65 #---------------#
66 # Parse Options # 66 # Parse Options #
67 #---------------# 67 #---------------#
68 while getopts ":hDv:cf:r123CeRsa" opt 68 while getopts ":hDv:cf:r123C:eRsa" opt
69 do 69 do
70 case $opt in 70 case $opt in
71 h) 71 h)
72 echo -e "$0 [OPTIONS] <WAV_FILE> <OUTPUT_DIRECTORY>\n" 72 echo -e "$0 [OPTIONS] <WAV_FILE> <OUTPUT_DIRECTORY>\n"
73 echo -e "\t Options:" 73 echo -e "\t Options:"
74 echo -e "\t\t-h :\tprint this message" 74 echo -e "\t\t-h :\tprint this message"
75 echo -e "\t\t-D :\tDEBUG mode on" 75 echo -e "\t\t-D :\tDEBUG mode on"
76 echo -e "\t\t-v l :\tVerbose mode, l=(1|2|3) level mode" 76 echo -e "\t\t-v l :\tVerbose mode, l=(1|2|3) level mode"
77 echo -e "\t\t-c :\tCheck process, stop if error detected" 77 echo -e "\t\t-c :\tCheck process, stop if error detected"
78 echo -e "\t\t-f n :\tSpecify a speeral forks number (default 1)" 78 echo -e "\t\t-f n :\tSpecify a speeral forks number (default 1)"
79 echo -e "\t\t-r :\tForce to rerun without deleting all files" 79 echo -e "\t\t-r :\tForce to rerun without deleting all files"
80 echo -e "\t\t-a :\tDo every pass" 80 echo -e "\t\t-a :\tDo every pass"
81 echo -e "\t\t-1 :\tDo 1rt pass" 81 echo -e "\t\t-1 :\tDo 1rt pass"
82 echo -e "\t\t-2 :\tDo 2nd pass" 82 echo -e "\t\t-2 :\tDo 2nd pass"
83 echo -e "\t\t-3 :\tDo 3rd pass" 83 echo -e "\t\t-3 :\tDo 3rd pass"
84 echo -e "\t\t-C :\tDo confidence pass" 84 echo -e "\t\t-C p :\tDo p confidence pass (1=all, 2 or 3)"
85 echo -e "\t\t-e :\tDo exploit confidence pass (SOLR)" 85 echo -e "\t\t-e :\tDo exploit confidence pass (SOLR)"
86 echo -e "\t\t-R :\tDo recompose res" 86 echo -e "\t\t-R :\tDo recompose res"
87 echo -e "\t\t-s :\tDo scoring" 87 echo -e "\t\t-s :\tDo scoring"
88 exit 1 88 exit 1
89 ;; 89 ;;
90 D) 90 D)
91 RING=$RING" -D" 91 RING=$RING" -D"
92 ;; 92 ;;
93 v) 93 v)
94 RING=$RING" -v $OPTARG" 94 RING=$RING" -v $OPTARG"
95 ;; 95 ;;
96 c) 96 c)
97 RING=$RING" -c" 97 RING=$RING" -c"
98 ;; 98 ;;
99 f) 99 f)
100 RING=$RING" -f $OPTARG" 100 FORKS=" -f $OPTARG"
101 ;; 101 ;;
102 r) 102 r)
103 RING=$RING" -r" 103 RING=$RING" -r"
104 ;; 104 ;;
105 a) 105 a)
106 p1=1 106 p1=1
107 p2=1 107 p2=1
108 p3=1 108 p3=1
109 conf=1 109 conf=1
110 exploitconf=1 110 exploitconf=1
111 recompose=1 111 recompose=1
112 scoring=1 112 scoring=1
113 ;; 113 ;;
114 1) 114 1)
115 p1=1 115 p1=1
116 ;; 116 ;;
117 2) 117 2)
118 p2=1 118 p2=1
119 ;; 119 ;;
120 3) 120 3)
121 p3=1 121 p3=1
122 ;; 122 ;;
123 C) 123 C)
124 conf=1 124 conf=$OPTARG
125 ;; 125 ;;
126 e) 126 e)
127 exploitconf=1 127 exploitconf=1
128 ;; 128 ;;
129 a) 129 a)
130 recompose=1 130 recompose=1
131 ;; 131 ;;
132 s) 132 s)
133 scoring=1 133 scoring=1
134 ;; 134 ;;
135 :) 135 :)
136 echo "Option -$OPTARG requires an argument." >&2 136 echo "Option -$OPTARG requires an argument." >&2
137 exit 1 137 exit 1
138 ;; 138 ;;
139 \?) 139 \?)
140 echo "BAD USAGE : unknow opton -$OPTARG" 140 echo "BAD USAGE : unknow opton -$OPTARG"
141 exit 1 141 exit 1
142 ;; 142 ;;
143 esac 143 esac
144 done 144 done
145 145
146 # Check USAGE by arguments number 146 # Check USAGE by arguments number
147 if [ $(($#-($OPTIND-1))) -ne 2 ] 147 if [ $(($#-($OPTIND-1))) -ne 2 ]
148 then 148 then
149 echo "BAD USAGE : $0 [OPTIONS] <WAV_FILE> <OUTPUT_DIR>" 149 echo "BAD USAGE : $0 [OPTIONS] <WAV_FILE> <OUTPUT_DIR>"
150 echo "$0 -h for more info" 150 echo "$0 -h for more info"
151 exit 1 151 exit 1
152 fi 152 fi
153 153
154 shift $((OPTIND-1)) 154 shift $((OPTIND-1))
155 # check audio file - First argument 155 # check audio file - First argument
156 if [ -e $1 ] && [ -s $1 ] 156 if [ -e $1 ] && [ -s $1 ]
157 then 157 then
158 echo -e "$LORD\n" 158 echo -e "$LORD\n"
159 REP_OUT=$2/$(basename ${1%.*}) 159 REP_OUT=$2/$(basename ${1%.*})
160 if [ $p1 -eq 1 ];then ${MAIN_SCRIPT_PATH}/FirstPass.sh ${RING} $1 $2;fi 160 if [ $p1 -eq 1 ];then ${MAIN_SCRIPT_PATH}/FirstPass.sh ${RING} ${FORKS} $1 $2;fi
161 if [ $p2 -eq 1 ];then ${MAIN_SCRIPT_PATH}/SecondPass.sh ${RING} ${REP_OUT};fi 161 if [ $p2 -eq 1 ];then ${MAIN_SCRIPT_PATH}/SecondPass.sh ${RING} ${FORKS} ${REP_OUT};fi
162 if [ $conf -eq 1 ];then $p${MAIN_SCRIPT_PATH}/ConfPass.sh ${RING} ${REP_OUT} "res_p2";fi 162 if [ $conf -eq 1 ] || [ $conf -eq 2 ];then $p${MAIN_SCRIPT_PATH}/ConfPass.sh ${RING} ${REP_OUT} "res_p2";fi
163 if [ $exploitconf -eq 1 ]; then ${MAIN_SCRIPT_PATH}/ExploitConfidencePass.sh ${RING} ${REP_OUT};fi 163 if [ $exploitconf -eq 1 ]; then ${MAIN_SCRIPT_PATH}/ExploitConfidencePass.sh ${RING} ${REP_OUT};fi
164 if [ $p3 -eq 1 ];then ${MAIN_SCRIPT_PATH}/ThirdPass.sh ${RING} ${REP_OUT};fi 164 if [ $p3 -eq 1 ];then ${MAIN_SCRIPT_PATH}/ThirdPass.sh ${RING} ${FORKS} ${REP_OUT};fi
165 if [ $conf -eq 1 ];then ${MAIN_SCRIPT_PATH}/ConfPass.sh ${RING} ${REP_OUT} "res_p3";fi 165 if [ $conf -eq 1 ] || [ $conf -eq 3 ];then ${MAIN_SCRIPT_PATH}/ConfPass.sh ${RING} ${REP_OUT} "res_p3";fi
166 if [ $recompose -eq 1 ];then ${MAIN_SCRIPT_PATH}/RecomposePass.sh ${RING} ${REP_OUT};fi 166 if [ $recompose -eq 1 ];then ${MAIN_SCRIPT_PATH}/RecomposePass.sh ${RING} ${REP_OUT};fi
167 if [ $scoring -eq 1 ];then ${MAIN_SCRIPT_PATH}/ScoringRes.sh ${RING} ${REP_OUT};fi 167 if [ $scoring -eq 1 ];then ${MAIN_SCRIPT_PATH}/ScoringRes.sh ${RING} ${REP_OUT};fi
168 echo "done" 168 echo "done"
169 else 169 else
170 echo "can't find $1 OR file is empty" 170 echo "can't find $1 OR file is empty"
171 exit 1 171 exit 1
172 fi 172 fi
173 173
174 174
175 175
176 176
tools/scripts/CheckSecondPass.sh
1 #!/bin/bash 1 #!/bin/bash
2 2
3 ################################################# 3 #################################################
4 # File : CheckSecondPass.sh # 4 # File : CheckSecondPass.sh #
5 # Brief : Check Second Pass # 5 # Brief : Check Second Pass #
6 # Author : Jean-François Rey # 6 # Author : Jean-François Rey #
7 # Version : 1.0 # 7 # Version : 1.0 #
8 # Date : 17/06/13 # 8 # Date : 17/06/13 #
9 ################################################# 9 #################################################
10 10
11 # configuration file 11 # configuration file
12 . "$OTMEDIA_HOME/cfg/SecondPass.cfg" 12 . "$OTMEDIA_HOME/cfg/SecondPass.cfg"
13 13
14 14
15 #check_second_pass_output_speeral(plplist,resdir) 15 #check_second_pass_output_speeral(plplist,resdir)
16 # - plplist : filename containing plp list 16 # - plplist : filename containing plp list
17 # - resdir : output Speeral directory 17 # - resdir : output Speeral directory
18 function check_second_pass_output_speeral() 18 function check_second_pass_output_speeral()
19 { 19 {
20 if [ $# -eq 2 ] 20 if [ $# -eq 2 ]
21 then 21 then
22 if [ ! -e "$1" ] || [ -z "$1" ]; then return 1; fi 22 if [ ! -e "$1" ] || [ -z "$1" ]; then return 1; fi
23 FILENBSEG=$(ls "$2/*.seg" | grep -f "$1" | wc -l) 23 FILENBSEG=$(ls "$2/*.seg" 2> /dev/null | grep -f "$1" | wc -l)
24 FILENBRES=$(ls "$2/*.res" | grep -f "$1" | wc -l) 24 FILENBRES=$(ls "$2/*.res" 2> /dev/null | grep -f "$1" | wc -l)
25 FILENBTREIL=$(ls "$2/*.treil" | grep -f "$1" | wc -l) 25 FILENBTREIL=$(ls "$2/*.treil" 2 /dev/null | grep -f "$1" | wc -l)
26 FILENB=$(cat "$1" | wc -l) 26 FILENB=$(cat "$1" | wc -l)
27 if [ $FILENB -ne $FILENBSEG ] || [ $FILENB -ne $FILENBRES ] || [ $FILENB -ne $FILENBTREIL ] ; then return 1;fi 27 if [ $FILENB -ne $FILENBSEG ] || [ $FILENB -ne $FILENBRES ] || [ $FILENB -ne $FILENBTREIL ] ; then return 1;fi
28 fi 28 fi
29 return 0 29 return 0
30 } 30 }
31 31
32 32