Commit c8737cbd9ec2627c4a03389ce3ce16d5ca468516

Authored by Jean-François Rey
1 parent 3aadb22616
Exists in master

bugfix info on res not done

Showing 4 changed files with 73 additions and 20 deletions Inline Diff

1 ___ _____ __ __ _____ ____ ___ _ _ ___ _
2 / _ \_ _| \/ | ____| _ \_ _| / \ | | |_ _| / \
3 | | | || | | |\/| | _| | | | | | / _ \ | | | | / _ \
4 | |_| || | | | | | |___| |_| | | / ___ \ | |___ | | / ___ \
5 \___/ |_| |_| |_|_____|____/___/_/ \_\ |_____|___/_/ \_\
6
7
1 #-------------------# 8 #-------------------#
2 # OTMEDIA README # 9 # OTMEDIA LIA #
10 # README #
3 # version 1.0 # 11 # version 1.0 #
4 #-------------------# 12 #-------------------#
5 13
6 "Observatoire Transmedia pour l'étude des évolutions et transformations du monde médiatique" 14 DESCRIPTION
15 -----------
7 16
8 OTMEDIA_HOME 17 OTMEDIA means "Observatoire Transmedia", its main objective is to study the evolution and transformation of the media world.
9 install.sh 18 The scientific objective of the project is the creation of a new generation of media observatory
19 based on an interactive automatic analysis system (semi-automatic) transmedia to understand
20 the world of information and developments.
10 21
11 Modif a la main de fichier si on veut 22 Web Site : http://www.otmedia.fr
12 23
13 install solr + tomcat 24 OTMEDIA LIA project is a set of tools to transcribe radio and TV shows.
25
26 DEPENDENCIES
27 ------------
28
29
30
31 INSTALLATION
32 ------------
33
34 See the INSTALL file for the installation procedure.
35
36 Quick install below.
37
38 Before launch installation :
39
40 Be certain that all dependencies are satisfied.
41
42 Issue the following commands to the shell :
43 $> ./install.sh
44 $> export OTMEDIA_HOME=path/to/OTMEDIA/directory
45
46
47 ACKNOWLEDGEMENTS
48 ----------------
49 Many thanks to Jean-François Rey for useful help.
50
51 KNOWN BUGS
52 ----------
53 Many.
54
55 COPYRIGHT
56 ---------
57 See the COPYING file.
58
59 AUTHORS
60 -------
61 Jean-François Rey <jean-francois.rey@univ-avignon.fr>
62 Hugo Mauchrétien <hugo.mauchretien@univ-avignon.fr>
63 Emmanuel Ferreira <emmanuel.ferreira@univ-avignon.fr>
14 64
15 65
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 echo "### FirstPass.sh ###" 13 echo "### FirstPass.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 # where is FirstPass.sh 22 # where is FirstPass.sh
23 MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0)) 23 MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0))
24 24
25 # scripts path 25 # scripts path
26 SCRIPT_PATH=$OTMEDIA_HOME/tools/scripts 26 SCRIPT_PATH=$OTMEDIA_HOME/tools/scripts
27 27
28 # Include scripts 28 # Include scripts
29 . $SCRIPT_PATH"/Tools.sh" 29 . $SCRIPT_PATH"/Tools.sh"
30 . $SCRIPT_PATH"/CheckFirstPass.sh" 30 . $SCRIPT_PATH"/CheckFirstPass.sh"
31 31
32 # where is FirstPass.cfg 32 # where is FirstPass.cfg
33 FIRSTPASS_CONFIG_FILE=$OTMEDIA_HOME"/cfg/FirstPass.cfg" 33 FIRSTPASS_CONFIG_FILE=$OTMEDIA_HOME"/cfg/FirstPass.cfg"
34 if [ -e $FIRSTPASS_CONFIG_FILE ] 34 if [ -e $FIRSTPASS_CONFIG_FILE ]
35 then 35 then
36 . $FIRSTPASS_CONFIG_FILE 36 . $FIRSTPASS_CONFIG_FILE
37 else 37 else
38 echo "ERROR : Can't find configuration file $FIRSTPASS_CONFIG_FILE" >&2 38 echo "ERROR : Can't find configuration file $FIRSTPASS_CONFIG_FILE" >&2
39 echo "exit" >&2 39 echo "exit" >&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:cf:r" opt 46 while getopts ":hDv:cf:r" opt
47 do 47 do
48 case $opt in 48 case $opt in
49 h) 49 h)
50 echo -e "$0 [OPTIONS] <WAV_FILE> <OUTPUT_DIRECTORY>\n" 50 echo -e "$0 [OPTIONS] <WAV_FILE> <OUTPUT_DIRECTORY>\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 :\tCheck process, and log it into files, can stop if error detected" 55 echo -e "\t\t-c :\tCheck process, and log it into files, can stop if error detected"
56 echo -e "\t\t-f n :\tspecify a speeral forks number (default 1)" 56 echo -e "\t\t-f n :\tspecify a speeral forks number (default 1)"
57 echo -e "\t\t-r :\tforce rerun the wav file" 57 echo -e "\t\t-r :\tforce rerun the wav file"
58 exit 1 58 exit 1
59 ;; 59 ;;
60 D) 60 D)
61 DEBUG=1 61 DEBUG=1
62 ;; 62 ;;
63 v) 63 v)
64 VERBOSE=$OPTARG 64 VERBOSE=$OPTARG
65 ;; 65 ;;
66 c) 66 c)
67 CHECK=1 67 CHECK=1
68 ;; 68 ;;
69 f) 69 f)
70 FORKS="--forks $OPTARG" 70 FORKS="--forks $OPTARG"
71 ;; 71 ;;
72 r) 72 r)
73 RERUN=1 73 RERUN=1
74 ;; 74 ;;
75 :) 75 :)
76 echo "Option -$OPTARG requires an argument." >&2 76 echo "Option -$OPTARG requires an argument." >&2
77 exit 1 77 exit 1
78 ;; 78 ;;
79 \?) 79 \?)
80 echo "BAD USAGE : unknow opton -$OPTARG" 80 echo "BAD USAGE : unknow opton -$OPTARG"
81 exit 1 81 exit 1
82 ;; 82 ;;
83 esac 83 esac
84 done 84 done
85 85
86 # mode debug enable 86 # mode debug enable
87 if [ $DEBUG -eq 1 ] 87 if [ $DEBUG -eq 1 ]
88 then 88 then
89 set -x 89 set -x
90 echo -e "## Mode DEBUG ON ##" 90 echo -e "## Mode DEBUG ON ##"
91 fi 91 fi
92 92
93 # mode verbose enable 93 # mode verbose enable
94 if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ;fi 94 if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ;fi
95 95
96 # Check USAGE by arguments number 96 # Check USAGE by arguments number
97 if [ $(($#-($OPTIND-1))) -ne 2 ] 97 if [ $(($#-($OPTIND-1))) -ne 2 ]
98 then 98 then
99 echo "BAD USAGE : FirstPass.sh [OPTIONS] <WAV_FILE> <OUTPUT_DIR>" 99 echo "BAD USAGE : FirstPass.sh [OPTIONS] <WAV_FILE> <OUTPUT_DIR>"
100 echo "$0 -h for more info" 100 echo "$0 -h for more info"
101 exit 1 101 exit 1
102 fi 102 fi
103 103
104 shift $((OPTIND-1)) 104 shift $((OPTIND-1))
105 # check audio file - First argument 105 # check audio file - First argument
106 if [ -e $1 ] && [ -s $1 ] 106 if [ -e $1 ] && [ -s $1 ]
107 then 107 then
108 # absolute path to wav file 108 # absolute path to wav file
109 WAV_FILE=$(readlink -e $1) 109 WAV_FILE=$(readlink -e $1)
110 # wav filename 110 # wav filename
111 FILENAME=$(basename $WAV_FILE) 111 FILENAME=$(basename $WAV_FILE)
112 # wav filename without extension 112 # wav filename without extension
113 BASENAME=${FILENAME%.*} 113 BASENAME=${FILENAME%.*}
114 114
115 print_info "[${BASENAME}] => P1 start | $(date +'%d/%m/%y %H:%M:%S')" 1 115 print_info "[${BASENAME}] => P1 start | $(date +'%d/%m/%y %H:%M:%S')" 1
116 print_info "[${BASENAME}] $WAV_FILE OK" 2 116 print_info "[${BASENAME}] $WAV_FILE OK" 2
117 else 117 else
118 print_error " Can't find $1 OR file is empty" 118 print_error " Can't find $1 OR file is empty"
119 exit 1 119 exit 1
120 fi 120 fi
121 121
122 # check output directory - Second argument 122 # check output directory - Second argument
123 if [ ! -e $2 ] 123 if [ ! -e $2 ]
124 then 124 then
125 mkdir -p $2 125 mkdir -p $2
126 print_info "[${BASENAME}] Make directory $2" 2 126 print_info "[${BASENAME}] Make directory $2" 2
127 fi 127 fi
128 128
129 129
130 #-------------# 130 #-------------#
131 # GLOBAL VARS # 131 # GLOBAL VARS #
132 #-------------# 132 #-------------#
133 OUTPUT_DIR=$(readlink -e $2) # Output directory absolute path 133 OUTPUT_DIR=$(readlink -e $2) # Output directory absolute path
134 OUTPUT_DIR_BASENAME="$OUTPUT_DIR/$BASENAME/" # New OUTPUT_DIR with BASENAME 134 OUTPUT_DIR_BASENAME="$OUTPUT_DIR/$BASENAME/" # New OUTPUT_DIR with BASENAME
135 PLP_FILE="$OUTPUT_DIR_BASENAME/$BASENAME.plp" # Global PLP file 135 PLP_FILE="$OUTPUT_DIR_BASENAME/$BASENAME.plp" # Global PLP file
136 PLP_DIR="$OUTPUT_DIR_BASENAME/PLP/" # Segmented PLP files directory 136 PLP_DIR="$OUTPUT_DIR_BASENAME/PLP/" # Segmented PLP files directory
137 PLP_LIST="$OUTPUT_DIR_BASENAME/plp.lst" # list of plp files
137 SEG_FILE="$OUTPUT_DIR_BASENAME/$BASENAME.seg" # Global Seg file 138 SEG_FILE="$OUTPUT_DIR_BASENAME/$BASENAME.seg" # Global Seg file
138 LBL_FILE="$OUTPUT_DIR_BASENAME/$BASENAME.lbl" # Global LBL file 139 LBL_FILE="$OUTPUT_DIR_BASENAME/$BASENAME.lbl" # Global LBL file
139 RES_DIR=$OUTPUT_DIR_BASENAME"/res_p1" 140 RES_DIR=$OUTPUT_DIR_BASENAME"/res_p1"
140 LOGFILE="$OUTPUT_DIR_BASENAME/info_p1.log" 141 LOGFILE="$OUTPUT_DIR_BASENAME/info_p1.log"
141 ERRORFILE="$OUTPUT_DIR_BASENAME/error_p1.log" 142 ERRORFILE="$OUTPUT_DIR_BASENAME/error_p1.log"
142 143
143 #------------------# 144 #------------------#
144 # Create WORKSPACE # 145 # Create WORKSPACE #
145 #------------------# 146 #------------------#
146 if [ ! -e $OUTPUT_DIR_BASENAME ] 147 if [ ! -e $OUTPUT_DIR_BASENAME ]
147 then 148 then
148 mkdir -p $OUTPUT_DIR_BASENAME 149 mkdir -p $OUTPUT_DIR_BASENAME
149 print_info "[${BASENAME}] Make directory $OUTPUT_DIR_BASENAME" 2 150 print_info "[${BASENAME}] Make directory $OUTPUT_DIR_BASENAME" 2
150 fi 151 fi
151 152
152 # Lock directory 153 # Lock directory
153 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
154 rm "$OUTPUT_DIR_BASENAME/FIRSTPASS.unlock" > /dev/null 2>&1 155 rm "$OUTPUT_DIR_BASENAME/FIRSTPASS.unlock" > /dev/null 2>&1
155 touch "$OUTPUT_DIR_BASENAME/FIRSTPASS.lock" > /dev/null 2>&1 156 touch "$OUTPUT_DIR_BASENAME/FIRSTPASS.lock" > /dev/null 2>&1
156 157
157 rm -r $PLP_DIR > /dev/null 2>&1; 158 rm -r $PLP_DIR > /dev/null 2>&1;
158 mkdir -p $PLP_DIR 159 mkdir -p $PLP_DIR
159 print_info "[${BASENAME}] Make directory $PLP_DIR" 2 160 print_info "[${BASENAME}] Make directory $PLP_DIR" 2
160 if [ $RERUN -eq 0 ]; 161 if [ $RERUN -eq 0 ];
161 then 162 then
162 rm -r $RES_DIR > /dev/null 2>&1; 163 rm -r $RES_DIR > /dev/null 2>&1;
163 else 164 else
164 rm $RES_DIR/*.lock > /dev/null 2>&1 165 rm $RES_DIR/*.lock > /dev/null 2>&1
165 fi 166 fi
166 mkdir -p $RES_DIR > /dev/null 2>&1 167 mkdir -p $RES_DIR > /dev/null 2>&1
167 print_info "[${BASENAME}] Make directory $RES_DIR" 2 168 print_info "[${BASENAME}] Make directory $RES_DIR" 2
168 rm $LOGFILE $ERRORFILE > /dev/null 2>&1 169 rm $LOGFILE $ERRORFILE > /dev/null 2>&1
169 170
170 #--------------------# 171 #--------------------#
171 # Save configuration # 172 # Save configuration #
172 #--------------------# 173 #--------------------#
173 cp $FIRSTPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/FirstPass.cfg 174 cp $FIRSTPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/FirstPass.cfg
174 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
175 echo "WAV_FILE=$WAV_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 176 echo "WAV_FILE=$WAV_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
176 echo "BASENAME=$BASENAME" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 177 echo "BASENAME=$BASENAME" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
177 echo "OUTPUT_DIR=$OUTPUT_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 178 echo "OUTPUT_DIR=$OUTPUT_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
178 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
179 echo "PLP_FILE=$PLP_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 180 echo "PLP_FILE=$PLP_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
180 echo "PLP_DIR=$PLP_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 181 echo "PLP_DIR=$PLP_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
182 echo "PLP_LIST=$PLP_LIST" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
181 echo "SEG_FILE=$SEG_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 183 echo "SEG_FILE=$SEG_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
182 echo "LBL_FILE=$LBL_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 184 echo "LBL_FILE=$LBL_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
183 echo "RES_DIR=$RES_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 185 echo "RES_DIR=$RES_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
184 print_info "[${BASENAME}] Save config in $OUTPUT_DIR_BASENAME/FirstPass.cfg" 1 186 print_info "[${BASENAME}] Save config in $OUTPUT_DIR_BASENAME/FirstPass.cfg" 1
185 187
186 #-------------------------# 188 #-------------------------#
187 # Check Audio File Format # 189 # Check Audio File Format #
188 #-------------------------# 190 #-------------------------#
189 error=0 191 error=0
190 temp=$(avconv -i $WAV_FILE 2>&1 | grep "16000 Hz") 192 temp=$(avconv -i $WAV_FILE 2>&1 | grep "16000 Hz")
191 if [ -z "$temp" ]; then error=1; fi 193 if [ -z "$temp" ]; then error=1; fi
192 temp=$(avconv -i $WAV_FILE 2>&1 | grep "1 channels") 194 temp=$(avconv -i $WAV_FILE 2>&1 | grep "1 channels")
193 if [ -z "$temp" ]; then error=1; fi 195 if [ -z "$temp" ]; then error=1; fi
194 temp=$(avconv -i $WAV_FILE 2>&1 | grep "s16") 196 temp=$(avconv -i $WAV_FILE 2>&1 | grep "s16")
195 if [ -z "$temp" ]; then error=1; fi 197 if [ -z "$temp" ]; then error=1; fi
196 198
197 if [ $error -eq 1 ] 199 if [ $error -eq 1 ]
198 then 200 then
199 print_message $WARNING 2 "[${BASENAME}] $WAV_FILE is not a wav file at 16000 Hz, 1 channel, 16bits\nhave to convert" 201 print_message $WARNING 2 "[${BASENAME}] $WAV_FILE is not a wav file at 16000 Hz, 1 channel, 16bits\nhave to convert"
200 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 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 avconv -i $WAV_FILE -threads 4 -vn -f wav -ac 1 -ar 16000 -ab 256000 $OUTPUT_DIR_BASENAME/$BASENAME.wav 203 avconv -i $WAV_FILE -threads 4 -vn -f wav -ac 1 -ar 16000 -ab 256000 $OUTPUT_DIR_BASENAME/$BASENAME.wav
202 WAV_FILE=$OUTPUT_DIR_BASENAME/$BASENAME.wav 204 WAV_FILE=$OUTPUT_DIR_BASENAME/$BASENAME.wav
203 FILENAME=$BASENAME.wav 205 FILENAME=$BASENAME.wav
204 print_message $INFO 1 "[${BASENAME}] new wav file : $WAV_FILE" 206 print_message $INFO 1 "[${BASENAME}] new wav file : $WAV_FILE"
205 fi 207 fi
206 208
207 #---------------# 209 #---------------#
208 # Get SRT file # 210 # Get SRT file #
209 #---------------# 211 #---------------#
210 if [ -s $(dirname $WAV_FILE)/$BASENAME.SRT ] 212 if [ -s $(dirname $WAV_FILE)/$BASENAME.SRT ]
211 then 213 then
212 cp $(dirname $WAV_FILE)/$BASENAME.SRT $OUTPUT_DIR_BASENAME/$BASENAME.SRT 214 cp $(dirname $WAV_FILE)/$BASENAME.SRT $OUTPUT_DIR_BASENAME/$BASENAME.SRT
213 print_info "[${BASENAME}] copy $BASENAME.SRT file into $OUTPUT_DIR_BASENAME" 3 215 print_info "[${BASENAME}] copy $BASENAME.SRT file into $OUTPUT_DIR_BASENAME" 3
214 fi 216 fi
215 217
216 #------------# 218 #------------#
217 # WAV -> PLP # 219 # WAV -> PLP #
218 #------------# 220 #------------#
219 print_info "[${BASENAME}] convert WAV -> PLP" 1 221 print_info "[${BASENAME}] convert WAV -> PLP" 1
220 echo $FILENAME > $OUTPUT_DIR_BASENAME/list.tmp 222 echo $FILENAME > $OUTPUT_DIR_BASENAME/list.tmp
221 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 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 224
223 $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 225 $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
224 226
225 if [ $CHECK -eq 1 ] 227 if [ $CHECK -eq 1 ]
226 then 228 then
227 check_first_pass_plp "$PLP_FILE" 229 check_first_pass_plp "$PLP_FILE"
228 if [ $? -eq 1 ] 230 if [ $? -eq 1 ]
229 then 231 then
230 print_log_file "$ERROFILE" "ERROR [$(date +'%d/%m/%y %H:%M:%S')] Creating PLP file : $PLP_FILE" 232 print_log_file "$ERROFILE" "ERROR [$(date +'%d/%m/%y %H:%M:%S')] Creating PLP file : $PLP_FILE"
231 print_error "[${BASENAME}] -> exit, Check $ERRORFILE file" 233 print_error "[${BASENAME}] -> exit, Check $ERRORFILE file"
232 exit 1 234 exit 1
233 fi 235 fi
234 fi 236 fi
235 237
236 rm $OUTPUT_DIR_BASENAME/list.tmp 2> /dev/null 238 rm $OUTPUT_DIR_BASENAME/list.tmp 2> /dev/null
237 239
238 #------------------------------# 240 #------------------------------#
239 # S/NS + SPEAKERS SEGMENTATION # 241 # S/NS + SPEAKERS SEGMENTATION #
240 #------------------------------# 242 #------------------------------#
241 print_info "[${BASENAME}] Launch speakers diarization" 1 243 print_info "[${BASENAME}] Launch speakers diarization" 1
242 # Calcul seg file 244 # Calcul seg file
243 print_info "[${BASENAME}] java -Xmx4096m -jar $BIN_PATH/LIUM_SpkDiarization-4.2.jar --fInputMask=${WAV_FILE} --sOutputMask=${SEG_FILE} $BASENAME" 3 245 print_info "[${BASENAME}] java -Xmx4096m -jar $BIN_PATH/LIUM_SpkDiarization-4.2.jar --fInputMask=${WAV_FILE} --sOutputMask=${SEG_FILE} $BASENAME" 3
244 #java -Xmx8000m -Xms2048 -jar $BIN_PATH/LIUM_SpkDiarization-4.2.jar --fInputMask=${WAV_FILE} --sOutputMask=${SEG_FILE} $BASENAME 246 #java -Xmx8000m -Xms2048 -jar $BIN_PATH/LIUM_SpkDiarization-4.2.jar --fInputMask=${WAV_FILE} --sOutputMask=${SEG_FILE} $BASENAME
245 java -Xmx4096m -jar $BIN_PATH/LIUM_SpkDiarization-4.2.jar --fInputMask=${WAV_FILE} --sOutputMask=${SEG_FILE} $BASENAME #–doCEClustering 247 java -Xmx4096m -jar $BIN_PATH/LIUM_SpkDiarization-4.2.jar --fInputMask=${WAV_FILE} --sOutputMask=${SEG_FILE} $BASENAME #–doCEClustering
246 248
247 if [ $CHECK -eq 1 ] && ( [ ! -e $SEG_FILE ] || [ -z $SEG_FILE ] ) 249 if [ $CHECK -eq 1 ] && ( [ ! -e $SEG_FILE ] || [ -z $SEG_FILE ] )
248 then 250 then
249 print_log_file "$ERRORFILE" "ERROR [$(date +'%d/%m/%y %H:%M:%S')] Creating SEG file : $SEG_FILE" 251 print_log_file "$ERRORFILE" "ERROR [$(date +'%d/%m/%y %H:%M:%S')] Creating SEG file : $SEG_FILE"
250 print_error "[${BASENAME}] Check $ERRORFILE file" 252 print_error "[${BASENAME}] Check $ERRORFILE file"
251 exit 1 253 exit 1
252 fi 254 fi
253 255
254 256
255 # Create LBL file 257 # Create LBL file
256 print_info "Extract LBL file from SEG file" 1 258 print_info "Extract LBL file from SEG file" 1
257 259
258 cat $SEG_FILE | grep -v ";;" | cut -f3,4,5,8 -d" " | tr " " "#" | sort -k1 -n | tr "#" " " > $LBL_FILE 260 cat $SEG_FILE | grep -v ";;" | cut -f3,4,5,8 -d" " | tr " " "#" | sort -k1 -n | tr "#" " " > $LBL_FILE
259 261
260 if [ $CHECK -eq 1 ] && ( [ ! -e $LBL_FILE ] || [ -z $LBL_FILE ] ) 262 if [ $CHECK -eq 1 ] && ( [ ! -e $LBL_FILE ] || [ -z $LBL_FILE ] )
261 then 263 then
262 print_log_file "$ERRORFILE" "ERROR [$(date +'%d/%m/%y %H:%M:%S')] Creating LBL file : $LBL_FILE" 264 print_log_file "$ERRORFILE" "ERROR [$(date +'%d/%m/%y %H:%M:%S')] Creating LBL file : $LBL_FILE"
263 print_error "[${BASENAME}] Check $ERRORFILE file" 265 print_error "[${BASENAME}] Check $ERRORFILE file"
264 exit 1 266 exit 1
265 fi 267 fi
266 268
267 269
268 #----------------------------------------------------# 270 #----------------------------------------------------#
269 # Cut global PLP file depending to LBL segmentations # 271 # Cut global PLP file depending to LBL segmentations #
270 #----------------------------------------------------# 272 #----------------------------------------------------#
271 print_info "[${BASENAME}] Cut PLP file depending to LBL segmentations" 1 273 print_info "[${BASENAME}] Cut PLP file depending to LBL segmentations" 1
272 print_info "[${BASENAME}] $BIN_PATH/gcep $PLP_FILE $LBL_FILE 500 $PLP_DIR -FSEG" 3 274 print_info "[${BASENAME}] $BIN_PATH/gcep $PLP_FILE $LBL_FILE 500 $PLP_DIR -FSEG" 3
273 275
274 $SPEERAL_TOOLS/gcep $PLP_FILE $LBL_FILE 500 $PLP_DIR -FSEG 276 $SPEERAL_TOOLS/gcep $PLP_FILE $LBL_FILE 500 $PLP_DIR -FSEG
275 277
276 if [ $CHECK -eq 1 ] 278 if [ $CHECK -eq 1 ]
277 then 279 then
278 check_first_pass_plps_lbl $PLP_DIR $LBL_FILE 280 check_first_pass_plps_lbl $PLP_DIR $LBL_FILE
279 if [ $? -eq 1 ] 281 if [ $? -eq 1 ]
280 then 282 then
281 print_log_file $ERRORFILE "ERROR [$(date +'%d/%m/%y %H:%M:%S')] $PLP wrong number of .plp files" 283 print_log_file $ERRORFILE "ERROR [$(date +'%d/%m/%y %H:%M:%S')] $PLP wrong number of .plp files"
282 print_error "[${BASENAME}] Check $ERRORFILE file" 284 print_error "[${BASENAME}] Check $ERRORFILE file"
283 exit 1 285 exit 1
284 fi 286 fi
285 fi 287 fi
286 288
287 # change plp files names 289 # change plp files names
288 cd $PLP_DIR; 290 cd $PLP_DIR;
289 rename -f s/_/#/g *plp 291 rename -f s/_/#/g *plp
290 rename -f s/#/_/ *plp 292 rename -f s/#/_/ *plp
291 cd $OLDPWD 293 cd $OLDPWD
292 294
293 #---------------------------------------------# 295 #---------------------------------------------#
294 # PLP files list depending to acoustic models # 296 # PLP files list depending to acoustic models #
295 #---------------------------------------------# 297 #---------------------------------------------#
296 print_info "[${BASENAME}] Create PLP list depending of the model" 1 298 print_info "[${BASENAME}] Create PLP list depending of the model" 1
297 # Create a list of plp files 299 # Create a list of plp files
298 find $PLP_DIR -type f -exec basename "{}" .plp \; | sort > $OUTPUT_DIR_BASENAME/plp.lst 300 find $PLP_DIR -type f -exec basename "{}" .plp \; | sort > $PLP_LIST
299 301
300 rm $OUTPUT_DIR_BASENAME/plp_*.lst > /dev/null 2>&1 302 rm $OUTPUT_DIR_BASENAME/plp_*.lst > /dev/null 2>&1
301 for (( i=0; $i<${#MTAG[@]} ; i++ )) 303 for (( i=0; $i<${#MTAG[@]} ; i++ ))
302 do 304 do
303 a=`grep -e "${MTAG[$i]}" $OUTPUT_DIR_BASENAME/plp.lst` 305 a=`grep -e "${MTAG[$i]}" $OUTPUT_DIR_BASENAME/plp.lst`
304 if [ -n "$a" ]; then 306 if [ -n "$a" ]; then
305 print_info "[${BASENAME}] Creating $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst" 3 307 print_info "[${BASENAME}] Creating $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst" 3
306 grep -e "${MTAG[$i]}" $OUTPUT_DIR_BASENAME/plp.lst | sort > $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst 308 grep -e "${MTAG[$i]}" $PLP_LIST | sort > $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst
307 fi 309 fi
308 done 310 done
309 311
310 #-----------------------# 312 #-----------------------#
311 # First Pass (DECODING) # 313 # First Pass (DECODING) #
312 #-----------------------# 314 #-----------------------#
313 # 315 #
314 # For all AM do decoding 316 # For all AM do decoding
315 # if Check error -> iter on undone decoding (max 1 times) 317 # if Check error -> iter on undone decoding (max 1 times)
316 # 318 #
317 print_info "[${BASENAME}] Launch decoding" 1 319 print_info "[${BASENAME}] Launch decoding" 1
318 for (( i=0; $i<${#MTAG[@]} ; i++ )) 320 for (( i=0; $i<${#MTAG[@]} ; i++ ))
319 do 321 do
320 redo=1; # nb of try if not all segs is decoded 322 redo=1; # nb of try if not all segs is decoded
321 if [ -e $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst ] 323 if [ -e $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst ]
322 then 324 then
323 todo=$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst 325 todo=$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst
324 while [ $redo -gt 0 ]; do 326 while [ $redo -gt 0 ]; do
325 rm $RES_DIR/*.lock > /dev/null 2>&1 327 rm $RES_DIR/*.lock > /dev/null 2>&1
326 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" 3 328 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" 3
327 # Run speeral 329 # Run speeral
328 $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 330 $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
329 331
330 # Check if error 332 # Check if error
331 if [ $CHECK -eq 1 ] 333 if [ $CHECK -eq 1 ]
332 then 334 then
333 check_first_pass_output_speeral "${OUTPUT_DIR_BASENAME}/plp_${MODS[$i]}.lst" "$RES_DIR" 335 check_first_pass_output_speeral "${OUTPUT_DIR_BASENAME}/plp_${MODS[$i]}.lst" "$RES_DIR"
334 # if error 336 # if error
335 if [ $? -eq 1 ] 337 if [ $? -eq 1 ]
336 then 338 then
337 # rerun 339 # rerun
338 redo=$(($redo - 1)); 340 redo=$(($redo - 1));
339 print_warn "[${BASENAME}] Speeral output error : check $LOGFILE" 2 341 print_warn "[${BASENAME}] Speeral output error : check $LOGFILE" 2
340 print_log_file $LOGFILE "WARN : Speeral number of output ERROR ${OUTPUT_DIR_BASENAME}/plp_${MODS[$i]}.lst" 342 print_log_file $LOGFILE "WARN : Speeral number of output ERROR ${OUTPUT_DIR_BASENAME}/plp_${MODS[$i]}.lst"
341 # new plp list 343 # new plp list
342 # list .seg done and compare to list of seg to do 344 # list .seg done and compare to list of seg to do
343 ls $RES_DIR/*.seg | grep -e "${MTAG[$i]}" | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp 345 ls $RES_DIR/*.seg | grep -e "${MTAG[$i]}" | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp
344 diff ${OUTPUT_DIR_BASENAME}/plp_${MODS[$i]}.lst ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" > ${OUTPUT_DIR_BASENAME}/todo.lst 346 diff ${OUTPUT_DIR_BASENAME}/plp_${MODS[$i]}.lst ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" > ${OUTPUT_DIR_BASENAME}/todo.lst
345 rm ${OUTPUT_DIR_BASENAME}/.tmp 347 rm ${OUTPUT_DIR_BASENAME}/.tmp
346 # log seg to do 348 # log seg to do
347 print_log_file $LOGFILE "Segs not done :" 349 print_log_file $LOGFILE "Segs not done :"
348 cat ${OUTPUT_DIR_BASENAME}/todo.lst >> $LOGFILE 350 cat ${OUTPUT_DIR_BASENAME}/todo.lst >> $LOGFILE
349 todo=${OUTPUT_DIR_BASENAME}/todo.lst 351 todo=${OUTPUT_DIR_BASENAME}/todo.lst
350 print_warn "[${BASENAME}] Try $redo" 3 352 print_warn "[${BASENAME}] Try $redo" 3
351 fi 353 fi
352 fi 354 fi
353 done 355 done
354 rm ${OUTPUT_DIR_BASENAME}/todo.lst > /dev/null 2>&1 356 rm ${OUTPUT_DIR_BASENAME}/todo.lst > /dev/null 2>&1
355 #rm $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst 357 #rm $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst
356 rm $RES_DIR/*.lock > /dev/null 2>&1 358 rm $RES_DIR/*.lock > /dev/null 2>&1
357 fi 359 fi
358 done 360 done
359 361
360 ## Check missing seg and log it 362 ## Check missing seg and log it
361 if [ "$CHECK" -eq 1 ] 363 if [ "$CHECK" -eq 1 ]
362 then 364 then
363 ls $RES_DIR/*.seg | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp 365 ls $RES_DIR/*.seg | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp
364 todo=$(cat ${OUTPUT_DIR_BASENAME}/plp.lst 2> /dev/null | wc -l) 366 todo=$(cat ${PLP_LIST} 2> /dev/null | wc -l)
365 if [ "$todo" -eq 0 ]; then todo=1;fi 367 if [ "$todo" -eq 0 ]; then todo=1;fi
366 notdone=$(($todo - $(cat ${OUTPUT_DIR_BASENAME}/.tmp | wc -l))) 368 notdone=$(($todo - $(cat ${OUTPUT_DIR_BASENAME}/.tmp | wc -l)))
367 pourcentage=$((($notdone*100)/$todo)) 369 pourcentage=$((($notdone*100)/$todo))
368 370
369 if [ "$notdone" -ne 0 ] 371 if [ "$notdone" -ne 0 ]
370 then 372 then
371 print_error "[${BASENAME}] Check ${ERRORFILE}" 373 print_error "[${BASENAME}] Check ${ERRORFILE}"
372 print_log_file "${ERRORFILE}" "ERROR : Segs not done [" 374 print_log_file "${ERRORFILE}" "ERROR : Segs not done ["
373 diff ${OUTPUT_DIR_BASENAME}/plp.lst ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> ${ERRORFILE} 375 diff ${PLP_LIST} ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> ${ERRORFILE}
374 print_log_file "${ERRORFILE}" "] $pourcentage% $BASENAME" 376 print_log_file "${ERRORFILE}" "] $pourcentage% $BASENAME"
375 else 377 else
376 print_log_file "$LOGFILE" "P1 OK ${BASENAME} | $(date +'%d/%m/%y %H:%M:%S')" 378 print_log_file "$LOGFILE" "P1 OK ${BASENAME} | $(date +'%d/%m/%y %H:%M:%S')"
377 fi 379 fi
378 rm ${OUTPUT_DIR_BASENAME}/.tmp 380 rm ${OUTPUT_DIR_BASENAME}/.tmp
379 fi 381 fi
380 382
381 #---------------# 383 #---------------#
382 # Convert res # 384 # Convert res #
383 #---------------# 385 #---------------#
384 print_info "[${BASENAME}] Convert .res into .ctm" 1 386 print_info "[${BASENAME}] Convert .res into .ctm" 1
385 # .res => .ctm 387 # .res => .ctm
386 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out $OUTPUT_DIR_BASENAME/$BASENAME.1pass.ctm 388 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out $OUTPUT_DIR_BASENAME/$BASENAME.1pass.ctm
387 print_info "[${BASENAME}] Convert .res into .trs" 1 389 print_info "[${BASENAME}] Convert .res into .trs" 1
388 # .res => .trs 390 # .res => .trs
389 echo -e "name $AUTHOR\nfileName $BASENAME\nfileExt wav\nsegFile $OUTPUT_DIR_BASENAME/$BASENAME.seg" > $OUTPUT_DIR_BASENAME/$BASENAME.trs_cfg 391 echo -e "name $AUTHOR\nfileName $BASENAME\nfileExt wav\nsegFile $OUTPUT_DIR_BASENAME/$BASENAME.seg" > $OUTPUT_DIR_BASENAME/$BASENAME.trs_cfg
390 $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 392 $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
391 rm $OUTPUT_DIR_BASENAME/$BASENAME.trs_cfg 2> /dev/null 393 rm $OUTPUT_DIR_BASENAME/$BASENAME.trs_cfg 2> /dev/null
392 print_info "[${BASENAME}] Convert .res into .txt" 1 394 print_info "[${BASENAME}] Convert .res into .txt" 1
393 # .res => .txt 395 # .res => .txt
394 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out $OUTPUT_DIR_BASENAME/$BASENAME.1pass.txt 396 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out $OUTPUT_DIR_BASENAME/$BASENAME.1pass.txt
395 397
396 print_info "[${BASENAME}] <= P1 End | $(date +'%d/%m/%y %H:%M:%S')" 1 398 print_info "[${BASENAME}] <= P1 End | $(date +'%d/%m/%y %H:%M:%S')" 1
397 # unlock directory 399 # unlock directory
398 mv "$OUTPUT_DIR_BASENAME/FIRSTPASS.lock" "$OUTPUT_DIR_BASENAME/FIRSTPASS.unlock" 400 mv "$OUTPUT_DIR_BASENAME/FIRSTPASS.lock" "$OUTPUT_DIR_BASENAME/FIRSTPASS.unlock"
399 401
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 echo "### SecondPass.sh ###" 13 echo "### SecondPass.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 # where is SecondPass.sh 22 # where is SecondPass.sh
23 MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0)) 23 MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0))
24 24
25 # Scripts Path 25 # Scripts Path
26 SCRIPT_PATH=$OTMEDIA_HOME/tools/scripts 26 SCRIPT_PATH=$OTMEDIA_HOME/tools/scripts
27 27
28 # Include scripts 28 # Include scripts
29 . $SCRIPT_PATH"/Tools.sh" 29 . $SCRIPT_PATH"/Tools.sh"
30 . $SCRIPT_PATH"/CheckSecondPass.sh" 30 . $SCRIPT_PATH"/CheckSecondPass.sh"
31 31
32 # where is SecondPass.cfg 32 # where is SecondPass.cfg
33 SECONDPASS_CONFIG_FILE=$OTMEDIA_HOME"/cfg/SecondPass.cfg" 33 SECONDPASS_CONFIG_FILE=$OTMEDIA_HOME"/cfg/SecondPass.cfg"
34 if [ -e $SECONDPASS_CONFIG_FILE ] 34 if [ -e $SECONDPASS_CONFIG_FILE ]
35 then 35 then
36 . $SECONDPASS_CONFIG_FILE 36 . $SECONDPASS_CONFIG_FILE
37 else 37 else
38 echo "ERROR : Can't find configuration file $SECONDPASS_CONFIG_FILE" >&2 38 echo "ERROR : Can't find configuration file $SECONDPASS_CONFIG_FILE" >&2
39 echo "exit" >&2 39 echo "exit" >&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:crf:" opt 46 while getopts ":hDv:crf:" opt
47 do 47 do
48 case $opt in 48 case $opt in
49 h) 49 h)
50 echo -e "$0 [OPTIONS] <FIRST_PASS_DIRECTORY>\n" 50 echo -e "$0 [OPTIONS] <FIRST_PASS_DIRECTORY>\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-f n :\tSpecify speeral forks number (default 1)" 56 echo -e "\t\t-f n :\tSpecify speeral forks number (default 1)"
57 echo -e "\t\t-r n :\tforce rerun the show, without deleting works already done" 57 echo -e "\t\t-r n :\tforce rerun the show, without deleting works already done"
58 exit 1 58 exit 1
59 ;; 59 ;;
60 D) 60 D)
61 DEBUG=1 61 DEBUG=1
62 ;; 62 ;;
63 v) 63 v)
64 VERBOSE=$OPTARG 64 VERBOSE=$OPTARG
65 ;; 65 ;;
66 c) 66 c)
67 CHECK=1 67 CHECK=1
68 ;; 68 ;;
69 f) 69 f)
70 FORKS="--forks $OPTARG" 70 FORKS="--forks $OPTARG"
71 ;; 71 ;;
72 r) 72 r)
73 RERUN=1 73 RERUN=1
74 ;; 74 ;;
75 :) 75 :)
76 echo "Option -$OPTARG requires an argument." >&2 76 echo "Option -$OPTARG requires an argument." >&2
77 exit 1 77 exit 1
78 ;; 78 ;;
79 \?) 79 \?)
80 echo "BAD USAGE : unknow opton -$OPTARG" >&2 80 echo "BAD USAGE : unknow opton -$OPTARG" >&2
81 exit 1 81 exit 1
82 ;; 82 ;;
83 esac 83 esac
84 done 84 done
85 85
86 # mode debug enable 86 # mode debug enable
87 if [ $DEBUG -eq 1 ] 87 if [ $DEBUG -eq 1 ]
88 then 88 then
89 set -x 89 set -x
90 echo -e "## Mode DEBUG ON ##" 90 echo -e "## Mode DEBUG ON ##"
91 fi 91 fi
92 92
93 # mode verbose enable 93 # mode verbose enable
94 if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ;fi 94 if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ;fi
95 95
96 # Check USAGE by arguments number 96 # Check USAGE by arguments number
97 if [ $(($#-($OPTIND-1))) -ne 1 ] 97 if [ $(($#-($OPTIND-1))) -ne 1 ]
98 then 98 then
99 echo "BAD USAGE : SecondPass.sh [OPTIONS] <FIRST_PASS_DIR>" 99 echo "BAD USAGE : SecondPass.sh [OPTIONS] <FIRST_PASS_DIR>"
100 echo "$0 -h for more info" 100 echo "$0 -h for more info"
101 exit 1 101 exit 1
102 fi 102 fi
103 103
104 shift $((OPTIND-1)) 104 shift $((OPTIND-1))
105 # check FirstPass directory - First argument 105 # check FirstPass directory - First argument
106 if [ -e $1 ] && [ -d $1 ] 106 if [ -e $1 ] && [ -d $1 ]
107 then 107 then
108 FIRSTPASS_DIR=$(readlink -e $1) 108 FIRSTPASS_DIR=$(readlink -e $1)
109 else 109 else
110 print_error "Can't find $1 directory" 110 print_error "Can't find $1 directory"
111 exit 1 111 exit 1
112 fi 112 fi
113 113
114 #-------------# 114 #-------------#
115 # GLOBAL VARS # 115 # GLOBAL VARS #
116 #-------------# 116 #-------------#
117 FIRSTPASS_CONFIG_FILE="$FIRSTPASS_DIR/FirstPass.cfg" 117 FIRSTPASS_CONFIG_FILE="$FIRSTPASS_DIR/FirstPass.cfg"
118 if [ -e $FIRSTPASS_CONFIG_FILE ] 118 if [ -e $FIRSTPASS_CONFIG_FILE ]
119 then 119 then
120 WAV_FILE=$(cat $FIRSTPASS_CONFIG_FILE | grep "WAV_FILE=" | cut -f2 -d"=") 120 WAV_FILE=$(cat $FIRSTPASS_CONFIG_FILE | grep "WAV_FILE=" | cut -f2 -d"=")
121 BASENAME=$(cat $FIRSTPASS_CONFIG_FILE | grep "^BASENAME=" | cut -f2 -d"=") 121 BASENAME=$(cat $FIRSTPASS_CONFIG_FILE | grep "^BASENAME=" | cut -f2 -d"=")
122 OUTPUT_DIR=$(cat $FIRSTPASS_CONFIG_FILE | grep "OUTPUT_DIR=" | cut -f2 -d"=") 122 OUTPUT_DIR=$(cat $FIRSTPASS_CONFIG_FILE | grep "OUTPUT_DIR=" | cut -f2 -d"=")
123 OUTPUT_DIR_BASENAME=$FIRSTPASS_DIR 123 OUTPUT_DIR_BASENAME=$FIRSTPASS_DIR
124 PLP_FILE_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "PLP_FILE=" | cut -f2 -d"=") 124 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"=") 125 PLP_DIR_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "PLP_DIR=" | cut -f2 -d"=")
126 PLP_LIST_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "PLP_LIST=" | cut -f2 -d"=")
126 SEG_FILE_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "SEG_FILE=" | cut -f2 -d"=") 127 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"=") 128 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"=") 129 RES_DIR_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "RES_DIR=" | cut -f2 -d"=")
129 else 130 else
130 print_error "Can't find $FIRSTPASS_CONFIG_FILE file" 131 print_error "Can't find $FIRSTPASS_CONFIG_FILE file"
131 print_error "exit" 132 print_error "exit"
132 exit 1 133 exit 1
133 fi 134 fi
134 LST=$OUTPUT_DIR_BASENAME"/lists" 135 LST=$OUTPUT_DIR_BASENAME"/lists"
135 HMM=$OUTPUT_DIR_BASENAME"/hmm/" 136 HMM=$OUTPUT_DIR_BASENAME"/hmm/"
136 RES_DIR=$OUTPUT_DIR_BASENAME"/res_p2" 137 RES_DIR=$OUTPUT_DIR_BASENAME"/res_p2"
137 LOGFILE="$OUTPUT_DIR_BASENAME/info_p2.log" 138 LOGFILE="$OUTPUT_DIR_BASENAME/info_p2.log"
138 ERRORFILE="$OUTPUT_DIR_BASENAME/error_p2.log" 139 ERRORFILE="$OUTPUT_DIR_BASENAME/error_p2.log"
139 140
140 print_info "[${BASENAME}] => P2 start | $(date +'%d/%m/%y %H:%M:%S')" 1 141 print_info "[${BASENAME}] => P2 start | $(date +'%d/%m/%y %H:%M:%S')" 1
141 142
142 #------------------# 143 #------------------#
143 # Create WORKSPACE # 144 # Create WORKSPACE #
144 #------------------# 145 #------------------#
145 146
146 # Lock directory 147 # Lock directory
147 if [ -e $OUTPUT_DIR_BASENAME/SECONDPASS.lock ] && [ $RERUN -eq 0 ]; then print_warn "[${BASENAME}] SECONDPASS is locked -> exit" 2; 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
148 rm "$OUTPUT_DIR_BASENAME/SECONDPASS.unlock" > /dev/null 2>&1 149 rm "$OUTPUT_DIR_BASENAME/SECONDPASS.unlock" > /dev/null 2>&1
149 touch "$OUTPUT_DIR_BASENAME/SECONDPASS.lock" > /dev/null 2>&1 150 touch "$OUTPUT_DIR_BASENAME/SECONDPASS.lock" > /dev/null 2>&1
150 151
151 rm -r $LST > /dev/null 2>&1 152 rm -r $LST > /dev/null 2>&1
152 mkdir -p $LST 153 mkdir -p $LST
153 print_info "[${BASENAME}] Make directory $LST" 2 154 print_info "[${BASENAME}] Make directory $LST" 2
154 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
155 mkdir -p $HMM 156 mkdir -p $HMM
156 print_info "[${BASENAME}] Make directory $HMM" 2 157 print_info "[${BASENAME}] Make directory $HMM" 2
157 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
158 mkdir -p $RES_DIR > /dev/null 2>&1 159 mkdir -p $RES_DIR > /dev/null 2>&1
159 print_info "[${BASENAME}] Make directory $RES_DIR" 2 160 print_info "[${BASENAME}] Make directory $RES_DIR" 2
160 rm $LOGFILE $ERRORFILE > /dev/null 2>&1 161 rm $LOGFILE $ERRORFILE > /dev/null 2>&1
161 162
162 #-------------------# 163 #-------------------#
163 # Check Pass # 164 # Check Pass #
164 #-------------------# 165 #-------------------#
165 print_info "[${BASENAME}] Check Pass 2 directory" 1 166 print_info "[${BASENAME}] Check Pass 2 directory" 1
166 for treil in $(ls $RES_DIR/ | grep treil) 167 for treil in $(ls $RES_DIR/ | grep treil)
167 do 168 do
168 if [ ! -s $RES_DIR/$treil ] 169 if [ ! -s $RES_DIR/$treil ]
169 then 170 then
170 bn = $(basename $treil ".treil") 171 bn = $(basename $treil ".treil")
171 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
172 print_info "[${BASENAME}] $RES_DIR/$bn.* files deleted.." 2 173 print_info "[${BASENAME}] $RES_DIR/$bn.* files deleted.." 2
173 fi 174 fi
174 done 175 done
175 176
176 # Check if more then 89% of treil are done 177 # Check if more then 89% of treil are done
177 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)
178 nbtreil_p2=$(ls $RES_DIR/*.treil 2> /dev/null | wc -l) 179 nbtreil_p2=$(ls $RES_DIR/*.treil 2> /dev/null | wc -l)
179 if [ $nbres_p1 -gt 0 ] 180 if [ $nbres_p1 -gt 0 ]
180 then 181 then
181 pourcentage=$((($nbtreil_p2*100)/$nbres_p1)) 182 pourcentage=$((($nbtreil_p2*100)/$nbres_p1))
182 if [ $pourcentage -gt 89 ] 183 if [ $pourcentage -gt 89 ]
183 then 184 then
184 print_info "[${BASENAME}] Lattice already done, skipping $BASENAME" 1 185 print_info "[${BASENAME}] Lattice already done, skipping $BASENAME" 1
185 exit 0 186 exit 0
186 fi 187 fi
187 else 188 else
188 print_error "[${BASENAME}] No First Pass, No .res -> exit P2" 189 print_error "[${BASENAME}] No First Pass, No .res -> exit P2"
189 if [ $CHECK -eq 1 ]; then print_log_file $ERRORFILE "No First Pass, No .res -> exit P2" ;fi 190 if [ $CHECK -eq 1 ]; then print_log_file $ERRORFILE "No First Pass, No .res -> exit P2" ;fi
190 exit 1 191 exit 1
191 fi 192 fi
192 193
193 #--------------------# 194 #--------------------#
194 # Save configuration # 195 # Save configuration #
195 #--------------------# 196 #--------------------#
196 cp $SECONDPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/SecondPass.cfg 197 cp $SECONDPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/SecondPass.cfg
197 echo "WAV_FILE=$WAV_FILE" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 198 echo "WAV_FILE=$WAV_FILE" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
198 echo "BASENAME=$BASENAME" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 199 echo "BASENAME=$BASENAME" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
199 echo "FIRSTPASS_DIR=$FIRSTPASS_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 200 echo "FIRSTPASS_DIR=$FIRSTPASS_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
200 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
201 echo "PLP_FILE_P1=$PLP_FILE_P1" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 202 echo "PLP_FILE_P1=$PLP_FILE_P1" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
203 echo "PLP_LIST_P1=$PLP_LIST_P1" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
202 echo "OUTPUT_DIR=$OUTPUT_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 204 echo "OUTPUT_DIR=$OUTPUT_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
203 echo "OUTPUT_DIR_BASENAME=$OUTPUT_DIR_BASENAME" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 205 echo "OUTPUT_DIR_BASENAME=$OUTPUT_DIR_BASENAME" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
204 echo "LST=$LST" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 206 echo "LST=$LST" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
205 echo "HMM=$HMM" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 207 echo "HMM=$HMM" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
206 echo "RES_DIR=$RES_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 208 echo "RES_DIR=$RES_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
207 print_info "[${BASENAME}] Save config in $OUTPUT_DIR_BASENAME/SecondPass.cfg" 1 209 print_info "[${BASENAME}] Save config in $OUTPUT_DIR_BASENAME/SecondPass.cfg" 1
208 210
209 211
210 #--------------------------------------------------# 212 #--------------------------------------------------#
211 # Speaker Adaptation (AM) + Second pass (DECODING) # 213 # Speaker Adaptation (AM) + Second pass (DECODING) #
212 #--------------------------------------------------# 214 #--------------------------------------------------#
213 print_info "[${BASENAME}] Launch Second Pass" 1 215 print_info "[${BASENAME}] Launch Second Pass" 1
214 216
215 # for all speaker 217 # for all speaker
216 for speaker in $(cat $LBL_FILE_P1 | cut -f4 -d" " | sort | uniq) 218 for speaker in $(cat $LBL_FILE_P1 | cut -f4 -d" " | sort | uniq)
217 do 219 do
218 ## get seg file from P1 containing the speaker 220 ## get seg file from P1 containing the speaker
219 find $RES_DIR_P1 -name "*${speaker}.seg" -exec basename "{}" .seg \; | sort > $LST/$speaker.lst 221 find $RES_DIR_P1 -name "*${speaker}.seg" -exec basename "{}" .seg \; | sort > $LST/$speaker.lst
220 print_info "[${BASENAME}] file for $speaker in $LST/$speaker.lst" 3 222 print_info "[${BASENAME}] file for $speaker in $LST/$speaker.lst" 3
221 if [ ! -s $LST/$speaker.lst ]; then print_warn "no ${speaker} file in $RES_DIR_P1" 3; continue; fi 223 if [ ! -s $LST/$speaker.lst ]; then print_warn "no ${speaker} file in $RES_DIR_P1" 3; continue; fi
222 224
223 225
224 # for all AM 226 # for all AM
225 for (( i=0; $i<${#MTAG[@]} ; i++ )) 227 for (( i=0; $i<${#MTAG[@]} ; i++ ))
226 do 228 do
227 if [ -e $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst ]; then 229 if [ -e $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst ]; then
228 type=$(grep -e "${speaker}$" "$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst") 230 type=$(grep -e "${speaker}$" "$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst")
229 ## if is the good AM for the speaker 231 ## if is the good AM for the speaker
230 if [ -n "$type" ] 232 if [ -n "$type" ]
231 then 233 then
232 ## HMM adaptation 234 ## HMM adaptation
233 if [ $RERUN -eq 0 ] || ( [ ! -e $HMM/$speaker.hmm ] || [ -z $HMM/$speaker.hmm ] ) 235 if [ $RERUN -eq 0 ] || ( [ ! -e $HMM/$speaker.hmm ] || [ -z $HMM/$speaker.hmm ] )
234 then 236 then
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 237 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
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/ 2> /dev/null 238 $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/ 2> /dev/null
237 fi 239 fi
238 240
239 if [ $CHECK -eq 1 ] && ( [ ! -e $HMM/$speaker.hmm ] || [ -z $HMM/$speaker.hmm ] ) 241 if [ $CHECK -eq 1 ] && ( [ ! -e $HMM/$speaker.hmm ] || [ -z $HMM/$speaker.hmm ] )
240 then 242 then
241 print_warn "[${BASENAME}] No hmm files created for $speaker" 2 243 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" 244 print_log_file $ERRORFILE "ERROR [$(date +'%d/%m/%y %H:%M:%S')] No hmm files created for $speaker"
243 print_error "[${BASENAME}] Check $ERRORFILE" 245 print_error "[${BASENAME}] Check $ERRORFILE"
244 #exit 1 246 #exit 1
245 fi 247 fi
246 248
247 ## cp map files 249 ## cp map files
248 cp $SPEERAL_AM/${MODS[$i]}.map $HMM/$speaker.map 250 cp $SPEERAL_AM/${MODS[$i]}.map $HMM/$speaker.map
249 251
250 ## class clustering 252 ## class clustering
251 if [ -s $HMM/$speaker.hmm ] && ( [ $RERUN -eq 0 ] || ( [ ! -e $HMM/$speaker.cls ] || [ -z $HMM/$speaker.cls ] )) 253 if [ -s $HMM/$speaker.hmm ] && ( [ $RERUN -eq 0 ] || ( [ ! -e $HMM/$speaker.cls ] || [ -z $HMM/$speaker.cls ] ))
252 then 254 then
253 print_info "[${BASENAME}] $SPEERAL_TOOLS/gclust_pdf $HMM/$speaker.hmm $HMM/$speaker.cls -i $SPEERAL_AM/${MODS[$i]}.cls" 3 255 print_info "[${BASENAME}] $SPEERAL_TOOLS/gclust_pdf $HMM/$speaker.hmm $HMM/$speaker.cls -i $SPEERAL_AM/${MODS[$i]}.cls" 3
254 $SPEERAL_TOOLS/gclust_pdf $HMM/$speaker.hmm $HMM/$speaker.cls -i $SPEERAL_AM/${MODS[$i]}.cls 2> /dev/null 256 $SPEERAL_TOOLS/gclust_pdf $HMM/$speaker.hmm $HMM/$speaker.cls -i $SPEERAL_AM/${MODS[$i]}.cls 2> /dev/null
255 fi 257 fi
256 if [ $CHECK -eq 1 ] && ( [ ! -e $HMM/$speaker.cls ] || [ -z $HMM/$speaker.cls ] ) 258 if [ $CHECK -eq 1 ] && ( [ ! -e $HMM/$speaker.cls ] || [ -z $HMM/$speaker.cls ] )
257 then 259 then
258 print_warn "[${BASENAME}] No cls file created for $speaker" 2 260 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" 261 print_log_file $ERRORFILE "ERROR [$(date +'%d/%m/%y %H:%M:%S')] No cls file created for $speakers"
260 print_error "[${BASENAME}] Check $ERRORFILE" 262 print_error "[${BASENAME}] Check $ERRORFILE"
261 #exit 1 263 #exit 1
262 fi 264 fi
263 265
264 ## Speeral decoding 266 ## Speeral decoding
265 if [ -s $HMM/$speaker.hmm ] && [ -s $HMM/$speaker.cls ] 267 if [ -s $HMM/$speaker.hmm ] && [ -s $HMM/$speaker.cls ]
266 then 268 then
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" 3 269 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" 3
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 270 $SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_CFG[$i]} -r $PLP_DIR_P1 -m $HMM/$speaker.hmm -c $HMM/$speaker.cls $FORKS --lock
269 else 271 else
270 print_warn "[${BASENAME}] $HMM/$speaker.hmm and $speaker.cls empty, do default decoding..." 2 272 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" 3 273 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" 3
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 274 $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
273 fi 275 fi
274 276
275 if [ $CHECK -eq 1 ] 277 if [ $CHECK -eq 1 ]
276 then 278 then
277 check_second_pass_output_speeral "$LST/$speaker.lst" "$RES_DIR" 279 check_second_pass_output_speeral "$LST/$speaker.lst" "$RES_DIR"
278 if [ $? -eq 1 ] 280 if [ $? -eq 1 ]
279 then 281 then
280 print_warn "[${BASENAME}] Speeral output error : check $LOGFILE" 2 282 print_warn "[${BASENAME}] Speeral output error : check $LOGFILE" 2
281 print_log_file $LOGFILE "WARN : Speeral number of output ERROR $LST/$speaker.lst" 283 print_log_file $LOGFILE "WARN : Speeral number of output ERROR $LST/$speaker.lst"
282 ls $RES_DIR/*.seg | grep -e "$speaker" | sed -e "s|$RES_DIR\/||" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp 284 ls $RES_DIR/*.seg | grep -e "${speaker}" | sed -e "s|${RES_DIR}\/||" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp
283 print_log_file $LOGFILE "Segs (and treil) not done :\n[" 285 print_log_file $LOGFILE "Segs (and treil) not done :\n["
284 diff $LST/$speaker.lst ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> $LOGFILE 286 diff ${LST}/${speaker}.lst ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> $LOGFILE
285 print_log_file $LOGFILE "] [$(date +'%d/%m/%y %H:%M:%S')]" 287 print_log_file $LOGFILE "] [$(date +'%d/%m/%y %H:%M:%S')]"
286 rm ${OUTPUT_DIR_BASENAME}/.tmp 288 rm ${OUTPUT_DIR_BASENAME}/.tmp
287 #exit 1 289 #exit 1
288 fi 290 fi
289 fi 291 fi
290 break 292 break
291 fi 293 fi
292 fi 294 fi
293 done 295 done
294 #rm "$HMM/$speaker.*" > /dev/null 2>&1 296 #rm "$HMM/$speaker.*" > /dev/null 2>&1
295 #rm "$LST/$speaker.lst" > /dev/null 2>&1 297 #rm "$LST/$speaker.lst" > /dev/null 2>&1
296 done 298 done
297 299
298 ## Check missing seg and log it 300 ## Check missing seg and log it
299 if [ $CHECK -eq 1 ] 301 if [ $CHECK -eq 1 ]
300 then 302 then
301 ls $RES_DIR/*.treil | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.treil//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp 303 ls $RES_DIR/*.treil | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.treil//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp
302 todo=$(cat ${PLP_FILE_P1} | wc -l) 304 todo=$(cat ${PLP_LIST_P1} | wc -l)
303 if [ $todo -eq 0 ]; then todo=1;fi 305 if [ $todo -eq 0 ]; then todo=1;fi
304 notdone=$(($todo - $(cat ${OUTPUT_DIR_BASENAME}/.tmp | wc -l))) 306 notdone=$(($todo - $(cat ${OUTPUT_DIR_BASENAME}/.tmp | wc -l)))
305 pourcentage=$((($notdone*100)/$todo)) 307 pourcentage=$((($notdone*100)/$todo))
306 if [ $notdone -ne 0 ] 308 if [ $notdone -ne 0 ]
307 then 309 then
308 print_error "[${BASENAME}] Check $ERRORFILE" 310 print_error "[${BASENAME}] Check $ERRORFILE"
309 print_log_file "$ERRORFILE" "ERROR : Treil not done [" 311 print_log_file "$ERRORFILE" "ERROR : Treil not done ["
310 diff ${PLP_FILE_P1} ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> $ERRORFILE 312 diff ${PLP_LIST_P1} ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> ${ERRORFILE}
311 print_log_file "$ERRORFILE" "] $pourcentage% $BASENAME" 313 print_log_file "$ERRORFILE" "] $pourcentage% $BASENAME"
312 else 314 else
313 print_log_file "$LOGFILE" "P2 OK $BASENAME | $(date +'%d/%m/%y %H:%M:%S')" 315 print_log_file "$LOGFILE" "P2 OK $BASENAME | $(date +'%d/%m/%y %H:%M:%S')"
314 fi 316 fi
315 rm ${OUTPUT_DIR_BASENAME}/.tmp > /dev/null 2>&1 317 rm ${OUTPUT_DIR_BASENAME}/.tmp > /dev/null 2>&1
316 fi 318 fi
317 319
318 #---------------# 320 #---------------#
319 # Convert res # 321 # Convert res #
320 #---------------# 322 #---------------#
321 323
322 print_info "[${BASENAME}] Convert .res into .ctm" 1 324 print_info "[${BASENAME}] Convert .res into .ctm" 1
323 # .res => .ctm 325 # .res => .ctm
324 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.2pass.ctm 326 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.2pass.ctm
325 print_info "[${BASENAME}] Convert .res into .trs" 1 327 print_info "[${BASENAME}] Convert .res into .trs" 1
326 # .res => .trs 328 # .res => .trs
327 echo -e "name $AUTHOR\nfileName ${BASENAME}\nfileExt wav\nsegFile ${OUTPUT_DIR_BASENAME}/${BASENAME}.seg" > ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg 329 echo -e "name $AUTHOR\nfileName ${BASENAME}\nfileExt wav\nsegFile ${OUTPUT_DIR_BASENAME}/${BASENAME}.seg" > ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg
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 330 $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
329 rm ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg > /dev/null 2>&1 331 rm ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg > /dev/null 2>&1
330 print_info "[${BASENAME}] Convert .res into .txt" 1 332 print_info "[${BASENAME}] Convert .res into .txt" 1
331 # .res => .txt 333 # .res => .txt
332 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.2pass.txt 334 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.2pass.txt
333 335
334 print_info "[${BASENAME}] <= P2 End | $(date +'%d/%m/%y %H:%M:%S')" 1 336 print_info "[${BASENAME}] <= P2 End | $(date +'%d/%m/%y %H:%M:%S')" 1
335 # unlock directory 337 # unlock directory
336 mv "$OUTPUT_DIR_BASENAME/SECONDPASS.lock" "$OUTPUT_DIR_BASENAME/SECONDPASS.unlock" 338 mv "$OUTPUT_DIR_BASENAME/SECONDPASS.lock" "$OUTPUT_DIR_BASENAME/SECONDPASS.unlock"
337 339
338 340
main_tools/ThirdPass.sh
1 #!/bin/bash 1 #!/bin/bash
2 2
3 ##################################################### 3 #####################################################
4 # File : ThirdPass.sh # 4 # File : ThirdPass.sh #
5 # Brief : ASR third pass using trigg files # 5 # Brief : ASR third pass using trigg files #
6 # Author : Jean-François Rey # 6 # Author : Jean-François Rey #
7 # Version : 1.0 # 7 # Version : 1.0 #
8 # Date : 18/07/13 # 8 # Date : 18/07/13 #
9 ##################################################### 9 #####################################################
10 10
11 echo "### ThirdPass.sh ###" 11 echo "### ThirdPass.sh ###"
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"/CheckThirdPass.sh" 28 . $SCRIPT_PATH"/CheckThirdPass.sh"
29 29
30 # where is ThirdPass.cfg 30 # where is ThirdPass.cfg
31 THIRDPASS_CONFIG_FILE=$OTMEDIA_HOME"/cfg/ThirdPass.cfg" 31 THIRDPASS_CONFIG_FILE=$OTMEDIA_HOME"/cfg/ThirdPass.cfg"
32 if [ -e $THIRDPASS_CONFIG_FILE ] 32 if [ -e $THIRDPASS_CONFIG_FILE ]
33 then 33 then
34 . $THIRDPASS_CONFIG_FILE 34 . $THIRDPASS_CONFIG_FILE
35 else 35 else
36 echo "ERROR : Can't find configuration file $THIRDPASS_CONFIG_FILE" >&2 36 echo "ERROR : Can't find configuration file $THIRDPASS_CONFIG_FILE" >&2
37 exit 1 37 exit 1
38 fi 38 fi
39 39
40 #---------------# 40 #---------------#
41 # Parse Options # 41 # Parse Options #
42 #---------------# 42 #---------------#
43 while getopts ":hDv:crf:" opt 43 while getopts ":hDv:crf:" opt
44 do 44 do
45 case $opt in 45 case $opt in
46 h) 46 h)
47 echo -e "$0 [OPTIONS] <PASS_DIRECTORY>\n" 47 echo -e "$0 [OPTIONS] <PASS_DIRECTORY>\n"
48 echo -e "\t Options:" 48 echo -e "\t Options:"
49 echo -e "\t\t-h :\tprint this message" 49 echo -e "\t\t-h :\tprint this message"
50 echo -e "\t\t-D :\tDEBUG mode on" 50 echo -e "\t\t-D :\tDEBUG mode on"
51 echo -e "\t\t-v l :\tVerbose mode, l=(1|2|3) level mode" 51 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" 52 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)" 53 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" 54 echo -e "\t\t-r n :\tforce rerun the show, without deleting works already done"
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 f) 66 f)
67 FORKS="--forks $OPTARG" 67 FORKS="--forks $OPTARG"
68 ;; 68 ;;
69 r) 69 r)
70 RERUN=1 70 RERUN=1
71 ;; 71 ;;
72 :) 72 :)
73 echo "Option -$OPTARG requires an argument." >&2 73 echo "Option -$OPTARG requires an argument." >&2
74 exit 1 74 exit 1
75 ;; 75 ;;
76 \?) 76 \?)
77 echo "BAD USAGE : unknow opton -$OPTARG" 77 echo "BAD USAGE : unknow opton -$OPTARG"
78 #exit 1 78 #exit 1
79 ;; 79 ;;
80 esac 80 esac
81 done 81 done
82 82
83 # mode debug enable 83 # mode debug enable
84 if [ $DEBUG -eq 1 ] 84 if [ $DEBUG -eq 1 ]
85 then 85 then
86 set -x 86 set -x
87 echo -e "## Mode DEBUG ON ##" 87 echo -e "## Mode DEBUG ON ##"
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 1 ] 94 if [ $(($#-($OPTIND-1))) -ne 1 ]
95 then 95 then
96 echo "BAD USAGE : ThirdPass.sh [OPTIONS] <PASS_DIR>" 96 echo "BAD USAGE : ThirdPass.sh [OPTIONS] <PASS_DIR>"
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 Pass directory - First argument 102 # check Pass directory - First argument
103 if [ -e $1 ] && [ -d $1 ] 103 if [ -e $1 ] && [ -d $1 ]
104 then 104 then
105 PASS_DIR=$(readlink -e $1) 105 PASS_DIR=$(readlink -e $1)
106 BASENAME=$(basename $PASS_DIR) 106 BASENAME=$(basename $PASS_DIR)
107 else 107 else
108 print_error "can't find $1 directory" 108 print_error "can't find $1 directory"
109 exit 1 109 exit 1
110 fi 110 fi
111 111
112 print_info "[${BASENAME}] => P3 start | $(date +'%d/%m/%y %H:%M:%S')" 1 112 print_info "[${BASENAME}] => P3 start | $(date +'%d/%m/%y %H:%M:%S')" 1
113 113
114 #-------------# 114 #-------------#
115 # GLOBAL VARS # 115 # GLOBAL VARS #
116 #-------------# 116 #-------------#
117 EXPLOITCONFPASS_CONFIG_FILE="$PASS_DIR/ExploitConfPass.cfg" 117 EXPLOITCONFPASS_CONFIG_FILE="$PASS_DIR/ExploitConfPass.cfg"
118 if [ -e $EXPLOITCONFPASS_CONFIG_FILE ] 118 if [ -e $EXPLOITCONFPASS_CONFIG_FILE ]
119 then 119 then
120 TRIGGER_SPEERAL=$(cat $EXPLOITCONFPASS_CONFIG_FILE | grep "TRIGGER_SPEERAL=" | cut -f2 -d"=") 120 TRIGGER_SPEERAL=$(cat $EXPLOITCONFPASS_CONFIG_FILE | grep "TRIGGER_SPEERAL=" | cut -f2 -d"=")
121 LEX_SPEERAL=$(cat $EXPLOITCONFPASS_CONFIG_FILE | grep "LEX_SPEERAL=" | cut -f2 -d"=") 121 LEX_SPEERAL=$(cat $EXPLOITCONFPASS_CONFIG_FILE | grep "LEX_SPEERAL=" | cut -f2 -d"=")
122 LEX_BINODE_SPEERAL=$(cat $EXPLOITCONFPASS_CONFIG_FILE | grep "LEX_BINODE_SPEERAL=" | cut -f2 -d"=") 122 LEX_BINODE_SPEERAL=$(cat $EXPLOITCONFPASS_CONFIG_FILE | grep "LEX_BINODE_SPEERAL=" | cut -f2 -d"=")
123 LST="" 123 LST=""
124 PLP_DIR_P1="" 124 PLP_DIR_P1=""
125 HMM="" 125 HMM=""
126 else 126 else
127 print_error "[${BASENAME}] Can't find $EXPLOITCONFPASS_CONFIG_FILE file" 127 print_error "[${BASENAME}] Can't find $EXPLOITCONFPASS_CONFIG_FILE file"
128 print_warn "[${BASENAME}] Will use default directories and files" 2 128 print_warn "[${BASENAME}] Will use default directories and files" 2
129 #exit 1 129 #exit 1
130 TRIGGER_SPEERAL=$PASS_DIR/trigg/speeral/ 130 TRIGGER_SPEERAL=$PASS_DIR/trigg/speeral/
131 LEX_SPEERAL=$PASS_DIR/LEX/speeral/LEXIQUE_V6_ext 131 LEX_SPEERAL=$PASS_DIR/LEX/speeral/LEXIQUE_V6_ext
132 LEX_BINODE_SPEERAL=$PASS_DIR/LEX/speeral/LEXIQUE_V6_ext.bin 132 LEX_BINODE_SPEERAL=$PASS_DIR/LEX/speeral/LEXIQUE_V6_ext.bin
133 fi 133 fi
134 134
135 SECONDPASS_CONFIG_FILE="$PASS_DIR/SecondPass.cfg" 135 SECONDPASS_CONFIG_FILE="$PASS_DIR/SecondPass.cfg"
136 if [ -e $SECONDPASS_CONFIG_FILE ] 136 if [ -e $SECONDPASS_CONFIG_FILE ]
137 then 137 then
138 LST=$(cat $SECONDPASS_CONFIG_FILE | grep "^LST=" | cut -f2 -d"=") 138 LST=$(cat $SECONDPASS_CONFIG_FILE | grep "^LST=" | cut -f2 -d"=")
139 HMM=$(cat $SECONDPASS_CONFIG_FILE | grep "^HMM=" | cut -f2 -d"=") 139 HMM=$(cat $SECONDPASS_CONFIG_FILE | grep "^HMM=" | cut -f2 -d"=")
140 PLP_DIR_P1=$(cat $SECONDPASS_CONFIG_FILE | grep "^PLP_DIR_P1=" | cut -f2 -d"=") 140 PLP_DIR_P1=$(cat $SECONDPASS_CONFIG_FILE | grep "^PLP_DIR_P1=" | cut -f2 -d"=")
141 PLP_FILE_P1=$(cat $SECONDPASS_CONFIG_FILE | grep "^PLP_FILE_P1=" | cut -f2 -d"=") 141 PLP_LIST_P1=$(cat $SECONDPASS_CONFIG_FILE | grep "^PLP_LIST_P1=" | cut -f2 -d"=")
142 else 142 else
143 print_error "[${BASENAME}] Can't find $SECONDPASS_CONFIG_FILE file" 143 print_error "[${BASENAME}] Can't find $SECONDPASS_CONFIG_FILE file"
144 print_warn "[${BASENAME}] Will use default directories and files" 2 144 print_warn "[${BASENAME}] Will use default directories and files" 2
145 #exit 1 145 #exit 1
146 LST=$PASS_DIR/lists 146 LST=$PASS_DIR/lists
147 HMM=$PASS_DIR/hmm 147 HMM=$PASS_DIR/hmm
148 PLP_DIR_P1=$PASS_DIR/PLP 148 PLP_DIR_P1=$PASS_DIR/PLP
149 PLP_FILE_P1=$PASS_DIR/plp.lst 149 PLP_LIST_P1=$PASS_DIR/plp.lst
150 fi 150 fi
151 151
152 OUTPUT_DIR_BASENAME=$PASS_DIR 152 OUTPUT_DIR_BASENAME=$PASS_DIR
153 RES_DIR="$PASS_DIR/res_p3" 153 RES_DIR="$PASS_DIR/res_p3"
154 LOGFILE=$PASS_DIR"/info_p3.log" 154 LOGFILE=$PASS_DIR"/info_p3.log"
155 ERRORFILE=$PASS_DIR"/error_p3.log" 155 ERRORFILE=$PASS_DIR"/error_p3.log"
156 156
157 #------------------# 157 #------------------#
158 # Create WORKSPACE # 158 # Create WORKSPACE #
159 #------------------# 159 #------------------#
160 160
161 # Lock directory 161 # Lock directory
162 if [ -e $OUTPUT_DIR_BASENAME/THIRDPASS.lock ] && [ $RERUN -eq 0 ]; then print_warn "[${BASENAME}] THIRDPASS is locked -> exit" 2; exit 1; fi 162 if [ -e $OUTPUT_DIR_BASENAME/THIRDPASS.lock ] && [ $RERUN -eq 0 ]; then print_warn "[${BASENAME}] THIRDPASS is locked -> exit" 2; exit 1; fi
163 rm "$OUTPUT_DIR_BASENAME/THIRDPASS.unlock" > /dev/null 2>&1 163 rm "$OUTPUT_DIR_BASENAME/THIRDPASS.unlock" > /dev/null 2>&1
164 touch "$OUTPUT_DIR_BASENAME/THIRDPASS.lock" > /dev/null 2>&1 164 touch "$OUTPUT_DIR_BASENAME/THIRDPASS.lock" > /dev/null 2>&1
165 165
166 if [ $RERUN -eq 0 ]; then rm -r $RES_DIR > /dev/null 2>&1; fi 166 if [ $RERUN -eq 0 ]; then rm -r $RES_DIR > /dev/null 2>&1; fi
167 mkdir -p $RES_DIR 167 mkdir -p $RES_DIR
168 print_info "[${BASENAME}] Make directory $RES_DIR" 3 168 print_info "[${BASENAME}] Make directory $RES_DIR" 3
169 169
170 #--------------------# 170 #--------------------#
171 # Save configuration # 171 # Save configuration #
172 #--------------------# 172 #--------------------#
173 cp $THIRDPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/ThirdPass.cfg 173 cp $THIRDPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/ThirdPass.cfg
174 echo "RES_DIR=$RES_DIR" >> $OUTPUT_DIR_BASENAME/ThirdPass.cfg 174 echo "RES_DIR=$RES_DIR" >> $OUTPUT_DIR_BASENAME/ThirdPass.cfg
175 print_info "[${BASENAME}] Save config in $OUTPUT_DIR_BASENAME/ThirdPass.cfg" 1 175 print_info "[${BASENAME}] Save config in $OUTPUT_DIR_BASENAME/ThirdPass.cfg" 1
176 176
177 #--------------------------------------------------# 177 #--------------------------------------------------#
178 # Third Pass using trigger file (DECODING) # 178 # Third Pass using trigger file (DECODING) #
179 #--------------------------------------------------# 179 #--------------------------------------------------#
180 print_info "[${BASENAME}] Launch Third Pass" 1 180 print_info "[${BASENAME}] Launch Third Pass" 1
181 181
182 ## Generate speeral config file adding trigger rep 182 ## Generate speeral config file adding trigger rep
183 cat $SPEERAL_CFG_PATH/$SPEERAL_CFG_FILE | sed -e "s|<nom>[^<]*</nom>|<nom>$OUTPUT_DIR_BASENAME/LEX/speeral/LEXIQUE_V6_ext</nom>|g" \ 183 cat $SPEERAL_CFG_PATH/$SPEERAL_CFG_FILE | sed -e "s|<nom>[^<]*</nom>|<nom>$OUTPUT_DIR_BASENAME/LEX/speeral/LEXIQUE_V6_ext</nom>|g" \
184 | sed -e "s|<binode>[^<]*</binode>|<binode>$OUTPUT_DIR_BASENAME/LEX/speeral/LEXIQUE_V6_ext.bin</binode>|g" \ 184 | sed -e "s|<binode>[^<]*</binode>|<binode>$OUTPUT_DIR_BASENAME/LEX/speeral/LEXIQUE_V6_ext.bin</binode>|g" \
185 | sed -e "s|<trigger><dir>[^<]*</dir></trigger>|<trigger><dir>$TRIGGER_SPEERAL</dir></trigger>|g" > $OUTPUT_DIR_BASENAME/SpeeralThirdPass.xml 185 | sed -e "s|<trigger><dir>[^<]*</dir></trigger>|<trigger><dir>$TRIGGER_SPEERAL</dir></trigger>|g" > $OUTPUT_DIR_BASENAME/SpeeralThirdPass.xml
186 SPEERAL_THIRD_CFG=$OUTPUT_DIR_BASENAME/SpeeralThirdPass.xml 186 SPEERAL_THIRD_CFG=$OUTPUT_DIR_BASENAME/SpeeralThirdPass.xml
187 print_info "[${BASENAME}] Third Pass Speeral Config file ${SPEERAL_THIRD_CFG}" 3 187 print_info "[${BASENAME}] Third Pass Speeral Config file ${SPEERAL_THIRD_CFG}" 3
188 188
189 # for all speaker 189 # for all speaker
190 for lspeaker in $(ls $LST/*.lst) 190 for lspeaker in $(ls $LST/*.lst)
191 do 191 do
192 speaker=$(basename $lspeaker ".lst") 192 speaker=$(basename $lspeaker ".lst")
193 # for all AM 193 # for all AM
194 for (( i=0; $i<${#MTAG[@]} ; i++ )) 194 for (( i=0; $i<${#MTAG[@]} ; i++ ))
195 do 195 do
196 if [ -e $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst ]; then 196 if [ -e $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst ]; then
197 type=$(grep -e "${speaker}$" "$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst") 197 type=$(grep -e "${speaker}$" "$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst")
198 ## if is the good AM for the speaker 198 ## if is the good AM for the speaker
199 if [ -n "$type" ] 199 if [ -n "$type" ]
200 then 200 then
201 ## Speeral decoding 201 ## Speeral decoding
202 if [ -s $HMM/$speaker.hmm ] && [ -s $HMM/$speaker.cls ] 202 if [ -s $HMM/$speaker.hmm ] && [ -s $HMM/$speaker.cls ]
203 then 203 then
204 print_info "[${BASENAME}] $SPEERAL_BIN $LST/$speaker.lst $RES_DIR $SPEERAL_THIRD_CFG -r $PLP_DIR_P1 -m $HMM/$speaker.hmm -c $HMM/$speaker.cls $FORKS --lock" 3 204 print_info "[${BASENAME}] $SPEERAL_BIN $LST/$speaker.lst $RES_DIR $SPEERAL_THIRD_CFG -r $PLP_DIR_P1 -m $HMM/$speaker.hmm -c $HMM/$speaker.cls $FORKS --lock" 3
205 $SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_THIRD_CFG} -r $PLP_DIR_P1 -m $HMM/$speaker.hmm -c $HMM/$speaker.cls $FORKS --lock 205 $SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_THIRD_CFG} -r $PLP_DIR_P1 -m $HMM/$speaker.hmm -c $HMM/$speaker.cls $FORKS --lock
206 else 206 else
207 print_warn "[${BASENAME}] $HMM/$speaker.hmm and $speaker.cls empty, do default decoding..." 2 207 print_warn "[${BASENAME}] $HMM/$speaker.hmm and $speaker.cls empty, do default decoding..." 2
208 print_info "$SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_THIRD_CFG} -r $PLP_DIR_P1 -m $SPEERAL_AM/${MODS[$i]}.hmm -c $SPEERAL_AM/${MODS[$i]}.cls $FORKS --lock" 3 208 print_info "$SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_THIRD_CFG} -r $PLP_DIR_P1 -m $SPEERAL_AM/${MODS[$i]}.hmm -c $SPEERAL_AM/${MODS[$i]}.cls $FORKS --lock" 3
209 $SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_THIRD_CFG} -r $PLP_DIR_P1 -m $SPEERAL_AM/${MODS[$i]}.hmm -c $SPEERAL_AM/${MODS[$i]}.cls $FORKS --lock 209 $SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_THIRD_CFG} -r $PLP_DIR_P1 -m $SPEERAL_AM/${MODS[$i]}.hmm -c $SPEERAL_AM/${MODS[$i]}.cls $FORKS --lock
210 fi 210 fi
211 211
212 if [ $CHECK -eq 1 ] 212 if [ $CHECK -eq 1 ]
213 then 213 then
214 check_third_pass_output_speeral "$LST/$speaker.lst" "$RES_DIR" 214 check_third_pass_output_speeral "$LST/$speaker.lst" "$RES_DIR"
215 if [ $? -eq 1 ] 215 if [ $? -eq 1 ]
216 then 216 then
217 217
218 print_warn "[${BASENAME}] Speeral output error : check $LOGFILE" 2 218 print_warn "[${BASENAME}] Speeral output error : check $LOGFILE" 2
219 print_log_file $LOGFILE "WARN : Speeral number of output ERROR $LST/$speaker.lst" 219 print_log_file $LOGFILE "WARN : Speeral number of output ERROR $LST/$speaker.lst"
220 ls $RES_DIR/*.seg 2>/dev/null | grep -e "$speaker" | sed -e "s|$RES_DIR\/||" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp 220 ls $RES_DIR/*.seg 2>/dev/null | grep -e "$speaker" | sed -e "s|$RES_DIR\/||" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp
221 print_log_file $LOGFILE "Segs (and treil) not done :\n[" 221 print_log_file $LOGFILE "Segs (and treil) not done :\n["
222 diff $LST/$speaker.lst ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> $LOGFILE 222 diff $LST/$speaker.lst ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> $LOGFILE
223 print_log_file $LOGFILE "] [$(date +'%d/%m/%y %H:%M:%S')]" 223 print_log_file $LOGFILE "] [$(date +'%d/%m/%y %H:%M:%S')]"
224 rm ${OUTPUT_DIR_BASENAME}/.tmp 224 rm ${OUTPUT_DIR_BASENAME}/.tmp
225 fi 225 fi
226 fi 226 fi
227 break 227 break
228 fi 228 fi
229 fi 229 fi
230 done 230 done
231 done 231 done
232 232
233 ## Check missing seg and log it 233 ## Check missing seg and log it
234 234
235 ## Check missing seg and log it 235 ## Check missing seg and log it
236 if [ $CHECK -eq 1 ] 236 if [ $CHECK -eq 1 ]
237 then 237 then
238 ls $RES_DIR/*.treil 2>/deV/null | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.treil//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp 238 ls $RES_DIR/*.treil 2>/deV/null | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.treil//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp
239 todo=$(cat ${PLP_FILE_P1} 2>/dev/null | wc -l) 239 todo=$(cat ${PLP_LIST_P1} 2>/dev/null | wc -l)
240 if [ $todo -eq 0 ]; then todo=1;fi 240 if [ $todo -eq 0 ]; then todo=1;fi
241 notdone=$(($todo - $(cat ${OUTPUT_DIR_BASENAME}/.tmp | wc -l))) 241 notdone=$(($todo - $(cat ${OUTPUT_DIR_BASENAME}/.tmp | wc -l)))
242 pourcentage=$((($notdone*100)/$todo)) 242 pourcentage=$((($notdone*100)/$todo))
243 if [ $notdone -ne 0 ] 243 if [ $notdone -ne 0 ]
244 then 244 then
245 print_error "[${BASENAME}] Check $ERRORFILE" 245 print_error "[${BASENAME}] Check $ERRORFILE"
246 print_log_file "$ERRORFILE" "ERROR : Treil not done [" 246 print_log_file "$ERRORFILE" "ERROR : Treil not done ["
247 diff ${PLP_FILE_P1} ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> $ERRORFILE 247 diff ${PLP_LIST_P1} ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> $ERRORFILE
248 print_log_file "$ERRORFILE" "] $pourcentage% $BASENAME" 248 print_log_file "$ERRORFILE" "] $pourcentage% $BASENAME"
249 else 249 else
250 print_log_file "$LOGFILE" "P3 OK $BASENAME | $(date +'%d/%m/%y %H:%M:%S')" 250 print_log_file "$LOGFILE" "P3 OK $BASENAME | $(date +'%d/%m/%y %H:%M:%S')"
251 fi 251 fi
252 rm ${OUTPUT_DIR_BASENAME}/.tmp > /dev/null 2>&1 252 rm ${OUTPUT_DIR_BASENAME}/.tmp > /dev/null 2>&1
253 fi 253 fi
254 254
255 #---------------# 255 #---------------#
256 # Convert res # 256 # Convert res #
257 #---------------# 257 #---------------#
258 258
259 print_info "[${BASENAME}] Convert .res into .ctm" 1 259 print_info "[${BASENAME}] Convert .res into .ctm" 1
260 # .res => .ctm 260 # .res => .ctm
261 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.3pass.ctm 261 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.3pass.ctm
262 print_info "[${BASENAME}] Convert .res into .trs" 1 262 print_info "[${BASENAME}] Convert .res into .trs" 1
263 # .res => .trs 263 # .res => .trs
264 echo -e "name $AUTHOR\nfileName ${BASENAME}\nfileExt wav\nsegFile ${OUTPUT_DIR_BASENAME}/${BASENAME}.seg" > ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg 264 echo -e "name $AUTHOR\nfileName ${BASENAME}\nfileExt wav\nsegFile ${OUTPUT_DIR_BASENAME}/${BASENAME}.seg" > ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg
265 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TRS --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.3pass.trs --trs_config ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg 265 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TRS --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.3pass.trs --trs_config ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg
266 rm ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg > /dev/null 2>&1 266 rm ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg > /dev/null 2>&1
267 print_info "[${BASENAME}] Convert .res into .txt" 1 267 print_info "[${BASENAME}] Convert .res into .txt" 1
268 # .res => .txt 268 # .res => .txt
269 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.3pass.txt 269 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.3pass.txt
270 270
271 271
272 print_info "[${BASENAME}] <= P3 End | $(date +'%d/%m/%y %H:%M:%S')" 1 272 print_info "[${BASENAME}] <= P3 End | $(date +'%d/%m/%y %H:%M:%S')" 1
273 273
274 # unlock directory 274 # unlock directory
275 mv "$OUTPUT_DIR_BASENAME/THIRDPASS.lock" "$OUTPUT_DIR_BASENAME/THIRDPASS.unlock" 275 mv "$OUTPUT_DIR_BASENAME/THIRDPASS.lock" "$OUTPUT_DIR_BASENAME/THIRDPASS.unlock"
276 276
277 277