Commit 9456401f804acd7976a25465be9d72b733fc4e88

Authored by Jean-François Rey
1 parent 135404bcf3
Exists in master

modify info and log file system in SecondPass and ConPass

Showing 4 changed files with 134 additions and 64 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 #Check OTMEDIA_HOME env var 13 #Check OTMEDIA_HOME env var
14 if [ -z ${OTMEDIA_HOME} ] 14 if [ -z ${OTMEDIA_HOME} ]
15 then 15 then
16 OTMEDIA_HOME=$(dirname $(dirname $(readlink -e $0))) 16 OTMEDIA_HOME=$(dirname $(dirname $(readlink -e $0)))
17 export OTMEDIA_HOME=$OTMEDIA_HOME 17 export OTMEDIA_HOME=$OTMEDIA_HOME
18 fi 18 fi
19 19
20 20
21 # where is ConfPath.sh 21 # where is ConfPath.sh
22 MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0)) 22 MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0))
23 23
24 # Scripts Path 24 # Scripts Path
25 SCRIPT_PATH=$OTMEDIA_HOME/tools/scripts 25 SCRIPT_PATH=$OTMEDIA_HOME/tools/scripts
26 26
27 # Include scripts 27 # Include scripts
28 . $SCRIPT_PATH"/Tools.sh" 28 . $SCRIPT_PATH"/Tools.sh"
29 . $SCRIPT_PATH"/CheckConfPass.sh" 29 . $SCRIPT_PATH"/CheckConfPass.sh"
30 30
31 # where is FirstPass.cfg 31 # where is FirstPass.cfg
32 CONFPASS_CONFIG_FILE="$OTMEDIA_HOME/cfg/ConfPass.cfg" 32 CONFPASS_CONFIG_FILE="$OTMEDIA_HOME/cfg/ConfPass.cfg"
33 if [ -e $CONFPASS_CONFIG_FILE ] 33 if [ -e $CONFPASS_CONFIG_FILE ]
34 then 34 then
35 . $CONFPASS_CONFIG_FILE 35 . $CONFPASS_CONFIG_FILE
36 else 36 else
37 echo "ERROR : Can't find configuration file $CONFPASS_CONFIG_FILE" >&2 37 echo "ERROR : Can't find configuration file $CONFPASS_CONFIG_FILE" > /dev/stderr
38 exit 1 38 exit 1
39 fi 39 fi
40 40
41 #---------------# 41 #---------------#
42 # Parse Options # 42 # Parse Options #
43 #---------------# 43 #---------------#
44 while getopts ":hDv:cr" opt 44 while getopts ":hDv:cr" opt
45 do 45 do
46 case $opt in 46 case $opt in
47 h) 47 h)
48 echo -e "$0 [OPTIONS] <INPUT_DIRECTORY> <TREIL_DIRECTORY_NAME>\n" 48 echo -e "$0 [OPTIONS] <INPUT_DIRECTORY> <TREIL_DIRECTORY_NAME>\n"
49 echo -e "\t Options:" 49 echo -e "\t Options:"
50 echo -e "\t\t-h :\tprint this message" 50 echo -e "\t\t-h :\tprint this message"
51 echo -e "\t\t-D :\tDEBUG mode on" 51 echo -e "\t\t-D :\tDEBUG mode on"
52 echo -e "\t\t-v l :\tVerbose mode, l=(1|2|3) level mode" 52 echo -e "\t\t-v l :\tVerbose mode, l=(1|2|3) level mode"
53 echo -e "\t\t-c :\t Check process, stop if error detected" 53 echo -e "\t\t-c :\t Check process, stop if error detected"
54 echo -e "\t\t-r :\tForce to rerun confpas without deleting existing files" 54 echo -e "\t\t-r :\tForce to rerun confpas without deleting existing files"
55 exit 1 55 exit 1
56 ;; 56 ;;
57 D) 57 D)
58 DEBUG=1 58 DEBUG=1
59 ;; 59 ;;
60 v) 60 v)
61 VERBOSE=$OPTARG 61 VERBOSE=$OPTARG
62 ;; 62 ;;
63 c) 63 c)
64 CHECK=1 64 CHECK=1
65 ;; 65 ;;
66 r) 66 r)
67 RERUN=1 67 RERUN=1
68 ;; 68 ;;
69 :) 69 :)
70 echo "Option -$OPTARG requires an argument." >&2 70 echo "Option -$OPTARG requires an argument." > /dev/stderr
71 exit 1 71 exit 1
72 ;; 72 ;;
73 \?) 73 \?)
74 echo "BAD USAGE : unknow opton -$OPTARG" 74 echo "BAD USAGE : unknow opton -$OPTARG"
75 #exit 1 75 #exit 1
76 ;; 76 ;;
77 esac 77 esac
78 done 78 done
79 79
80 # mode debug enable 80 # mode debug enable
81 if [ $DEBUG -eq 1 ] 81 if [ $DEBUG -eq 1 ]
82 then 82 then
83 set -x 83 set -x
84 echo -e "## Mode DEBUG ON ##" 84 echo -e "## Mode DEBUG ON ##"
85 REDIRECTION_OUTPUT="" 85 REDIRECTION_OUTPUT=""
86 else 86 else
87 REDIRECTION_OUTPUT=" 2> /dev/null" 87 REDIRECTION_OUTPUT=" 2> /dev/null"
88 fi 88 fi
89 89
90 # mode verbose enable 90 # mode verbose enable
91 if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ;fi 91 if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ;fi
92 92
93 # Check USAGE by arguments number 93 # Check USAGE by arguments number
94 if [ $(($#-($OPTIND-1))) -ne 2 ] 94 if [ $(($#-($OPTIND-1))) -ne 2 ]
95 then 95 then
96 echo "BAD USAGE : ConfPass.sh [OPTIONS] <INPUT_DIR> <TREIL_DIRECTORY_NAME>" 96 echo "BAD USAGE : ConfPass.sh [OPTIONS] <INPUT_DIR> <TREIL_DIRECTORY_NAME>"
97 echo "$0 -h for more info" 97 echo "$0 -h for more info"
98 exit 1 98 exit 1
99 fi 99 fi
100 100
101 shift $((OPTIND-1)) 101 shift $((OPTIND-1))
102 # check input directory - first argument 102 # check input directory - first argument
103 if [ ! -e $1 ] 103 if [ ! -e $1 ]
104 then 104 then
105 print_error "can't open $1" 105 print_error "can't open $1"
106 exit 1 106 exit 1
107 fi 107 fi
108 # check treil input directory - second argument 108 # check treil input directory - second argument
109 if [ ! -e $1/$2 ] 109 if [ ! -e $1/$2 ]
110 then 110 then
111 print_error "can't open $1/$2" 111 print_error "can't open $1/$2"
112 exit 1 112 exit 1
113 fi 113 fi
114 114
115 #-------------# 115 #-------------#
116 # GLOBAL VARS # 116 # GLOBAL VARS #
117 #-------------# 117 #-------------#
118 INPUT_DIR=$(readlink -e $1) 118 INPUT_DIR=$(readlink -e $1)
119 OUTPUT_DIR=$INPUT_DIR 119 OUTPUT_DIR=$INPUT_DIR
120 BASENAME=$(basename $OUTPUT_DIR) 120 BASENAME=$(basename $OUTPUT_DIR)
121 RES_NAME=$2 121 RES_NAME=$2
122 RES_P="${INPUT_DIR}/${RES_NAME}" 122 RES_P="${INPUT_DIR}/${RES_NAME}"
123 USF_FILE=${INPUT_DIR}/${BASENAME}.${RES_NAME}.usf 123 USF_FILE=${INPUT_DIR}/${BASENAME}.${RES_NAME}.usf
124 CONF_DIR="$OUTPUT_DIR/conf/$RES_NAME" 124 CONF_DIR="$OUTPUT_DIR/conf/$RES_NAME"
125 RES_CONF_DIR="$OUTPUT_DIR/conf/$RES_NAME/scored_ctm" 125 RES_CONF_DIR="$OUTPUT_DIR/conf/$RES_NAME/scored_ctm"
126 LOGFILE="$(dirname $OUTPUT_DIR)/info_conf.log" 126 LOGFILE="${OUTPUT_DIR_BASENAME}/info_conf.log"
127 ERRORFILE="$(dirname $OUTPUT_DIR)/error_conf.log" 127 ERRORFILE="${OUTPUT_DIR_BASENAME}/error_conf.log"
128 128
129
130 #------------------# 129 #------------------#
131 # Create Workspace # 130 # Create Workspace #
132 #------------------# 131 #------------------#
133 # Lock directory 132 # Lock directory
134 if [ -e "$OUTPUT_DIR/CONFPASS.lock" ] && [ $RERUN -eq 0 ] 133 if [ -e "$OUTPUT_DIR/CONFPASS.lock" ] && [ $RERUN -eq 0 ]
135 then 134 then
136 print_info "Confpass lock $INPUT_DIR -> exit" 1 135 print_warn "[${BASENAME}] Confpass is locked -> exit" 2
137 exit 1 136 exit 1
138 fi 137 fi
139 rm "$OUTPUT_DIR/CONFPASS.unlock" > /dev/null 2>&1 138 rm "$OUTPUT_DIR/CONFPASS.unlock" > /dev/null 2>&1
140 touch "$OUTPUT_DIR/CONFPASS.lock" > /dev/null 2>&1 139 touch "$OUTPUT_DIR/CONFPASS.lock" > /dev/null 2>&1
141 if [ $RERUN -eq 0 ]; then rm -r $CONF_DIR > /dev/null 2>&1; fi 140 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 141 if [ $RERUN -eq 1 ]; then rm $USF_FILE > /dev/null 2>&1; fi
143 mkdir -p $CONF_DIR > /dev/null 2>&1 142 mkdir -p $CONF_DIR > /dev/null 2>&1
144 mkdir -p $RES_CONF_DIR > /dev/null 2>&1 143 mkdir -p $RES_CONF_DIR > /dev/null 2>&1
144 rm $LOGFILE $ERRORFILE > /dev/null 2>&1
145 145
146 #---------------# 146 #---------------#
147 # Check Pass # 147 # Check Pass #
148 #---------------# 148 #---------------#
149 149 print_info "[${BASENAME}] Check Conf Pass directory ${RES_NAME}" 1
150 # if usf contains more than 40% of 0.600 confidence -> usf error 150 # if usf contains more than 49% of 0.600 confidence -> usf error
151 if [ -s $USF_FILE ] 151 if [ -s $USF_FILE ]
152 then 152 then
153 conftozerosix=$(grep -c -E 'confidence="0.600"' "${USF_FILE}") 153 conftozerosix=$(grep -c -E 'confidence="0.600"' "${USF_FILE}")
154 conftoother=$(grep -c -v -E 'confidence="0.600"' "${USF_FILE}") 154 confall=$(grep -c -E 'confidence=' "${USF_FILE}")
155 if [ $conftoother -gt 0 ] 155 if [ $confall -gt 0 ]
156 then 156 then
157 pourcentageofzerosix=$((($conftozerosix*100)/$conftoother)) 157 pourcentageofzerosix=$((($conftozerosix*100)/$confall))
158 if [ $pourcentageofzerosix -gt 40 ] 158 if [ $pourcentageofzerosix -gt 49 ]
159 then 159 then
160 print_warn "${USF_FILE} got $pourcentageofzerosix% of 0.6 confidence" 1 160 print_warn "[${BASENAME}] ${BASENAME}.${RES_NAME}.usf got $pourcentageofzerosix% of 0.600 confidence" 2
161 print_info "[${BASENAME}] bad usf ${RES_NAME}, will do it again" 1
161 mv "${USF_FILE}" "${USF_FILE}.back" 162 mv "${USF_FILE}" "${USF_FILE}.back"
162 rm -r $CONF_DIR > /dev/null 2>&1 163 rm -r $CONF_DIR > /dev/null 2>&1
163 else 164 else
164 print_warn "${USF_FILE} already done, skipping it" 1 165 print_warn "[${BASENAME}] ${USF_FILE} already done, skipping it" 1
165 exit 0 166 exit 0
166 fi 167 fi
167 fi 168 fi
169 else
170 print_info "[${BASENAME}] No USF file already done, continue..." 1
168 fi 171 fi
169 172
173 # Check if treil are here
174 nbres_p1=$(cat ${INPUT_DIR}/plp.lst | wc -l)
175 nbtreil_p=$(ls $RES_P/*.treil 2> /dev/null | wc -l)
176 if [ $nbtreil_p -eq 0 ]
177 then
178 print_error "[${BASENAME}] No ${RES_NAME} Pass, No .treil -> exit ConfPass"
179 if [ $CHECK -eq 1 ]; then print_log_file $ERRORFILE "No ${RES_NAME} Pass, No .treil -> exit ConfPass" ;fi
180 exit 1
181 else
182 #Check if more then 89% of treil are done
183 if [ $nbres_p1 -gt 0 ]
184 then
185 pourcentage=$((($nbtreil_p*100)/$nbres_p1))
186 if [ $pourcentage -gt 89 ]
187 then
188 print_info "[${BASENAME}] ${RES_NAME}/*.treil are here" 1
189 else
190 print_warn "[${BASENAME}] not enough ${RES_NAME} treil" 2
191 if [ $CHECK -eq 1 ]; then print_log_file $ERRORFILE "Not enough ${RES_NAME} treil "
192 fi
193 fi
194 fi
195
170 #------# 196 #------#
171 # Save # 197 # Save #
172 #------# 198 #------#
173 cp $CONFPASS_CONFIG_FILE $OUTPUT_DIR/ConfPass.cfg 199 cp $CONFPASS_CONFIG_FILE $OUTPUT_DIR/ConfPass.cfg
174 echo "RES_CONF_DIR=$RES_CONF_DIR" >> $OUTPUT_DIR/ConfPass.cfg 200 echo "RES_CONF_DIR=$RES_CONF_DIR" >> $OUTPUT_DIR/ConfPass.cfg
175 echo "CONF_DIR=$CONF_DIR" >> $OUTPUT_DIR/ConfPass.cfg 201 echo "CONF_DIR=$CONF_DIR" >> $OUTPUT_DIR/ConfPass.cfg
202 print_info "[${BASENAME}] Save config in $OUTPUT_DIR_BASENAME/ConfPass.cfg" 1
176 203
177 #--------------------# 204 #--------------------#
178 # CONFIDENCE MEASURE # 205 # CONFIDENCE MEASURE #
179 #--------------------# 206 #--------------------#
180 207
181 # Check pourcentage of scored_ctm already done, if < 85% done confidence measure 208 # Check pourcentage of scored_ctm already done, if < 85% do confidence measure
182 nbres_p=$(ls ${RES_P}/*.treil | wc -l) 209 nbres_p=$(ls ${RES_P}/*.treil | wc -l)
183 nbconf=$(ls ${RES_CONF_DIR}/*.res | wc -l) 210 nbconf=$(ls ${RES_CONF_DIR}/*.res | wc -l)
184 if [ $nbres_p -gt 0 ] 211 if [ $nbres_p -gt 0 ]
185 then 212 then
186 pourcentageres=$((($nbconf*100)/$nbres_p)) 213 pourcentageres=$((($nbconf*100)/$nbres_p))
187 if [ $pourcentageres -lt 85 ] 214 if [ $pourcentageres -lt 85 ]
188 then 215 then
189 print_info "Calcul Confidence $INPUT_DIR $RES_NAME" 1 216 print_info "[${BASENAME}] Calcul Confidence $INPUT_DIR $RES_NAME" 1
190 $MAIN_SCRIPT_PATH/ConfidenceMeasure.sh $INPUT_DIR $RES_NAME $REDIRECTION_OUTPUT 217 $MAIN_SCRIPT_PATH/ConfidenceMeasure.sh $INPUT_DIR $RES_NAME $REDIRECTION_OUTPUT
191 218
192 else 219 else
193 print_info "skipping Confidence Calcul $INPUT_DIR/$RES_NAME" 1 220 print_info "[${BASENAME}] Skipping Confidence Calcul $INPUT_DIR/$RES_NAME" 1
194 fi 221 fi
195 fi 222 fi
196 223
197 ### Check scored_ctm number res files ! 224 ### Check scored_ctm number res files !
198 if [ $CHECK -eq 1 ] 225 if [ $CHECK -eq 1 ]
199 then 226 then
200 nbconf=$(ls ${RES_CONF_DIR}/*.res | wc -l) 227 nbconf=$(ls ${RES_CONF_DIR}/*.res | wc -l)
201 if [ $nbres_p -ne $nbconf ];then echo "WARN : ConfPass $INPUT_DIR/$RES_NAME number of res files differ" >> $LOGFILE;fi 228 if [ $nbres_p -ne $nbconf ]
229 then
230 print_warn "WARN : ConfPass $INPUT_DIR/$RES_NAME number of res files differ" 2
231 print_log_file $LOGFILE "WARN : ConfPass $INPUT_DIR/$RES_NAME number of res files differ"
232 fi
202 fi 233 fi
203 234
204 #---------------------------# 235 #---------------------------#
205 # FROM RES WITH CONF => USF # 236 # FROM RES WITH CONF => USF #
206 #---------------------------# 237 #---------------------------#
238 print_info "[${BASENAME}] Create USF file for $RES_P" 1
207 for f in `ls ${RES_CONF_DIR}`; do $SCRIPT_PATH/formatRES.pl $RES_CONF_DIR/$f; done 239 for f in `ls ${RES_CONF_DIR}`; do $SCRIPT_PATH/formatRES.pl $RES_CONF_DIR/$f; done
208 # create USF configuration file 240 # create USF configuration file
209 echo -e "name $AUTHOR\nfileName $BASENAME\nfileExt wav\nsegFile $OUTPUT_DIR/$BASENAME.seg" > $OUTPUT_DIR/$BASENAME.usf_cfg 241 echo -e "name $AUTHOR\nfileName $BASENAME\nfileExt wav\nsegFile $OUTPUT_DIR/$BASENAME.seg" > $OUTPUT_DIR/$BASENAME.usf_cfg
210 # create USF file 242 # create USF file
243 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 $REDIRECTION_OUTPUT" 3
211 $SCRIPT_PATH/res2out.pl --dir $RES_CONF_DIR --format USF --ignore $RULES/asupp --out $USF_FILE.tmp --usf_config $OUTPUT_DIR/$BASENAME.usf_cfg $REDIRECTION_OUTPUT 244 $SCRIPT_PATH/res2out.pl --dir $RES_CONF_DIR --format USF --ignore $RULES/asupp --out $USF_FILE.tmp --usf_config $OUTPUT_DIR/$BASENAME.usf_cfg $REDIRECTION_OUTPUT
212 rm $OUTPUT_DIR/$BASENAME.usf_cfg > /dev/null 2>&1 245 rm $OUTPUT_DIR/$BASENAME.usf_cfg > /dev/null 2>&1
213 cat $USF_FILE.tmp | $SCRIPT_PATH/BdlexUC.pl $RULES/basic -f > $USF_FILE 246 cat $USF_FILE.tmp | $SCRIPT_PATH/BdlexUC.pl $RULES/basic -f > $USF_FILE
214 cp $USF_FILE ${OUTPUT_DIR}/${BASENAME}.usf 247 cp $USF_FILE ${OUTPUT_DIR}/${BASENAME}.usf
215 rm $USF_FILE.tmp > /dev/null 2>&1 248 rm $USF_FILE.tmp > /dev/null 2>&1
216 249
217 #----------------# 250 #----------------#
218 # Check USF file # 251 # Check USF file #
219 #----------------# 252 #----------------#
220 if [ $CHECK -eq 1 ] 253 if [ $CHECK -eq 1 ]
221 then 254 then
222 check_conf_pass_usf "$OUTPUT_DIR/$BASENAME.usf" 255 check_conf_pass_usf "$OUTPUT_DIR/$BASENAME.usf"
223 if [ $? -eq 1 ] 256 if [ $? -eq 1 ]
224 then 257 then
225 echo -e "ERROR : Wrong confidence measures in USF file : $OUTPUT_DIR/$BASENAME.usf" >> $ERRORFILE 258 print_error "[${BASENAME}] Wrong confidence measures in USF file : $OUTPUT_DIR/$BASENAME.usf"
259 print_log_file $ERRORFILE "ERROR : Wrong confidence measures in USF file : $OUTPUT_DIR/$BASENAME.usf"
226 exit 1 260 exit 1
227 fi 261 fi
228 fi 262 fi
229 263
230 #-------# 264 #-------#
231 # CLOSE # 265 # CLOSE #
232 #-------# 266 #-------#
233 # Seem OK 267 # Seem OK
234 print_info "<= End $BASENAME ConfPass | $(date +'%d/%m/%y %H:%M:%S')" 1 268 print_info "[${BASENAME}] <= ConfPass End | $(date +'%d/%m/%y %H:%M:%S')" 1
235 echo -e "ConfPass $BASENAME OK" >> $LOGFILE
236 269
237 # unlock directory 270 # unlock directory
238 mv "$OUTPUT_DIR/CONFPASS.lock" "$OUTPUT_DIR/CONFPASS.unlock" 271 mv "$OUTPUT_DIR/CONFPASS.lock" "$OUTPUT_DIR/CONFPASS.unlock"
main_tools/FirstPass.sh
1 #!/bin/bash 1 #!/bin/bash
2 2
3 ##################################################### 3 #####################################################
4 # File : FirstPass.sh # 4 # File : FirstPass.sh #
5 # Brief : ASR first pass and speaker diarization # 5 # Brief : ASR first pass and speaker diarization #
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.1 # 9 # Version : 1.1 #
10 # Date : 18/06/13 # 10 # Date : 18/06/13 #
11 ##################################################### 11 #####################################################
12 12
13 # Check OTMEDIA_HOME env var 13 # Check OTMEDIA_HOME env var
14 if [ -z ${OTMEDIA_HOME} ] 14 if [ -z ${OTMEDIA_HOME} ]
15 then 15 then
16 OTMEDIA_HOME=$(dirname $(dirname $(readlink -e $0))) 16 OTMEDIA_HOME=$(dirname $(dirname $(readlink -e $0)))
17 export OTMEDIA_HOME=$OTMEDIA_HOME 17 export OTMEDIA_HOME=$OTMEDIA_HOME
18 fi 18 fi
19 19
20 # where is FirstPass.sh 20 # where is FirstPass.sh
21 MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0)) 21 MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0))
22 22
23 # scripts path 23 # scripts path
24 SCRIPT_PATH=$OTMEDIA_HOME/tools/scripts 24 SCRIPT_PATH=$OTMEDIA_HOME/tools/scripts
25 25
26 # Include scripts 26 # Include scripts
27 . $SCRIPT_PATH"/Tools.sh" 27 . $SCRIPT_PATH"/Tools.sh"
28 . $SCRIPT_PATH"/CheckFirstPass.sh" 28 . $SCRIPT_PATH"/CheckFirstPass.sh"
29 29
30 # where is FirstPass.cfg 30 # where is FirstPass.cfg
31 FIRSTPASS_CONFIG_FILE=$OTMEDIA_HOME"/cfg/FirstPass.cfg" 31 FIRSTPASS_CONFIG_FILE=$OTMEDIA_HOME"/cfg/FirstPass.cfg"
32 if [ -e $FIRSTPASS_CONFIG_FILE ] 32 if [ -e $FIRSTPASS_CONFIG_FILE ]
33 then 33 then
34 . $FIRSTPASS_CONFIG_FILE 34 . $FIRSTPASS_CONFIG_FILE
35 else 35 else
36 echo "ERROR : Can't find configuration file $FIRSTPASS_CONFIG_FILE" > /dev/stderr 36 echo "ERROR : Can't find configuration file $FIRSTPASS_CONFIG_FILE" > /dev/stderr
37 echo "exit" > /dev/stderr 37 echo "exit" > /dev/stderr
38 exit 1 38 exit 1
39 fi 39 fi
40 40
41 #---------------# 41 #---------------#
42 # Parse Options # 42 # Parse Options #
43 #---------------# 43 #---------------#
44 while getopts ":hDv:cf:r" opt 44 while getopts ":hDv:cf:r" opt
45 do 45 do
46 case $opt in 46 case $opt in
47 h) 47 h)
48 echo -e "$0 [OPTIONS] <WAV_FILE> <OUTPUT_DIRECTORY>\n" 48 echo -e "$0 [OPTIONS] <WAV_FILE> <OUTPUT_DIRECTORY>\n"
49 echo -e "\t Options:" 49 echo -e "\t Options:"
50 echo -e "\t\t-h :\tprint this message" 50 echo -e "\t\t-h :\tprint this message"
51 echo -e "\t\t-D :\tDEBUG mode on" 51 echo -e "\t\t-D :\tDEBUG mode on"
52 echo -e "\t\t-v l :\tVerbose mode, l=(1|2|3) level mode" 52 echo -e "\t\t-v l :\tVerbose mode, l=(1|2|3) level mode"
53 echo -e "\t\t-c :\tCheck process, and log it into files, can stop if error detected" 53 echo -e "\t\t-c :\tCheck process, and log it into files, can stop if error detected"
54 echo -e "\t\t-f n :\tspecify a speeral forks number (default 1)" 54 echo -e "\t\t-f n :\tspecify a speeral forks number (default 1)"
55 echo -e "\t\t-r :\tforce rerun the wav file" 55 echo -e "\t\t-r :\tforce rerun the wav file"
56 exit 1 56 exit 1
57 ;; 57 ;;
58 D) 58 D)
59 DEBUG=1 59 DEBUG=1
60 ;; 60 ;;
61 v) 61 v)
62 VERBOSE=$OPTARG 62 VERBOSE=$OPTARG
63 ;; 63 ;;
64 c) 64 c)
65 CHECK=1 65 CHECK=1
66 ;; 66 ;;
67 f) 67 f)
68 FORKS="--forks $OPTARG" 68 FORKS="--forks $OPTARG"
69 ;; 69 ;;
70 r) 70 r)
71 RERUN=1 71 RERUN=1
72 ;; 72 ;;
73 :) 73 :)
74 echo "Option -$OPTARG requires an argument." >&2 74 echo "Option -$OPTARG requires an argument." > /dev/stderr
75 exit 1 75 exit 1
76 ;; 76 ;;
77 \?) 77 \?)
78 echo "BAD USAGE : unknow opton -$OPTARG" 78 echo "BAD USAGE : unknow opton -$OPTARG"
79 exit 1 79 exit 1
80 ;; 80 ;;
81 esac 81 esac
82 done 82 done
83 83
84 # mode debug enable 84 # mode debug enable
85 if [ $DEBUG -eq 1 ] 85 if [ $DEBUG -eq 1 ]
86 then 86 then
87 set -x 87 set -x
88 echo -e "## Mode DEBUG ON ##" 88 echo -e "## Mode DEBUG ON ##"
89 REDIRECTION_OUTPUT="" 89 REDIRECTION_OUTPUT=""
90 else 90 else
91 REDIRECTION_OUTPUT=" 2> /dev/null" 91 REDIRECTION_OUTPUT=" 2> /dev/null"
92 fi 92 fi
93 93
94 # mode verbose enable 94 # mode verbose enable
95 if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ;fi 95 if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ;fi
96 96
97 # Check USAGE by arguments number 97 # Check USAGE by arguments number
98 if [ $(($#-($OPTIND-1))) -ne 2 ] 98 if [ $(($#-($OPTIND-1))) -ne 2 ]
99 then 99 then
100 echo "BAD USAGE : FirstPass.sh [OPTIONS] <WAV_FILE> <OUTPUT_DIR>" 100 echo "BAD USAGE : FirstPass.sh [OPTIONS] <WAV_FILE> <OUTPUT_DIR>"
101 echo "$0 -h for more info" 101 echo "$0 -h for more info"
102 exit 1 102 exit 1
103 fi 103 fi
104 104
105 shift $((OPTIND-1)) 105 shift $((OPTIND-1))
106 # check audio file - First argument 106 # check audio file - First argument
107 if [ -e $1 ] && [ -s $1 ] 107 if [ -e $1 ] && [ -s $1 ]
108 then 108 then
109 # absolute path to wav file 109 # absolute path to wav file
110 WAV_FILE=$(readlink -e $1) 110 WAV_FILE=$(readlink -e $1)
111 # wav filename 111 # wav filename
112 FILENAME=$(basename $WAV_FILE) 112 FILENAME=$(basename $WAV_FILE)
113 # wav filename without extension 113 # wav filename without extension
114 BASENAME=${FILENAME%.*} 114 BASENAME=${FILENAME%.*}
115 115
116 print_info "[${BASENAME}] => P1 start | $(date +'%d/%m/%y %H:%M:%S')" 1 116 print_info "[${BASENAME}] => P1 start | $(date +'%d/%m/%y %H:%M:%S')" 1
117 print_info "[${BASENAME}] $WAV_FILE OK" 2 117 print_info "[${BASENAME}] $WAV_FILE OK" 2
118 else 118 else
119 print_error "can't find $1 OR file is empty" 119 print_error "can't find $1 OR file is empty"
120 exit 1 120 exit 1
121 fi 121 fi
122 122
123 # check output directory - Second argument 123 # check output directory - Second argument
124 if [ ! -e $2 ] 124 if [ ! -e $2 ]
125 then 125 then
126 mkdir -p $2 126 mkdir -p $2
127 print_info "[${BASENAME}] Make directory $2" 2 127 print_info "[${BASENAME}] Make directory $2" 2
128 fi 128 fi
129 129
130 130
131 #-------------# 131 #-------------#
132 # GLOBAL VARS # 132 # GLOBAL VARS #
133 #-------------# 133 #-------------#
134 OUTPUT_DIR=$(readlink -e $2) # Output directory absolute path 134 OUTPUT_DIR=$(readlink -e $2) # Output directory absolute path
135 OUTPUT_DIR_BASENAME="$OUTPUT_DIR/$BASENAME/" # New OUTPUT_DIR with BASENAME 135 OUTPUT_DIR_BASENAME="$OUTPUT_DIR/$BASENAME/" # New OUTPUT_DIR with BASENAME
136 PLP_FILE="$OUTPUT_DIR_BASENAME/$BASENAME.plp" # Global PLP file 136 PLP_FILE="$OUTPUT_DIR_BASENAME/$BASENAME.plp" # Global PLP file
137 PLP_DIR="$OUTPUT_DIR_BASENAME/PLP/" # Segmented PLP files directory 137 PLP_DIR="$OUTPUT_DIR_BASENAME/PLP/" # Segmented PLP files directory
138 SEG_FILE="$OUTPUT_DIR_BASENAME/$BASENAME.seg" # Global Seg file 138 SEG_FILE="$OUTPUT_DIR_BASENAME/$BASENAME.seg" # Global Seg file
139 LBL_FILE="$OUTPUT_DIR_BASENAME/$BASENAME.lbl" # Global LBL file 139 LBL_FILE="$OUTPUT_DIR_BASENAME/$BASENAME.lbl" # Global LBL file
140 RES_DIR=$OUTPUT_DIR_BASENAME"/res_p1" 140 RES_DIR=$OUTPUT_DIR_BASENAME"/res_p1"
141 LOGFILE="$OUTPUT_DIR_BASENAME/info_p1.log" 141 LOGFILE="$OUTPUT_DIR_BASENAME/info_p1.log"
142 ERRORFILE="$OUTPUT_DIR_BASENAME/error_p1.log" 142 ERRORFILE="$OUTPUT_DIR_BASENAME/error_p1.log"
143 143
144 #------------------# 144 #------------------#
145 # Create WORKSPACE # 145 # Create WORKSPACE #
146 #------------------# 146 #------------------#
147 if [ ! -e $OUTPUT_DIR_BASENAME ] 147 if [ ! -e $OUTPUT_DIR_BASENAME ]
148 then 148 then
149 mkdir -p $OUTPUT_DIR_BASENAME 149 mkdir -p $OUTPUT_DIR_BASENAME
150 print_info "[${BASENAME}] Make directory $OUTPUT_DIR_BASENAME" 2 150 print_info "[${BASENAME}] Make directory $OUTPUT_DIR_BASENAME" 2
151 fi 151 fi
152 152
153 # Lock directory 153 # Lock directory
154 if [ -e $OUTPUT_DIR_BASENAME/FIRSTPASS.lock ] && [ $RERUN -eq 0 ]; then exit 1; fi 154 if [ -e $OUTPUT_DIR_BASENAME/FIRSTPASS.lock ] && [ $RERUN -eq 0 ]; then exit 1; fi
155 rm "$OUTPUT_DIR_BASENAME/FIRSTPASS.unlock" > /dev/null 2>&1 155 rm "$OUTPUT_DIR_BASENAME/FIRSTPASS.unlock" > /dev/null 2>&1
156 touch "$OUTPUT_DIR_BASENAME/FIRSTPASS.lock" > /dev/null 2>&1 156 touch "$OUTPUT_DIR_BASENAME/FIRSTPASS.lock" > /dev/null 2>&1
157 157
158 rm -r $PLP_DIR > /dev/null 2>&1; 158 rm -r $PLP_DIR > /dev/null 2>&1;
159 mkdir -p $PLP_DIR 159 mkdir -p $PLP_DIR
160 print_info "[${BASENAME}] Make directory $PLP_DIR" 2 160 print_info "[${BASENAME}] Make directory $PLP_DIR" 2
161 if [ $RERUN -eq 0 ]; 161 if [ $RERUN -eq 0 ];
162 then 162 then
163 rm -r $RES_DIR > /dev/null 2>&1; 163 rm -r $RES_DIR > /dev/null 2>&1;
164 else 164 else
165 rm $RES_DIR/*.lock > /dev/null 2>&1 165 rm $RES_DIR/*.lock > /dev/null 2>&1
166 fi 166 fi
167 mkdir -p $RES_DIR > /dev/null 2>&1 167 mkdir -p $RES_DIR > /dev/null 2>&1
168 print_info "[${BASENAME}] Make directory $RES_DIR" 2 168 print_info "[${BASENAME}] Make directory $RES_DIR" 2
169 rm $LOGFILE $ERRORFILE > /dev/null 2>&1 169 rm $LOGFILE $ERRORFILE > /dev/null 2>&1
170 170
171 #--------------------# 171 #--------------------#
172 # Save configuration # 172 # Save configuration #
173 #--------------------# 173 #--------------------#
174 cp $FIRSTPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/FirstPass.cfg 174 cp $FIRSTPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/FirstPass.cfg
175 echo "FIRSTPASS_SCRIPT_PATH=$MAIN_SCRIPT_PATH" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 175 echo "FIRSTPASS_SCRIPT_PATH=$MAIN_SCRIPT_PATH" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
176 echo "WAV_FILE=$WAV_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 176 echo "WAV_FILE=$WAV_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
177 echo "BASENAME=$BASENAME" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 177 echo "BASENAME=$BASENAME" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
178 echo "OUTPUT_DIR=$OUTPUT_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 178 echo "OUTPUT_DIR=$OUTPUT_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
179 echo "OUTPUT_DIR_BASENAME=$OUTPUT_DIR_BASENAME" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 179 echo "OUTPUT_DIR_BASENAME=$OUTPUT_DIR_BASENAME" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
180 echo "PLP_FILE=$PLP_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 180 echo "PLP_FILE=$PLP_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
181 echo "PLP_DIR=$PLP_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 181 echo "PLP_DIR=$PLP_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
182 echo "SEG_FILE=$SEG_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 182 echo "SEG_FILE=$SEG_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
183 echo "LBL_FILE=$LBL_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 183 echo "LBL_FILE=$LBL_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
184 echo "RES_DIR=$RES_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 184 echo "RES_DIR=$RES_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
185 print_info "[${BASENAME}] save config in $OUTPUT_DIR_BASENAME/FirstPass.cfg" 1 185 print_info "[${BASENAME}] Save config in $OUTPUT_DIR_BASENAME/FirstPass.cfg" 1
186 186
187 #-------------------------# 187 #-------------------------#
188 # Check Audio File Format # 188 # Check Audio File Format #
189 #-------------------------# 189 #-------------------------#
190 error=0 190 error=0
191 temp=$(avconv -i $WAV_FILE 2>&1 | grep "16000 Hz") 191 temp=$(avconv -i $WAV_FILE 2>&1 | grep "16000 Hz")
192 if [ -z "$temp" ]; then error=1; fi 192 if [ -z "$temp" ]; then error=1; fi
193 temp=$(avconv -i $WAV_FILE 2>&1 | grep "1 channels") 193 temp=$(avconv -i $WAV_FILE 2>&1 | grep "1 channels")
194 if [ -z "$temp" ]; then error=1; fi 194 if [ -z "$temp" ]; then error=1; fi
195 temp=$(avconv -i $WAV_FILE 2>&1 | grep "s16") 195 temp=$(avconv -i $WAV_FILE 2>&1 | grep "s16")
196 if [ -z "$temp" ]; then error=1; fi 196 if [ -z "$temp" ]; then error=1; fi
197 197
198 if [ $error -eq 1 ] 198 if [ $error -eq 1 ]
199 then 199 then
200 print_message $WARNING 2 "[${BASENAME}] $WAV_FILE is not a wav file at 16000 Hz, 1 channel, 16bits\nhave to convert" 200 print_message $WARNING 2 "[${BASENAME}] $WAV_FILE is not a wav file at 16000 Hz, 1 channel, 16bits\nhave to convert"
201 print_message $INFO 3 "[${BASENAME}] avconv -i $WAV_FILE -threads 4 -vn -f wav -ac 1 -ar 16000 -ab 256000 $OUTPUT_DIR_BASENAME/$BASENAME.wav" 201 print_message $INFO 3 "[${BASENAME}] avconv -i $WAV_FILE -threads 4 -vn -f wav -ac 1 -ar 16000 -ab 256000 $OUTPUT_DIR_BASENAME/$BASENAME.wav"
202 avconv -i $WAV_FILE -threads 4 -vn -f wav -ac 1 -ar 16000 -ab 256000 $OUTPUT_DIR_BASENAME/$BASENAME.wav $REDIRECTION_OUTPUT 202 avconv -i $WAV_FILE -threads 4 -vn -f wav -ac 1 -ar 16000 -ab 256000 $OUTPUT_DIR_BASENAME/$BASENAME.wav $REDIRECTION_OUTPUT
203 WAV_FILE=$OUTPUT_DIR_BASENAME/$BASENAME.wav 203 WAV_FILE=$OUTPUT_DIR_BASENAME/$BASENAME.wav
204 FILENAME=$BASENAME.wav 204 FILENAME=$BASENAME.wav
205 print_message $INFO 1 "[${BASENAME}] new wav file : $WAV_FILE" 205 print_message $INFO 1 "[${BASENAME}] new wav file : $WAV_FILE"
206 fi 206 fi
207 207
208 #---------------# 208 #---------------#
209 # Get SRT file # 209 # Get SRT file #
210 #---------------# 210 #---------------#
211 if [ -s $(dirname $WAV_FILE)/$BASENAME.SRT ] 211 if [ -s $(dirname $WAV_FILE)/$BASENAME.SRT ]
212 then 212 then
213 cp $(dirname $WAV_FILE)/$BASENAME.SRT $OUTPUT_DIR_BASENAME/$BASENAME.SRT 213 cp $(dirname $WAV_FILE)/$BASENAME.SRT $OUTPUT_DIR_BASENAME/$BASENAME.SRT
214 print_info "[${BASENAME}] copy $BASENAME.SRT file into $OUTPUT_DIR_BASENAME" 3 214 print_info "[${BASENAME}] copy $BASENAME.SRT file into $OUTPUT_DIR_BASENAME" 3
215 fi 215 fi
216 216
217 #------------# 217 #------------#
218 # WAV -> PLP # 218 # WAV -> PLP #
219 #------------# 219 #------------#
220 print_info "[${BASENAME}] convert WAV -> PLP" 1 220 print_info "[${BASENAME}] convert WAV -> PLP" 1
221 echo $FILENAME > $OUTPUT_DIR_BASENAME/list.tmp 221 echo $FILENAME > $OUTPUT_DIR_BASENAME/list.tmp
222 print_info "[${BASENAME}] $BIN_PATH/lia_plp_mt.32 --lst $OUTPUT_DIR_BASENAME/list.tmp --input_dir $(dirname $WAV_FILE) --output_dir $OUTPUT_DIR_BASENAME --input_type WAV --output_type HTK --nb_coef 12 --cms" 3 222 print_info "[${BASENAME}] $BIN_PATH/lia_plp_mt.32 --lst $OUTPUT_DIR_BASENAME/list.tmp --input_dir $(dirname $WAV_FILE) --output_dir $OUTPUT_DIR_BASENAME --input_type WAV --output_type HTK --nb_coef 12 --cms" 3
223 223
224 $BIN_PATH/lia_plp_mt$ARCH --lst $OUTPUT_DIR_BASENAME/list.tmp --input_dir $(dirname $WAV_FILE) --output_dir $OUTPUT_DIR_BASENAME --input_type WAV --output_type HTK --nb_coef 12 --cms $REDIRECTION_OUTPUT 224 $BIN_PATH/lia_plp_mt$ARCH --lst $OUTPUT_DIR_BASENAME/list.tmp --input_dir $(dirname $WAV_FILE) --output_dir $OUTPUT_DIR_BASENAME --input_type WAV --output_type HTK --nb_coef 12 --cms $REDIRECTION_OUTPUT
225 225
226 if [ $CHECK -eq 1 ] 226 if [ $CHECK -eq 1 ]
227 then 227 then
228 check_first_pass_plp "$PLP_FILE" 228 check_first_pass_plp "$PLP_FILE"
229 if [ $? -eq 1 ] 229 if [ $? -eq 1 ]
230 then 230 then
231 print_log_file "$ERROFILE" "ERROR [$(date +'%d/%m/%y %H:%M:%S')] Creating PLP file : $PLP_FILE" 231 print_log_file "$ERROFILE" "ERROR [$(date +'%d/%m/%y %H:%M:%S')] Creating PLP file : $PLP_FILE"
232 echo "[${BASENAME}] ERROR : ${BASENAME} check $ERRORFILE file" > /dev/stderr 232 echo "[${BASENAME}] ERROR : ${BASENAME} check $ERRORFILE file" > /dev/stderr
233 exit 1 233 exit 1
234 fi 234 fi
235 fi 235 fi
236 236
237 rm $OUTPUT_DIR_BASENAME/list.tmp 237 rm $OUTPUT_DIR_BASENAME/list.tmp
238 238
239 #------------------------------# 239 #------------------------------#
240 # S/NS + SPEAKERS SEGMENTATION # 240 # S/NS + SPEAKERS SEGMENTATION #
241 #------------------------------# 241 #------------------------------#
242 print_info "[${BASENAME}] Launch speakers diarization" 1 242 print_info "[${BASENAME}] Launch speakers diarization" 1
243 # Calcul seg file 243 # Calcul seg file
244 print_info "[${BASENAME}] java -Xmx4096m -jar $BIN_PATH/LIUM_SpkDiarization-4.2.jar --fInputMask=${WAV_FILE} --sOutputMask=${SEG_FILE} $BASENAME" 3 244 print_info "[${BASENAME}] java -Xmx4096m -jar $BIN_PATH/LIUM_SpkDiarization-4.2.jar --fInputMask=${WAV_FILE} --sOutputMask=${SEG_FILE} $BASENAME" 3
245 #java -Xmx8000m -Xms2048 -jar $BIN_PATH/LIUM_SpkDiarization-4.2.jar --fInputMask=${WAV_FILE} --sOutputMask=${SEG_FILE} $BASENAME 245 #java -Xmx8000m -Xms2048 -jar $BIN_PATH/LIUM_SpkDiarization-4.2.jar --fInputMask=${WAV_FILE} --sOutputMask=${SEG_FILE} $BASENAME
246 java -Xmx4096m -jar $BIN_PATH/LIUM_SpkDiarization-4.2.jar --fInputMask=${WAV_FILE} --sOutputMask=${SEG_FILE} $BASENAME $REDIRECTION_OUTPUT #–doCEClustering 246 java -Xmx4096m -jar $BIN_PATH/LIUM_SpkDiarization-4.2.jar --fInputMask=${WAV_FILE} --sOutputMask=${SEG_FILE} $BASENAME $REDIRECTION_OUTPUT #–doCEClustering
247 247
248 if [ $CHECK -eq 1 ] && ( [ ! -e $SEG_FILE ] || [ -z $SEG_FILE ] ) 248 if [ $CHECK -eq 1 ] && ( [ ! -e $SEG_FILE ] || [ -z $SEG_FILE ] )
249 then 249 then
250 print_log_file "$ERRORFILE" "ERROR [$(date +'%d/%m/%y %H:%M:%S')] Creating SEG file : $SEG_FILE" 250 print_log_file "$ERRORFILE" "ERROR [$(date +'%d/%m/%y %H:%M:%S')] Creating SEG file : $SEG_FILE"
251 echo "[${BASENAME}] ERROR : check $ERRORFILE file" > /dev/stderr 251 print_error "[${BASENAME}] ERROR : check $ERRORFILE file"
252 exit 1 252 exit 1
253 fi 253 fi
254 254
255 255
256 # Create LBL file 256 # Create LBL file
257 print_info "Extract LBL file from SEG file" 1 257 print_info "Extract LBL file from SEG file" 1
258 258
259 cat $SEG_FILE | grep -v ";;" | cut -f3,4,5,8 -d" " | tr " " "#" | sort -k1 -n | tr "#" " " > $LBL_FILE 259 cat $SEG_FILE | grep -v ";;" | cut -f3,4,5,8 -d" " | tr " " "#" | sort -k1 -n | tr "#" " " > $LBL_FILE
260 260
261 if [ $CHECK -eq 1 ] && ( [ ! -e $LBL_FILE ] || [ -z $LBL_FILE ] ) 261 if [ $CHECK -eq 1 ] && ( [ ! -e $LBL_FILE ] || [ -z $LBL_FILE ] )
262 then 262 then
263 print_log_file "$ERRORFILE" "ERROR [$(date +'%d/%m/%y %H:%M:%S')] Creating LBL file : $LBL_FILE" 263 print_log_file "$ERRORFILE" "ERROR [$(date +'%d/%m/%y %H:%M:%S')] Creating LBL file : $LBL_FILE"
264 echo "[${BASENAME}] ERROR : check $ERRORFILE file" > /dev/stderr 264 print_error "[${BASENAME}] ERROR : check $ERRORFILE file"
265 exit 1 265 exit 1
266 fi 266 fi
267 267
268 268
269 #----------------------------------------------------# 269 #----------------------------------------------------#
270 # Cut global PLP file depending to LBL segmentations # 270 # Cut global PLP file depending to LBL segmentations #
271 #----------------------------------------------------# 271 #----------------------------------------------------#
272 print_info "[${BASENAME}] Cut PLP file depending to LBL segmentations" 1 272 print_info "[${BASENAME}] Cut PLP file depending to LBL segmentations" 1
273 print_info "[${BASENAME}] $BIN_PATH/gcep $PLP_FILE $LBL_FILE 500 $PLP_DIR -FSEG" 3 273 print_info "[${BASENAME}] $BIN_PATH/gcep $PLP_FILE $LBL_FILE 500 $PLP_DIR -FSEG" 3
274 274
275 $SPEERAL_TOOLS/gcep $PLP_FILE $LBL_FILE 500 $PLP_DIR -FSEG $REDIRECTION_OUTPUT 275 $SPEERAL_TOOLS/gcep $PLP_FILE $LBL_FILE 500 $PLP_DIR -FSEG $REDIRECTION_OUTPUT
276 276
277 if [ $CHECK -eq 1 ] 277 if [ $CHECK -eq 1 ]
278 then 278 then
279 check_first_pass_plps_lbl $PLP_DIR $LBL_FILE 279 check_first_pass_plps_lbl $PLP_DIR $LBL_FILE
280 if [ $? -eq 1 ] 280 if [ $? -eq 1 ]
281 then 281 then
282 print_log_file $ERRORFILE "ERROR [$(date +'%d/%m/%y %H:%M:%S')] $PLP wrong number of .plp files" 282 print_log_file $ERRORFILE "ERROR [$(date +'%d/%m/%y %H:%M:%S')] $PLP wrong number of .plp files"
283 echo "[${BASENAME}] ERROR : check $ERRORFILE file" > /dev/stderr 283 print_error "[${BASENAME}] ERROR : check $ERRORFILE file"
284 exit 1 284 exit 1
285 fi 285 fi
286 fi 286 fi
287 287
288 # change plp files names 288 # change plp files names
289 cd $PLP_DIR; 289 cd $PLP_DIR;
290 rename -f s/_/#/g *plp 290 rename -f s/_/#/g *plp
291 rename -f s/#/_/ *plp 291 rename -f s/#/_/ *plp
292 cd $OLDPWD 292 cd $OLDPWD
293 293
294 #---------------------------------------------# 294 #---------------------------------------------#
295 # PLP files list depending to acoustic models # 295 # PLP files list depending to acoustic models #
296 #---------------------------------------------# 296 #---------------------------------------------#
297 print_info "[${BASENAME}] Create PLP list depending of the model" 1 297 print_info "[${BASENAME}] Create PLP list depending of the model" 1
298 # Create a list of plp files 298 # Create a list of plp files
299 find $PLP_DIR -type f -exec basename "{}" .plp \; | sort > $OUTPUT_DIR_BASENAME/plp.lst 299 find $PLP_DIR -type f -exec basename "{}" .plp \; | sort > $OUTPUT_DIR_BASENAME/plp.lst
300 300
301 rm $OUTPUT_DIR_BASENAME/plp_*.lst > /dev/null 2>&1 301 rm $OUTPUT_DIR_BASENAME/plp_*.lst > /dev/null 2>&1
302 for (( i=0; $i<${#MTAG[@]} ; i++ )) 302 for (( i=0; $i<${#MTAG[@]} ; i++ ))
303 do 303 do
304 a=`grep -e "${MTAG[$i]}" $OUTPUT_DIR_BASENAME/plp.lst` 304 a=`grep -e "${MTAG[$i]}" $OUTPUT_DIR_BASENAME/plp.lst`
305 if [ -n "$a" ]; then 305 if [ -n "$a" ]; then
306 print_info "[${BASENAME}] Creating $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst" 3 306 print_info "[${BASENAME}] Creating $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst" 3
307 grep -e "${MTAG[$i]}" $OUTPUT_DIR_BASENAME/plp.lst | sort > $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst 307 grep -e "${MTAG[$i]}" $OUTPUT_DIR_BASENAME/plp.lst | sort > $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst
308 fi 308 fi
309 done 309 done
310 310
311 #-----------------------# 311 #-----------------------#
312 # First Pass (DECODING) # 312 # First Pass (DECODING) #
313 #-----------------------# 313 #-----------------------#
314 # 314 #
315 # For all AM do decoding 315 # For all AM do decoding
316 # if Check error -> iter on undone decoding (max 1 times) 316 # if Check error -> iter on undone decoding (max 1 times)
317 # 317 #
318 print_info "[${BASENAME}] Launch decoding" 1 318 print_info "[${BASENAME}] Launch decoding" 1
319 for (( i=0; $i<${#MTAG[@]} ; i++ )) 319 for (( i=0; $i<${#MTAG[@]} ; i++ ))
320 do 320 do
321 redo=1; # nb of try if not all segs is decoded 321 redo=1; # nb of try if not all segs is decoded
322 if [ -e $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst ] 322 if [ -e $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst ]
323 then 323 then
324 todo=$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst 324 todo=$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst
325 while [ $redo -gt 0 ]; do 325 while [ $redo -gt 0 ]; do
326 rm $RES_DIR/*.lock > /dev/null 2>&1 326 rm $RES_DIR/*.lock > /dev/null 2>&1
327 print_info "[${BASENAME}] $SPEERAL_BIN $todo $RES_DIR ${SPEERAL_CFG[$i]} -r $PLP_DIR -m $SPEERAL_AM/${MODS[$i]}.hmm -c $SPEERAL_AM/${MODS[$i]}.cls $FORKS --lock $REDIRECTION_OUTPUT" 3 327 print_info "[${BASENAME}] $SPEERAL_BIN $todo $RES_DIR ${SPEERAL_CFG[$i]} -r $PLP_DIR -m $SPEERAL_AM/${MODS[$i]}.hmm -c $SPEERAL_AM/${MODS[$i]}.cls $FORKS --lock $REDIRECTION_OUTPUT" 3
328 # Run speeral 328 # Run speeral
329 $SPEERAL_BIN ${todo} $RES_DIR ${SPEERAL_CFG[$i]} -r $PLP_DIR -m $SPEERAL_AM/${MODS[$i]}.hmm -c $SPEERAL_AM/${MODS[$i]}.cls $FORKS --lock $REDIRECTION_OUTPUT 329 $SPEERAL_BIN ${todo} $RES_DIR ${SPEERAL_CFG[$i]} -r $PLP_DIR -m $SPEERAL_AM/${MODS[$i]}.hmm -c $SPEERAL_AM/${MODS[$i]}.cls $FORKS --lock $REDIRECTION_OUTPUT
330 330
331 # Check if error 331 # Check if error
332 if [ $CHECK -eq 1 ] 332 if [ $CHECK -eq 1 ]
333 then 333 then
334 check_first_pass_output_speeral "${OUTPUT_DIR_BASENAME}/plp_${MODS[$i]}.lst" "$RES_DIR" 334 check_first_pass_output_speeral "${OUTPUT_DIR_BASENAME}/plp_${MODS[$i]}.lst" "$RES_DIR"
335 # if error 335 # if error
336 if [ $? -eq 1 ] 336 if [ $? -eq 1 ]
337 then 337 then
338 # rerun 338 # rerun
339 redo=$(($redo - 1)); 339 redo=$(($redo - 1));
340 print_warn "[${BASENAME}] Speeral output error : check $LOGFILE" 2 340 print_warn "[${BASENAME}] Speeral output error : check $LOGFILE" 2
341 print_log_file $LOGFILE "WARN : Speeral number of output ERROR ${OUTPUT_DIR_BASENAME}/plp_${MODS[$i]}.lst" 341 print_log_file $LOGFILE "WARN : Speeral number of output ERROR ${OUTPUT_DIR_BASENAME}/plp_${MODS[$i]}.lst"
342 # new plp list 342 # new plp list
343 # list .seg done and compare to list of seg to do 343 # list .seg done and compare to list of seg to do
344 ls $RES_DIR/*.seg | grep -e "${MTAG[$i]}" | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp 344 ls $RES_DIR/*.seg | grep -e "${MTAG[$i]}" | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp
345 diff ${OUTPUT_DIR_BASENAME}/plp_${MODS[$i]}.lst ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" > ${OUTPUT_DIR_BASENAME}/todo.lst 345 diff ${OUTPUT_DIR_BASENAME}/plp_${MODS[$i]}.lst ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" > ${OUTPUT_DIR_BASENAME}/todo.lst
346 rm ${OUTPUT_DIR_BASENAME}/.tmp 346 rm ${OUTPUT_DIR_BASENAME}/.tmp
347 # log seg to do 347 # log seg to do
348 print_log_file $LOGFILE "Segs not done :" 348 print_log_file $LOGFILE "Segs not done :"
349 cat ${OUTPUT_DIR_BASENAME}/todo.lst >> $LOGFILE 349 cat ${OUTPUT_DIR_BASENAME}/todo.lst >> $LOGFILE
350 todo=${OUTPUT_DIR_BASENAME}/todo.lst 350 todo=${OUTPUT_DIR_BASENAME}/todo.lst
351 print_warn "[${BASENAME}] Try $redo" 3 351 print_warn "[${BASENAME}] Try $redo" 3
352 fi 352 fi
353 fi 353 fi
354 done 354 done
355 rm ${OUTPUT_DIR_BASENAME}/todo.lst > /dev/null 2>&1 355 rm ${OUTPUT_DIR_BASENAME}/todo.lst > /dev/null 2>&1
356 #rm $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst 356 #rm $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst
357 rm $RES_DIR/*.lock > /dev/null 2>&1 357 rm $RES_DIR/*.lock > /dev/null 2>&1
358 fi 358 fi
359 done 359 done
360 360
361 ## Check missing seg and log it 361 ## Check missing seg and log it
362 if [ $CHECK -eq 1 ] 362 if [ $CHECK -eq 1 ]
363 then 363 then
364 ls $RES_DIR/*.seg | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp 364 ls $RES_DIR/*.seg | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp
365 todo=$(cat ${OUTPUT_DIR_BASENAME}/plp.lst | wc -l) 365 todo=$(cat ${OUTPUT_DIR_BASENAME}/plp.lst | wc -l)
366 if [ $todo -eq 0 ]; then todo=1;fi 366 if [ $todo -eq 0 ]; then todo=1;fi
367 notdone=$(($todo - $(cat ${OUTPUT_DIR_BASENAME}/.tmp | wc -l))) 367 notdone=$(($todo - $(cat ${OUTPUT_DIR_BASENAME}/.tmp | wc -l)))
368 pourcentage=$((($notdone*100)/$todo)) 368 pourcentage=$((($notdone*100)/$todo))
369 369
370 if [ $notdone -ne 0 ] 370 if [ $notdone -ne 0 ]
371 then 371 then
372 print_error "[${BASENAME}] ERROR : check $ERRORFILE" 372 print_error "[${BASENAME}] ERROR : check $ERRORFILE"
373 print_log_file "$ERRORFILE" "ERROR : Segs not done [" 373 print_log_file "$ERRORFILE" "ERROR : Segs not done ["
374 diff ${OUTPUT_DIR_BASENAME}/plp.lst ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> $ERROFILE 374 diff ${OUTPUT_DIR_BASENAME}/plp.lst ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> $ERRORFILE
375 print_log_file "$ERRORFILE" "] $pourcentage% $BASENAME" 375 print_log_file "$ERRORFILE" "] $pourcentage% $BASENAME"
376 else 376 else
377 print_log_file "$LOGFILE" "P1 OK $BASENAME | $(date +'%d/%m/%y %H:%M:%S')" 377 print_log_file "$LOGFILE" "P1 OK $BASENAME | $(date +'%d/%m/%y %H:%M:%S')"
378 fi 378 fi
379 rm ${OUTPUT_DIR_BASENAME}/.tmp 379 rm ${OUTPUT_DIR_BASENAME}/.tmp
380 fi 380 fi
381 381
382 #---------------# 382 #---------------#
383 # Convert res # 383 # Convert res #
384 #---------------# 384 #---------------#
385 print_info "[${BASENAME}] Convert .res into .ctm" 1 385 print_info "[${BASENAME}] Convert .res into .ctm" 1
386 # .res => .ctm 386 # .res => .ctm
387 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out $OUTPUT_DIR_BASENAME/$BASENAME.1pass.ctm $REDIRECTION_OUTPUT 387 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out $OUTPUT_DIR_BASENAME/$BASENAME.1pass.ctm $REDIRECTION_OUTPUT
388 print_info "[${BASENAME}] Convert .res into .trs" 1 388 print_info "[${BASENAME}] Convert .res into .trs" 1
389 # .res => .trs 389 # .res => .trs
390 echo -e "name $AUTHOR\nfileName $BASENAME\nfileExt wav\nsegFile $OUTPUT_DIR_BASENAME/$BASENAME.seg" > $OUTPUT_DIR_BASENAME/$BASENAME.trs_cfg 390 echo -e "name $AUTHOR\nfileName $BASENAME\nfileExt wav\nsegFile $OUTPUT_DIR_BASENAME/$BASENAME.seg" > $OUTPUT_DIR_BASENAME/$BASENAME.trs_cfg
391 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TRS --ignore $RULES/asupp --out $OUTPUT_DIR_BASENAME/$BASENAME.1pass.trs --trs_config $OUTPUT_DIR_BASENAME/$BASENAME.trs_cfg $REDIRECTION_OUTPUT 391 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TRS --ignore $RULES/asupp --out $OUTPUT_DIR_BASENAME/$BASENAME.1pass.trs --trs_config $OUTPUT_DIR_BASENAME/$BASENAME.trs_cfg $REDIRECTION_OUTPUT
392 rm $OUTPUT_DIR_BASENAME/$BASENAME.trs_cfg 2> /dev/null 392 rm $OUTPUT_DIR_BASENAME/$BASENAME.trs_cfg 2> /dev/null
393 print_info "[${BASENAME}] Convert .res into .txt" 1 393 print_info "[${BASENAME}] Convert .res into .txt" 1
394 # .res => .txt 394 # .res => .txt
395 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out $OUTPUT_DIR_BASENAME/$BASENAME.1pass.txt $REDIRECTION_OUTPUT 395 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out $OUTPUT_DIR_BASENAME/$BASENAME.1pass.txt $REDIRECTION_OUTPUT
396 396
397 print_info "[${BASENAME}] <= P1 End | $(date +'%d/%m/%y %H:%M:%S')" 1 397 print_info "[${BASENAME}] <= P1 End | $(date +'%d/%m/%y %H:%M:%S')" 1
398 # unlock directory 398 # unlock directory
399 mv "$OUTPUT_DIR_BASENAME/FIRSTPASS.lock" "$OUTPUT_DIR_BASENAME/FIRSTPASS.unlock" 399 mv "$OUTPUT_DIR_BASENAME/FIRSTPASS.lock" "$OUTPUT_DIR_BASENAME/FIRSTPASS.unlock"
400 400
main_tools/SecondPass.sh
1 #!/bin/bash 1 #!/bin/bash
2 2
3 ##################################################### 3 #####################################################
4 # File : SecondPass.sh # 4 # File : SecondPass.sh #
5 # Brief : Speaker adaptation + ASR second pass # 5 # Brief : Speaker adaptation + ASR second 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.1 # 9 # Version : 1.1 #
10 # Date : 18/06/13 # 10 # Date : 18/06/13 #
11 ##################################################### 11 #####################################################
12 12
13 # Check OTMEDIA_HOME env var 13 # Check OTMEDIA_HOME env var
14 if [ -z ${OTMEDIA_HOME} ] 14 if [ -z ${OTMEDIA_HOME} ]
15 then 15 then
16 OTMEDIA_HOME=$(dirname $(dirname $(readlink -e $0))) 16 OTMEDIA_HOME=$(dirname $(dirname $(readlink -e $0)))
17 export OTMEDIA_HOME=$OTMEDIA_HOME 17 export OTMEDIA_HOME=$OTMEDIA_HOME
18 fi 18 fi
19 19
20 # where is SecondPass.sh 20 # where is SecondPass.sh
21 MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0)) 21 MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0))
22 22
23 # Scripts Path 23 # Scripts Path
24 SCRIPT_PATH=$OTMEDIA_HOME/tools/scripts 24 SCRIPT_PATH=$OTMEDIA_HOME/tools/scripts
25 25
26 # Include scripts 26 # Include scripts
27 . $SCRIPT_PATH"/Tools.sh" 27 . $SCRIPT_PATH"/Tools.sh"
28 . $SCRIPT_PATH"/CheckSecondPass.sh" 28 . $SCRIPT_PATH"/CheckSecondPass.sh"
29 29
30 # where is SecondPass.cfg 30 # where is SecondPass.cfg
31 SECONDPASS_CONFIG_FILE=$OTMEDIA_HOME"/cfg/SecondPass.cfg" 31 SECONDPASS_CONFIG_FILE=$OTMEDIA_HOME"/cfg/SecondPass.cfg"
32 if [ -e $SECONDPASS_CONFIG_FILE ] 32 if [ -e $SECONDPASS_CONFIG_FILE ]
33 then 33 then
34 . $SECONDPASS_CONFIG_FILE 34 . $SECONDPASS_CONFIG_FILE
35 else 35 else
36 echo "ERROR : Can't find configuration file $SECONDPASS_CONFIG_FILE" >&2 36 echo "ERROR : Can't find configuration file $SECONDPASS_CONFIG_FILE" > /dev/stderr
37 echo "exit" > /dev/stderr
37 exit 1 38 exit 1
38 fi 39 fi
39 40
40 #---------------# 41 #---------------#
41 # Parse Options # 42 # Parse Options #
42 #---------------# 43 #---------------#
43 while getopts ":hDv:crf:" opt 44 while getopts ":hDv:crf:" opt
44 do 45 do
45 case $opt in 46 case $opt in
46 h) 47 h)
47 echo -e "$0 [OPTIONS] <FIRST_PASS_DIRECTORY>\n" 48 echo -e "$0 [OPTIONS] <FIRST_PASS_DIRECTORY>\n"
48 echo -e "\t Options:" 49 echo -e "\t Options:"
49 echo -e "\t\t-h :\tprint this message" 50 echo -e "\t\t-h :\tprint this message"
50 echo -e "\t\t-D :\tDEBUG mode on" 51 echo -e "\t\t-D :\tDEBUG mode on"
51 echo -e "\t\t-v l :\tVerbose mode, l=(1|2|3) level mode" 52 echo -e "\t\t-v l :\tVerbose mode, l=(1|2|3) level mode"
52 echo -e "\t\t-c :\t Check process, stop if error detected" 53 echo -e "\t\t-c :\t Check process, stop if error detected"
53 echo -e "\t\t-f n :\tSpecify speeral forks number (default 1)" 54 echo -e "\t\t-f n :\tSpecify speeral forks number (default 1)"
54 echo -e "\t\t-r n :\tforce rerun the show, without deleting works already done" 55 echo -e "\t\t-r n :\tforce rerun the show, without deleting works already done"
55 exit 1 56 exit 1
56 ;; 57 ;;
57 D) 58 D)
58 DEBUG=1 59 DEBUG=1
59 ;; 60 ;;
60 v) 61 v)
61 VERBOSE=$OPTARG 62 VERBOSE=$OPTARG
62 ;; 63 ;;
63 c) 64 c)
64 CHECK=1 65 CHECK=1
65 ;; 66 ;;
66 f) 67 f)
67 FORKS="--forks $OPTARG" 68 FORKS="--forks $OPTARG"
68 ;; 69 ;;
69 r) 70 r)
70 RERUN=1 71 RERUN=1
71 ;; 72 ;;
72 :) 73 :)
73 echo "Option -$OPTARG requires an argument." >&2 74 echo "Option -$OPTARG requires an argument." > /dev/stderr
74 exit 1 75 exit 1
75 ;; 76 ;;
76 \?) 77 \?)
77 echo "BAD USAGE : unknow opton -$OPTARG" 78 echo "BAD USAGE : unknow opton -$OPTARG" > /dev/stderr
78 exit 1 79 exit 1
79 ;; 80 ;;
80 esac 81 esac
81 done 82 done
82 83
83 # mode debug enable 84 # mode debug enable
84 if [ $DEBUG -eq 1 ] 85 if [ $DEBUG -eq 1 ]
85 then 86 then
86 set -x 87 set -x
87 echo -e "## Mode DEBUG ON ##" 88 echo -e "## Mode DEBUG ON ##"
88 REDIRECTION_OUTPUT="" 89 REDIRECTION_OUTPUT=""
89 else 90 else
90 REDIRECTION_OUTPUT=" 2> /dev/null" 91 REDIRECTION_OUTPUT=" 2> /dev/null"
91 fi 92 fi
92 93
93 # mode verbose enable 94 # mode verbose enable
94 if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ;fi 95 if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ;fi
95 96
96 # Check USAGE by arguments number 97 # Check USAGE by arguments number
97 if [ $(($#-($OPTIND-1))) -ne 1 ] 98 if [ $(($#-($OPTIND-1))) -ne 1 ]
98 then 99 then
99 echo "BAD USAGE : SecondPass.sh [OPTIONS] <FIRST_PASS_DIR>" 100 echo "BAD USAGE : SecondPass.sh [OPTIONS] <FIRST_PASS_DIR>"
100 echo "$0 -h for more info" 101 echo "$0 -h for more info"
101 exit 1 102 exit 1
102 fi 103 fi
103 104
104 shift $((OPTIND-1)) 105 shift $((OPTIND-1))
105 # check FirstPass directory - First argument 106 # check FirstPass directory - First argument
106 if [ -e $1 ] && [ -d $1 ] 107 if [ -e $1 ] && [ -d $1 ]
107 then 108 then
108 FIRSTPASS_DIR=$(readlink -e $1) 109 FIRSTPASS_DIR=$(readlink -e $1)
109 else 110 else
110 print_error "can't find $1 directory" 111 print_error "can't find $1 directory"
111 exit 1 112 exit 1
112 fi 113 fi
113 114
115 print_info "[${BASENAME}] => P2 start | $(date +'%d/%m/%y %H:%M:%S')" 1
116
114 #-------------# 117 #-------------#
115 # GLOBAL VARS # 118 # GLOBAL VARS #
116 #-------------# 119 #-------------#
117 FIRSTPASS_CONFIG_FILE="$FIRSTPASS_DIR/FirstPass.cfg" 120 FIRSTPASS_CONFIG_FILE="$FIRSTPASS_DIR/FirstPass.cfg"
118 if [ -e $FIRSTPASS_CONFIG_FILE ] 121 if [ -e $FIRSTPASS_CONFIG_FILE ]
119 then 122 then
120 WAV_FILE=$(cat $FIRSTPASS_CONFIG_FILE | grep "WAV_FILE=" | cut -f2 -d"=") 123 WAV_FILE=$(cat $FIRSTPASS_CONFIG_FILE | grep "WAV_FILE=" | cut -f2 -d"=")
121 BASENAME=$(cat $FIRSTPASS_CONFIG_FILE | grep "^BASENAME=" | cut -f2 -d"=") 124 BASENAME=$(cat $FIRSTPASS_CONFIG_FILE | grep "^BASENAME=" | cut -f2 -d"=")
122 OUTPUT_DIR=$(cat $FIRSTPASS_CONFIG_FILE | grep "OUTPUT_DIR=" | cut -f2 -d"=") 125 OUTPUT_DIR=$(cat $FIRSTPASS_CONFIG_FILE | grep "OUTPUT_DIR=" | cut -f2 -d"=")
123 OUTPUT_DIR_BASENAME=$FIRSTPASS_DIR 126 OUTPUT_DIR_BASENAME=$FIRSTPASS_DIR
124 PLP_FILE_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "PLP_FILE=" | cut -f2 -d"=") 127 PLP_FILE_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "PLP_FILE=" | cut -f2 -d"=")
125 PLP_DIR_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "PLP_DIR=" | cut -f2 -d"=") 128 PLP_DIR_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "PLP_DIR=" | cut -f2 -d"=")
126 SEG_FILE_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "SEG_FILE=" | cut -f2 -d"=") 129 SEG_FILE_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "SEG_FILE=" | cut -f2 -d"=")
127 LBL_FILE_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "LBL_FILE=" | cut -f2 -d"=") 130 LBL_FILE_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "LBL_FILE=" | cut -f2 -d"=")
128 RES_DIR_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "RES_DIR=" | cut -f2 -d"=") 131 RES_DIR_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "RES_DIR=" | cut -f2 -d"=")
129 else 132 else
130 print_error "can't find $FIRSTPASS_CONFIG_FILE file" 133 print_error "can't find $FIRSTPASS_CONFIG_FILE file"
134 print_error "exit"
131 exit 1 135 exit 1
132 fi 136 fi
133 LST=$OUTPUT_DIR_BASENAME"/lists" 137 LST=$OUTPUT_DIR_BASENAME"/lists"
134 HMM=$OUTPUT_DIR_BASENAME"/hmm/" 138 HMM=$OUTPUT_DIR_BASENAME"/hmm/"
135 RES_DIR=$OUTPUT_DIR_BASENAME"/res_p2" 139 RES_DIR=$OUTPUT_DIR_BASENAME"/res_p2"
136 LOGFILE="$OUTPUT_DIR/info_p2.log" 140 LOGFILE="$OUTPUT_DIR_BASENAME/info_p2.log"
137 ERRORFILE="$OUTPUT_DIR/error_p2.log" 141 ERRORFILE="$OUTPUT_DIR_BASENAME/error_p2.log"
138 142
139 #------------------# 143 #------------------#
140 # Create WORKSPACE # 144 # Create WORKSPACE #
141 #------------------# 145 #------------------#
142 146
143 # Lock directory 147 # Lock directory
144 if [ -e $OUTPUT_DIR_BASENAME/SECONDPASS.lock ] && [ $RERUN -eq 0 ]; then exit 1;fi 148 if [ -e $OUTPUT_DIR_BASENAME/SECONDPASS.lock ] && [ $RERUN -eq 0 ]; then print_warn "[${BASENAME}] SECONDPASS is locked -> exit" 2; exit 1;fi
145 rm "$OUTPUT_DIR_BASENAME/SECONDPASS.unlock" > /dev/null 2>&1 149 rm "$OUTPUT_DIR_BASENAME/SECONDPASS.unlock" > /dev/null 2>&1
146 touch "$OUTPUT_DIR_BASENAME/SECONDPASS.lock" > /dev/null 2>&1 150 touch "$OUTPUT_DIR_BASENAME/SECONDPASS.lock" > /dev/null 2>&1
147 151
148 rm -r $LST > /dev/null 2>&1 152 rm -r $LST > /dev/null 2>&1
149 mkdir -p $LST 153 mkdir -p $LST
150 print_info "Make directory $LST" 1 154 print_info "[${BASENAME}] Make directory $LST" 2
151 if [ $RERUN -eq 0 ]; then rm -r $HMM > /dev/null 2>&1; fi 155 if [ $RERUN -eq 0 ]; then rm -r $HMM > /dev/null 2>&1; fi
152 mkdir -p $HMM 156 mkdir -p $HMM
153 print_info "Make directory $HMM" 1 157 print_info "[${BASENAME}] Make directory $HMM" 2
154 if [ $RERUN -eq 0 ]; then rm -r $RES_DIR > /dev/null 2>&1; fi 158 if [ $RERUN -eq 0 ]; then rm -r $RES_DIR > /dev/null 2>&1; fi
155 mkdir -p $RES_DIR > /dev/null 2>&1 159 mkdir -p $RES_DIR > /dev/null 2>&1
156 print_info "Make directory $RES_DIR" 1 160 print_info "[${BASENAME}] Make directory $RES_DIR" 2
161 rm $LOGFILE $ERRORFILE > /dev/null 2>&1
157 162
158 #-------------------# 163 #-------------------#
159 # Check Pass # 164 # Check Pass #
160 #-------------------# 165 #-------------------#
161 print_info "Check Pass 2 directory" 1 166 print_info "[${BASENAME}] Check Pass 2 directory" 1
162 for treil in $(ls $RES_DIR/ | grep treil) 167 for treil in $(ls $RES_DIR/ | grep treil)
163 do 168 do
164 if [ ! -s $RES_DIR/$treil ] 169 if [ ! -s $RES_DIR/$treil ]
165 then 170 then
166 bn = $(basename $treil ".treil") 171 bn = $(basename $treil ".treil")
167 rm $RES_DIR/$treil $RES_DIR/$bn.seg $RES_DIR/$bn.res $RES_DIR/$bn.pho 2> /dev/null 172 rm $RES_DIR/$treil $RES_DIR/$bn.seg $RES_DIR/$bn.res $RES_DIR/$bn.pho 2> /dev/null
168 print_info "$RES_DIR/$bn.* files deleted.." 2 173 print_info "[${BASENAME}] $RES_DIR/$bn.* files deleted.." 2
169 fi 174 fi
170 done 175 done
171 176
172 # Check if more then 89% of treil are done 177 # Check if more then 89% of treil are done
173 nbres_p1=$(ls $RES_DIR_P1/*.res 2> /dev/null | wc -l) 178 nbres_p1=$(ls $RES_DIR_P1/*.res 2> /dev/null | wc -l)
174 nbtreil_p2=$(ls $RES_DIR/*.treil 2> /dev/null | wc -l) 179 nbtreil_p2=$(ls $RES_DIR/*.treil 2> /dev/null | wc -l)
175 if [ $nbres_p1 -gt 0 ] 180 if [ $nbres_p1 -gt 0 ]
176 then 181 then
177 pourcentage=$((($nbtreil_p2*100)/$nbres_p1)) 182 pourcentage=$((($nbtreil_p2*100)/$nbres_p1))
178 if [ $pourcentage -gt 89 ] 183 if [ $pourcentage -gt 89 ]
179 then 184 then
180 echo "Lattice already done, skipping $BASENAME" 185 print_info "[${BASENAME}] Lattice already done, skipping $BASENAME" 1
181 exit 0 186 exit 0
182 fi 187 fi
188 else
189 print_error "[${BASENAME}] No First Pass, No .res -> exit P2"
190 if [ $CHECK -eq 1 ]; then print_log_file $ERRORFILE "No First Pass, No .res -> exit P2" ;fi
191 exit 1
183 fi 192 fi
184 193
185 #--------------------# 194 #--------------------#
186 # Save configuration # 195 # Save configuration #
187 #--------------------# 196 #--------------------#
188 cp $SECONDPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/SecondPass.cfg 197 cp $SECONDPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/SecondPass.cfg
189 echo "WAV_FILE=$WAV_FILE" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 198 echo "WAV_FILE=$WAV_FILE" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
190 echo "BASENAME=$BASENAME" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 199 echo "BASENAME=$BASENAME" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
191 echo "FIRSTPASS_DIR=$FIRSTPASS_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 200 echo "FIRSTPASS_DIR=$FIRSTPASS_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
192 echo "PLP_DIR_P1=$PLP_DIR_P1" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 201 echo "PLP_DIR_P1=$PLP_DIR_P1" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
193 echo "OUTPUT_DIR=$OUTPUT_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 202 echo "OUTPUT_DIR=$OUTPUT_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
194 echo "OUTPUT_DIR_BASENAME=$OUTPUT_DIR_BASENAME" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 203 echo "OUTPUT_DIR_BASENAME=$OUTPUT_DIR_BASENAME" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
195 echo "LST=$LST" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 204 echo "LST=$LST" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
196 echo "HMM=$HMM" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 205 echo "HMM=$HMM" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
197 echo "RES_DIR=$RES_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 206 echo "RES_DIR=$RES_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
198 print_info "save config in $OUTPUT_DIR_BASENAME/SecondPass.cfg" 1 207 print_info "[${BASENAME}] Save config in $OUTPUT_DIR_BASENAME/SecondPass.cfg" 1
199 208
200 209
201 #--------------------------------------------------# 210 #--------------------------------------------------#
202 # Speaker Adaptation (AM) + Second pass (DECODING) # 211 # Speaker Adaptation (AM) + Second pass (DECODING) #
203 #--------------------------------------------------# 212 #--------------------------------------------------#
204 print_info "Launch Second Pass" 1 213 print_info "[${BASENAME}] Launch Second Pass" 1
205 214
206 # for all speaker 215 # for all speaker
207 for speaker in $(cat $LBL_FILE_P1 | cut -f4 -d" " | sort | uniq) 216 for speaker in $(cat $LBL_FILE_P1 | cut -f4 -d" " | sort | uniq)
208 do 217 do
209 ## get seg file from P1 containing the speaker 218 ## get seg file from P1 containing the speaker
210 find $RES_DIR_P1 -name "*${speaker}.seg" -exec basename "{}" .seg \; | sort > $LST/$speaker.lst 219 find $RES_DIR_P1 -name "*${speaker}.seg" -exec basename "{}" .seg \; | sort > $LST/$speaker.lst
211 print_info "file for $speaker in $LST/$speaker.lst" 3 220 print_info "[${BASENAME}] file for $speaker in $LST/$speaker.lst" 3
212 if [ ! -s $LST/$speaker.lst ]; then print_warn "no ${speaker} file in $RES_DIR_P1" 3; continue; fi 221 if [ ! -s $LST/$speaker.lst ]; then print_warn "no ${speaker} file in $RES_DIR_P1" 3; continue; fi
213 222
214 223
215 # for all AM 224 # for all AM
216 for (( i=0; $i<${#MTAG[@]} ; i++ )) 225 for (( i=0; $i<${#MTAG[@]} ; i++ ))
217 do 226 do
218 if [ -e $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst ]; then 227 if [ -e $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst ]; then
219 type=$(grep -e "${speaker}$" "$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst") 228 type=$(grep -e "${speaker}$" "$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst")
220 ## if is the good AM for the speaker 229 ## if is the good AM for the speaker
221 if [ -n "$type" ] 230 if [ -n "$type" ]
222 then 231 then
223 ## HMM adaptation 232 ## HMM adaptation
224 if [ $RERUN -eq 0 ] || ( [ ! -e $HMM/$speaker.hmm ] || [ -z $HMM/$speaker.hmm ] ) 233 if [ $RERUN -eq 0 ] || ( [ ! -e $HMM/$speaker.hmm ] || [ -z $HMM/$speaker.hmm ] )
225 then 234 then
226 print_info "$SPEERAL_TOOLS/mllrmap $SPEERAL_AM/${MODS[$i]}.hmm -LR -b$LST/$speaker.lst -d$PLP_DIR_P1/ -t.plp -i3 -c.seg -o$HMM/$speaker.hmm -a$RES_DIR_P1/" 3 235 print_info "[${BASENAME}] $SPEERAL_TOOLS/mllrmap $SPEERAL_AM/${MODS[$i]}.hmm -LR -b$LST/$speaker.lst -d$PLP_DIR_P1/ -t.plp -i3 -c.seg -o$HMM/$speaker.hmm -a$RES_DIR_P1/" 3
227 $SPEERAL_TOOLS/mllrmap $SPEERAL_AM/${MODS[$i]}.hmm -LR -b$LST/$speaker.lst -d$PLP_DIR_P1/ -t.plp -i3 -c.seg -o$HMM/$speaker.hmm -a$RES_DIR_P1/ $REDIRECTION_OUTPUT 236 $SPEERAL_TOOLS/mllrmap $SPEERAL_AM/${MODS[$i]}.hmm -LR -b$LST/$speaker.lst -d$PLP_DIR_P1/ -t.plp -i3 -c.seg -o$HMM/$speaker.hmm -a$RES_DIR_P1/ $REDIRECTION_OUTPUT
228 fi 237 fi
229 238
230 if [ $CHECK -eq 1 ] && ( [ ! -e $HMM/$speaker.hmm ] || [ -z $HMM/$speaker.hmm ] ) 239 if [ $CHECK -eq 1 ] && ( [ ! -e $HMM/$speaker.hmm ] || [ -z $HMM/$speaker.hmm ] )
231 then 240 then
232 echo "ERROR [$(date +'%d/%m/%y %H:%M:%S')] $HMM/$speaker.hmm" >> $ERRORFILE 241 print_warn "[${BASENAME}] No hmm files created for $speaker" 2
242 print_log_file $ERRORFILE "ERROR [$(date +'%d/%m/%y %H:%M:%S')] No hmm files created for $speaker"
243 print_error "[${BASENAME}] Check $ERRORFILE"
233 #exit 1 244 #exit 1
234 fi 245 fi
235 246
236 ## cp map files 247 ## cp map files
237 cp $SPEERAL_AM/${MODS[$i]}.map $HMM/$speaker.map 248 cp $SPEERAL_AM/${MODS[$i]}.map $HMM/$speaker.map
238 249
239 ## class clustering 250 ## class clustering
240 if [ -s $HMM/$speaker.hmm ] && ( [ $RERUN -eq 0 ] || ( [ ! -e $HMM/$speaker.cls ] || [ -z $HMM/$speaker.cls ] )) 251 if [ -s $HMM/$speaker.hmm ] && ( [ $RERUN -eq 0 ] || ( [ ! -e $HMM/$speaker.cls ] || [ -z $HMM/$speaker.cls ] ))
241 then 252 then
242 print_info "$SPEERAL_TOOLS/gclust_pdf $HMM/$speaker.hmm $HMM/$speaker.cls -i $SPEERAL_AM/${MODS[$i]}.cls" 3 253 print_info "[${BASENAME}] $SPEERAL_TOOLS/gclust_pdf $HMM/$speaker.hmm $HMM/$speaker.cls -i $SPEERAL_AM/${MODS[$i]}.cls" 3
243 $SPEERAL_TOOLS/gclust_pdf $HMM/$speaker.hmm $HMM/$speaker.cls -i $SPEERAL_AM/${MODS[$i]}.cls $REDIRECTION_OUTPUT 254 $SPEERAL_TOOLS/gclust_pdf $HMM/$speaker.hmm $HMM/$speaker.cls -i $SPEERAL_AM/${MODS[$i]}.cls $REDIRECTION_OUTPUT
244 fi 255 fi
245 if [ $CHECK -eq 1 ] && ( [ ! -e $HMM/$speaker.cls ] || [ -z $HMM/$speaker.cls ] ) 256 if [ $CHECK -eq 1 ] && ( [ ! -e $HMM/$speaker.cls ] || [ -z $HMM/$speaker.cls ] )
246 then 257 then
247 echo "ERROR [$(date +'%d/%m/%y %H:%M:%S')] $HMM/$speaker.cls" >> $ERRORFILE 258 print_warn "[${BASENAME}] No cls file created for $speaker" 2
259 print_log_file $ERRORFILE "ERROR [$(date +'%d/%m/%y %H:%M:%S')] No cls file created for $speakers"
260 print_error "[${BASENAME}] Check $ERRORFILE"
248 #exit 1 261 #exit 1
249 fi 262 fi
250 263
251 ## Speeral decoding 264 ## Speeral decoding
252 if [ -s $HMM/$speaker.hmm ] && [ -s $HMM/$speaker.cls ] 265 if [ -s $HMM/$speaker.hmm ] && [ -s $HMM/$speaker.cls ]
253 then 266 then
254 print_info "$SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_CFG[$i]} -r $PLP_DIR_P1 -m $HMM/$speaker.hmm -c $HMM/$speaker.cls $FORKS --lock $REDIRECTION_OUTPUT" 3 267 print_info "[${BASENAME}] $SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_CFG[$i]} -r $PLP_DIR_P1 -m $HMM/$speaker.hmm -c $HMM/$speaker.cls $FORKS --lock $REDIRECTION_OUTPUT" 3
255 $SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_CFG[$i]} -r $PLP_DIR_P1 -m $HMM/$speaker.hmm -c $HMM/$speaker.cls $FORKS --lock $REDIRECTION_OUTPUT 268 $SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_CFG[$i]} -r $PLP_DIR_P1 -m $HMM/$speaker.hmm -c $HMM/$speaker.cls $FORKS --lock $REDIRECTION_OUTPUT
256 else 269 else
257 print_warn "$HMM/$speaker.hmm and $speaker.cls empty, do default decoding..." 2 270 print_warn "[${BASENAME}] $HMM/$speaker.hmm and $speaker.cls empty, do default decoding..." 2
271 print_info "[${BASENAME}] $SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_CFG[$i]} -r $PLP_DIR_P1 -m $SPEERAL_AM/${MODS[$i]}.hmm -c $SPEERAL_AM/${MODS[$i]}.cls $FORKS --lock $REDIRECTION_OUTPUT" 3
258 $SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_CFG[$i]} -r $PLP_DIR_P1 -m $SPEERAL_AM/${MODS[$i]}.hmm -c $SPEERAL_AM/${MODS[$i]}.cls $FORKS --lock $REDIRECTION_OUTPUT 272 $SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_CFG[$i]} -r $PLP_DIR_P1 -m $SPEERAL_AM/${MODS[$i]}.hmm -c $SPEERAL_AM/${MODS[$i]}.cls $FORKS --lock $REDIRECTION_OUTPUT
259 fi 273 fi
260 274
261 if [ $CHECK -eq 1 ] 275 if [ $CHECK -eq 1 ]
262 then 276 then
263 check_second_pass_output_speeral "$LST/$speaker.lst" "$RES_DIR" 277 check_second_pass_output_speeral "$LST/$speaker.lst" "$RES_DIR"
264 if [ $? -eq 1 ] 278 if [ $? -eq 1 ]
265 then 279 then
266 echo -e "ERROR : Speeral $LST/$speaker.lst\n[" >> $ERRORFILE 280 print_warn "[${BASENAME}] Speeral output error : check $LOGFILE" 2
281 print_log_file $LOGFILE "WARN : Speeral number of output ERROR $LST/$speaker.lst"
267 ls $RES_DIR/*.seg | grep -e "$speaker" | sed -e "s|$RES_DIR\/||" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp 282 ls $RES_DIR/*.seg | grep -e "$speaker" | sed -e "s|$RES_DIR\/||" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp
268 diff $LST/$speaker.lst ${OUTPUT_DIR_BASENAME}/.tmp >> $ERRORFILE 283 print_log_file $LOGFILE "Segs (and treil) not done :\n["
269 echo -e "] " >> $ERRORFILE 284 diff $LST/$speaker.lst ${OUTPUT_DIR_BASENAME}/.tmp >> $LOGFILE
285 print_log_file $LOGFILE "] [$(date +'%d/%m/%y %H:%M:%S')]"
270 rm ${OUTPUT_DIR_BASENAME}/.tmp 286 rm ${OUTPUT_DIR_BASENAME}/.tmp
271 #exit 1 287 #exit 1
272 fi 288 fi
273 fi 289 fi
274 break 290 break
275 fi 291 fi
276 fi 292 fi
277 done 293 done
278 #rm "$HMM/$speaker.*" > /dev/null 2>&1 294 #rm "$HMM/$speaker.*" > /dev/null 2>&1
279 #rm "$LST/$speaker.lst" > /dev/null 2>&1 295 #rm "$LST/$speaker.lst" > /dev/null 2>&1
280 done 296 done
281 297
282 print_info "<= End $BASENAME P2 | $(date +'%d/%m/%y %H:%M:%S')" 1
283
284 ## Check missing seg and log it 298 ## Check missing seg and log it
285 ls $RES_DIR/*.treil | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.treil//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp 299 if [ $CHECK -eq 1 ]
286 echo -e "$BASENAME P2 END\n[" >> $LOGFILE 300 then
287 diff ${OUTPUT_DIR_BASENAME}/plp.lst ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> $LOGFILE 301 ls $RES_DIR/*.treil | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.treil//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp
288 echo -e "] $BASENAME" >> $LOGFILE 302 todo=$(cat ${PLP_FILE_P1} | wc -l)
289 rm ${OUTPUT_DIR_BASENAME}/.tmp > /dev/null 2>&1 303 if [ $todo -eq 0 ]; then todo=1;fi
304 notdone=$(($todo - $(cat ${OUTPUT_DIR_BASENAME}/.tmp | wc -l)))
305 pourcentage=$((($notdone*100)/$todo))
306 if [ $notdone -ne 0 ]
307 then
308 print_error "[${BASENAME}] ERROR : check $ERRORFILE"
309 print_log_file "$ERRORFILE" "ERROR : Treil not done ["
310 diff ${PLP_FILE_P1} ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> $ERRORFILE
311 print_log_file "$ERRORFILE" "] $pourcentage% $BASENAME"
312 else
313 print_log_file "$LOGFILE" "P1 OK $BASENAME | $(date +'%d/%m/%y %H:%M:%S')"
314 fi
315 rm ${OUTPUT_DIR_BASENAME}/.tmp > /dev/null 2>&1
316 fi
290 317
291 #---------------# 318 #---------------#
292 # Convert res # 319 # Convert res #
293 #---------------# 320 #---------------#
294 321
322 print_info "[${BASENAME}] Convert .res into .ctm" 1
295 # .res => .ctm 323 # .res => .ctm
296 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.2pass.ctm $REDIRECTION_OUTPUT 324 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.2pass.ctm $REDIRECTION_OUTPUT
325 print_info "[${BASENAME}] Convert .res into .trs" 1
297 # .res => .trs 326 # .res => .trs
298 echo -e "name $AUTHOR\nfileName ${BASENAME}\nfileExt wav\nsegFile ${OUTPUT_DIR_BASENAME}/${BASENAME}.seg" > ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg 327 echo -e "name $AUTHOR\nfileName ${BASENAME}\nfileExt wav\nsegFile ${OUTPUT_DIR_BASENAME}/${BASENAME}.seg" > ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg
299 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TRS --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.2pass.trs --trs_config ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg $REDIRECTION_OUTPUT 328 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TRS --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.2pass.trs --trs_config ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg $REDIRECTION_OUTPUT
300 rm ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg > /dev/null 2>&1 329 rm ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg > /dev/null 2>&1
330 print_info "[${BASENAME}] Convert .res into .txt" 1
301 # .res => .txt 331 # .res => .txt
302 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.2pass.txt $REDIRECTION_OUTPUT 332 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.2pass.txt $REDIRECTION_OUTPUT
303 333
304 334 print_info "[${BASENAME}] <= P2 End | $(date +'%d/%m/%y %H:%M:%S')" 1
305 # unlock directory 335 # unlock directory
306 mv "$OUTPUT_DIR_BASENAME/SECONDPASS.lock" "$OUTPUT_DIR_BASENAME/SECONDPASS.unlock" 336 mv "$OUTPUT_DIR_BASENAME/SECONDPASS.lock" "$OUTPUT_DIR_BASENAME/SECONDPASS.unlock"
tools/scripts/CheckConfPass.sh
1 #!/bin/bash 1 #!/bin/bash
2 2
3 ################################################# 3 #################################################
4 # File : CheckConfPass.sh # 4 # File : CheckConfPass.sh #
5 # Brief : Check Conf Pass # 5 # Brief : Check Conf 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/ConfPass.cfg" 12 . "$OTMEDIA_HOME/cfg/ConfPass.cfg"
13 13
14 # check_conf_pass_usf(usffilenamefullpath) 14 # check_conf_pass_usf(usffilenamefullpath)
15 # -usffilenamefullpath : full path to usf file 15 # -usffilenamefullpath : full path to usf file
16 # return 0 if ok, otherwise return 1 16 # return 0 if ok, otherwise return 1
17 function check_conf_pass_usf() 17 function check_conf_pass_usf()
18 { 18 {
19 if [ $# -ne 1 ] 19 if [ $# -ne 1 ]
20 then 20 then
21 if [ -e "$1" ] && [ -s "$1" ] 21 if [ -e "$1" ] && [ -s "$1" ]
22 then 22 then
23 temp=`grep -c -E 'confidence="0.600"' "$1"` 23 conftozerosix=$(grep -c -E 'confidence="0.600"' "$1")
24 if [ $temp -gt 200 ] 24 confall=$(grep -c -E 'confidence=' "$1")
25 if [ $confall -gt 0 ]
25 then 26 then
26 return 1 27 pourcentageofzerosix=$((($conftozerosix*100)/$confall))
28 if [ $pourcentageofzerosix -gt 49 ]
29 then
30 return 1
31
32 else
33 return 0
34 fi
27 fi 35 fi
28 else 36 else
29 return 1 37 return 1
30 fi 38 fi
31 fi 39 fi
32
33 return 0 40 return 0
34 } 41 }
35 42
36 43
37 44
38 45
39 46
40 47