Commit 135404bcf3b764441731134b9822b01a6e4902f0
1 parent
1fd315c89e
Exists in
master
Modify verbose and log system into FirstPass.sh
Showing 4 changed files with 135 additions and 69 deletions Inline Diff
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" >&2 | 36 | echo "ERROR : Can't find configuration file $FIRSTPASS_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:cf:r" opt | 44 | while getopts ":hDv:cf:r" opt |
44 | do | 45 | do |
45 | case $opt in | 46 | case $opt in |
46 | h) | 47 | h) |
47 | echo -e "$0 [OPTIONS] <WAV_FILE> <OUTPUT_DIRECTORY>\n" | 48 | echo -e "$0 [OPTIONS] <WAV_FILE> <OUTPUT_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 :\tCheck process, stop if error detected" | 53 | echo -e "\t\t-c :\tCheck process, and log it into files, can stop if error detected" |
53 | 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)" |
54 | echo -e "\t\t-r :\tforce rerun the wav file" | 55 | echo -e "\t\t-r :\tforce rerun the wav file" |
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." >&2 |
74 | exit 1 | 75 | exit 1 |
75 | ;; | 76 | ;; |
76 | \?) | 77 | \?) |
77 | echo "BAD USAGE : unknow opton -$OPTARG" | 78 | echo "BAD USAGE : unknow opton -$OPTARG" |
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 2 ] | 98 | if [ $(($#-($OPTIND-1))) -ne 2 ] |
98 | then | 99 | then |
99 | echo "BAD USAGE : FirstPass.sh [OPTIONS] <WAV_FILE> <OUTPUT_DIR>" | 100 | echo "BAD USAGE : FirstPass.sh [OPTIONS] <WAV_FILE> <OUTPUT_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 audio file - First argument | 106 | # check audio file - First argument |
106 | if [ -e $1 ] && [ -s $1 ] | 107 | if [ -e $1 ] && [ -s $1 ] |
107 | then | 108 | then |
108 | # absolute path to wav file | 109 | # absolute path to wav file |
109 | WAV_FILE=$(readlink -e $1) | 110 | WAV_FILE=$(readlink -e $1) |
110 | # wav filename | 111 | # wav filename |
111 | FILENAME=$(basename $WAV_FILE) | 112 | FILENAME=$(basename $WAV_FILE) |
112 | # wav filename without extension | 113 | # wav filename without extension |
113 | BASENAME=${FILENAME%.*} | 114 | BASENAME=${FILENAME%.*} |
114 | 115 | ||
115 | print_info "=> $BASENAME P1 | $(date +'%d/%m/%y %H:%M:%S')" 1 | 116 | print_info "[${BASENAME}] => P1 start | $(date +'%d/%m/%y %H:%M:%S')" 1 |
116 | print_info "$WAV_FILE OK" 1 | 117 | print_info "[${BASENAME}] $WAV_FILE OK" 2 |
117 | else | 118 | else |
118 | print_error "can't find $1 OR file is empty" | 119 | print_error "can't find $1 OR file is empty" |
119 | exit 1 | 120 | exit 1 |
120 | fi | 121 | fi |
121 | 122 | ||
122 | # check output directory - Second argument | 123 | # check output directory - Second argument |
123 | if [ ! -e $2 ] | 124 | if [ ! -e $2 ] |
124 | then | 125 | then |
125 | mkdir -p $2 | 126 | mkdir -p $2 |
126 | print_info "Make directory $2" 1 | 127 | print_info "[${BASENAME}] Make directory $2" 2 |
127 | fi | 128 | fi |
128 | 129 | ||
129 | 130 | ||
130 | #-------------# | 131 | #-------------# |
131 | # GLOBAL VARS # | 132 | # GLOBAL VARS # |
132 | #-------------# | 133 | #-------------# |
133 | OUTPUT_DIR=$(readlink -e $2) # Output directory absolute path | 134 | OUTPUT_DIR=$(readlink -e $2) # Output directory absolute path |
134 | OUTPUT_DIR_BASENAME="$OUTPUT_DIR/$BASENAME/" # New OUTPUT_DIR with BASENAME | 135 | OUTPUT_DIR_BASENAME="$OUTPUT_DIR/$BASENAME/" # New OUTPUT_DIR with BASENAME |
135 | PLP_FILE="$OUTPUT_DIR_BASENAME/$BASENAME.plp" # Global PLP file | 136 | PLP_FILE="$OUTPUT_DIR_BASENAME/$BASENAME.plp" # Global PLP file |
136 | PLP_DIR="$OUTPUT_DIR_BASENAME/PLP/" # Segmented PLP files directory | 137 | PLP_DIR="$OUTPUT_DIR_BASENAME/PLP/" # Segmented PLP files directory |
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/info_p1.log" | 141 | LOGFILE="$OUTPUT_DIR_BASENAME/info_p1.log" |
141 | ERRORFILE="$OUTPUT_DIR/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 "Make directory $OUTPUT_DIR_BASENAME" 1 | 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 "Make directory $PLP_DIR" 1 | 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 "Make directory $RES_DIR" 1 | 168 | print_info "[${BASENAME}] Make directory $RES_DIR" 2 |
169 | rm $LOGFILE $ERRORFILE > /dev/null 2>&1 | ||
168 | 170 | ||
169 | #--------------------# | 171 | #--------------------# |
170 | # Save configuration # | 172 | # Save configuration # |
171 | #--------------------# | 173 | #--------------------# |
172 | cp $FIRSTPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/FirstPass.cfg | 174 | cp $FIRSTPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/FirstPass.cfg |
173 | 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 |
174 | echo "WAV_FILE=$WAV_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg | 176 | echo "WAV_FILE=$WAV_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg |
175 | echo "BASENAME=$BASENAME" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg | 177 | echo "BASENAME=$BASENAME" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg |
176 | echo "OUTPUT_DIR=$OUTPUT_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg | 178 | echo "OUTPUT_DIR=$OUTPUT_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg |
177 | 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 |
178 | echo "PLP_FILE=$PLP_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg | 180 | echo "PLP_FILE=$PLP_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg |
179 | echo "PLP_DIR=$PLP_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg | 181 | echo "PLP_DIR=$PLP_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg |
180 | echo "SEG_FILE=$SEG_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg | 182 | echo "SEG_FILE=$SEG_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg |
181 | echo "LBL_FILE=$LBL_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg | 183 | echo "LBL_FILE=$LBL_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg |
182 | echo "RES_DIR=$RES_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg | 184 | echo "RES_DIR=$RES_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg |
183 | print_info "save config in $OUTPUT_DIR_BASENAME/FirstPass.cfg" 1 | 185 | print_info "[${BASENAME}] save config in $OUTPUT_DIR_BASENAME/FirstPass.cfg" 1 |
184 | 186 | ||
185 | #-------------------------# | 187 | #-------------------------# |
186 | # Check Audio File Format # | 188 | # Check Audio File Format # |
187 | #-------------------------# | 189 | #-------------------------# |
188 | error=0 | 190 | error=0 |
189 | temp=$(avconv -i $WAV_FILE 2>&1 | grep "16000 Hz") | 191 | temp=$(avconv -i $WAV_FILE 2>&1 | grep "16000 Hz") |
190 | if [ -z "$temp" ]; then error=1; fi | 192 | if [ -z "$temp" ]; then error=1; fi |
191 | temp=$(avconv -i $WAV_FILE 2>&1 | grep "1 channels") | 193 | temp=$(avconv -i $WAV_FILE 2>&1 | grep "1 channels") |
192 | if [ -z "$temp" ]; then error=1; fi | 194 | if [ -z "$temp" ]; then error=1; fi |
193 | temp=$(avconv -i $WAV_FILE 2>&1 | grep "s16") | 195 | temp=$(avconv -i $WAV_FILE 2>&1 | grep "s16") |
194 | if [ -z "$temp" ]; then error=1; fi | 196 | if [ -z "$temp" ]; then error=1; fi |
195 | 197 | ||
196 | if [ $error -eq 1 ] | 198 | if [ $error -eq 1 ] |
197 | then | 199 | then |
198 | print_message $WARNING 2 "$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" |
199 | print_message $INFO 3 "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" |
200 | 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 |
201 | WAV_FILE=$OUTPUT_DIR_BASENAME/$BASENAME.wav | 203 | WAV_FILE=$OUTPUT_DIR_BASENAME/$BASENAME.wav |
202 | FILENAME=$BASENAME.wav | 204 | FILENAME=$BASENAME.wav |
203 | print_message $INFO 1 "new wav file : $WAV_FILE" | 205 | print_message $INFO 1 "[${BASENAME}] new wav file : $WAV_FILE" |
204 | fi | 206 | fi |
205 | 207 | ||
206 | #---------------# | 208 | #---------------# |
207 | # Get SRT file # | 209 | # Get SRT file # |
208 | #---------------# | 210 | #---------------# |
209 | if [ -s $(dirname $WAV_FILE)/$BASENAME.SRT ] | 211 | if [ -s $(dirname $WAV_FILE)/$BASENAME.SRT ] |
210 | then | 212 | then |
211 | cp $(dirname $WAV_FILE)/$BASENAME.SRT $OUTPUT_DIR_BASENAME/$BASENAME.SRT | 213 | cp $(dirname $WAV_FILE)/$BASENAME.SRT $OUTPUT_DIR_BASENAME/$BASENAME.SRT |
212 | print_info "copy $BASENAME.SRT file into workingspace" 1 | 214 | print_info "[${BASENAME}] copy $BASENAME.SRT file into $OUTPUT_DIR_BASENAME" 3 |
213 | fi | 215 | fi |
214 | 216 | ||
215 | #------------# | 217 | #------------# |
216 | # WAV -> PLP # | 218 | # WAV -> PLP # |
217 | #------------# | 219 | #------------# |
218 | print_info "convert WAV -> PLP" 1 | 220 | print_info "[${BASENAME}] convert WAV -> PLP" 1 |
219 | echo $FILENAME > $OUTPUT_DIR_BASENAME/list.tmp | 221 | echo $FILENAME > $OUTPUT_DIR_BASENAME/list.tmp |
220 | print_info "$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 | 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 |
221 | " 2 | ||
222 | 223 | ||
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 $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 |
224 | 225 | ||
225 | if [ $CHECK -eq 1 ] | 226 | if [ $CHECK -eq 1 ] |
226 | then | 227 | then |
227 | check_first_pass_plp "$PLP_FILE" | 228 | check_first_pass_plp "$PLP_FILE" |
228 | if [ $? -eq 1 ] | 229 | if [ $? -eq 1 ] |
229 | then | 230 | then |
230 | echo "ERROR [$(date +'%d/%m/%y %H:%M:%S')] $PLP_FILE" >> $ERRORFILE | 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 | ||
231 | exit 1 | 233 | exit 1 |
232 | fi | 234 | fi |
233 | fi | 235 | fi |
234 | 236 | ||
235 | rm $OUTPUT_DIR_BASENAME/list.tmp | 237 | rm $OUTPUT_DIR_BASENAME/list.tmp |
236 | 238 | ||
237 | #------------------------------# | 239 | #------------------------------# |
238 | # S/NS + SPEAKERS SEGMENTATION # | 240 | # S/NS + SPEAKERS SEGMENTATION # |
239 | #------------------------------# | 241 | #------------------------------# |
240 | print_info "Launch speakers diarization" 1 | 242 | print_info "[${BASENAME}] Launch speakers diarization" 1 |
241 | # Calcul seg file | 243 | # Calcul seg file |
242 | print_info "java -Xmx4096m -jar $BIN_PATH/LIUM_SpkDiarization-4.2.jar --fInputMask=${WAV_FILE} --sOutputMask=${SEG_FILE} $BASENAME" 2 | 244 | print_info "[${BASENAME}] java -Xmx4096m -jar $BIN_PATH/LIUM_SpkDiarization-4.2.jar --fInputMask=${WAV_FILE} --sOutputMask=${SEG_FILE} $BASENAME" 3 |
243 | #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 |
244 | 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 |
245 | 247 | ||
246 | if [ $CHECK -eq 1 ] && ( [ ! -e $SEG_FILE ] || [ -z $SEG_FILE ] ) | 248 | if [ $CHECK -eq 1 ] && ( [ ! -e $SEG_FILE ] || [ -z $SEG_FILE ] ) |
247 | then | 249 | then |
248 | echo "ERROR [$(date +'%d/%m/%y %H:%M:%S')] $SEG_FILE" >> $ERRORFILE | 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 | ||
249 | exit 1 | 252 | exit 1 |
250 | fi | 253 | fi |
251 | 254 | ||
252 | 255 | ||
253 | # Create LBL file | 256 | # Create LBL file |
254 | print_info "Extract LBL file from SEG file" 2 | 257 | print_info "Extract LBL file from SEG file" 1 |
255 | 258 | ||
256 | 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 |
257 | 260 | ||
258 | if [ $CHECK -eq 1 ] && ( [ ! -e $LBL_FILE ] || [ -z $LBL_FILE ] ) | 261 | if [ $CHECK -eq 1 ] && ( [ ! -e $LBL_FILE ] || [ -z $LBL_FILE ] ) |
259 | then | 262 | then |
260 | echo "ERROR [$(date +'%d/%m/%y %H:%M:%S')] $LBL_FILE" >> $ERRORFILE | 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 | ||
261 | exit 1 | 265 | exit 1 |
262 | fi | 266 | fi |
263 | 267 | ||
264 | 268 | ||
265 | #----------------------------------------------------# | 269 | #----------------------------------------------------# |
266 | # Cut global PLP file depending to LBL segmentations # | 270 | # Cut global PLP file depending to LBL segmentations # |
267 | #----------------------------------------------------# | 271 | #----------------------------------------------------# |
268 | print_info "Cut PLP file depending to LBL segmentations" 1 | 272 | print_info "[${BASENAME}] Cut PLP file depending to LBL segmentations" 1 |
269 | print_info "$BIN_PATH/gcep $PLP_FILE $LBL_FILE 500 $PLP_DIR -FSEG" 2 | 273 | print_info "[${BASENAME}] $BIN_PATH/gcep $PLP_FILE $LBL_FILE 500 $PLP_DIR -FSEG" 3 |
270 | 274 | ||
271 | $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 |
272 | 276 | ||
273 | if [ $CHECK -eq 1 ] | 277 | if [ $CHECK -eq 1 ] |
274 | then | 278 | then |
275 | check_first_pass_plps_lbl $PLP_DIR $LBL_FILE | 279 | check_first_pass_plps_lbl $PLP_DIR $LBL_FILE |
276 | if [ $? -eq 1 ] | 280 | if [ $? -eq 1 ] |
277 | then | 281 | then |
278 | echo "ERROR [$(date +'%d/%m/%y %H:%M:%S')] $PLP wrong .plp files number" >> $ERRORFILE | 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 | ||
279 | exit 1 | 284 | exit 1 |
280 | fi | 285 | fi |
281 | fi | 286 | fi |
282 | 287 | ||
283 | # change plp files names | 288 | # change plp files names |
284 | cd $PLP_DIR; | 289 | cd $PLP_DIR; |
285 | rename -f s/_/#/g *plp | 290 | rename -f s/_/#/g *plp |
286 | rename -f s/#/_/ *plp | 291 | rename -f s/#/_/ *plp |
287 | cd $OLDPWD | 292 | cd $OLDPWD |
288 | 293 | ||
289 | #---------------------------------------------# | 294 | #---------------------------------------------# |
290 | # PLP files list depending to acoustic models # | 295 | # PLP files list depending to acoustic models # |
291 | #---------------------------------------------# | 296 | #---------------------------------------------# |
292 | print_info "Create PLP list depending of the model" 1 | 297 | print_info "[${BASENAME}] Create PLP list depending of the model" 1 |
293 | # Create a list of plp files | 298 | # Create a list of plp files |
294 | 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 |
295 | 300 | ||
296 | rm $OUTPUT_DIR_BASENAME/plp_*.lst > /dev/null 2>&1 | 301 | rm $OUTPUT_DIR_BASENAME/plp_*.lst > /dev/null 2>&1 |
297 | for (( i=0; $i<${#MTAG[@]} ; i++ )) | 302 | for (( i=0; $i<${#MTAG[@]} ; i++ )) |
298 | do | 303 | do |
299 | a=`grep -e "${MTAG[$i]}" $OUTPUT_DIR_BASENAME/plp.lst` | 304 | a=`grep -e "${MTAG[$i]}" $OUTPUT_DIR_BASENAME/plp.lst` |
300 | if [ -n "$a" ]; then | 305 | if [ -n "$a" ]; then |
301 | print_info "$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst" 3 | 306 | print_info "[${BASENAME}] Creating $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst" 3 |
302 | 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 |
303 | fi | 308 | fi |
304 | done | 309 | done |
305 | 310 | ||
306 | #-----------------------# | 311 | #-----------------------# |
307 | # First Pass (DECODING) # | 312 | # First Pass (DECODING) # |
308 | #-----------------------# | 313 | #-----------------------# |
309 | # | 314 | # |
310 | # For all AM do decoding | 315 | # For all AM do decoding |
311 | # if Check error -> iter on undone decoding (max 1 times) | 316 | # if Check error -> iter on undone decoding (max 1 times) |
312 | # | 317 | # |
313 | print_info "Launch decoding" 1 | 318 | print_info "[${BASENAME}] Launch decoding" 1 |
314 | for (( i=0; $i<${#MTAG[@]} ; i++ )) | 319 | for (( i=0; $i<${#MTAG[@]} ; i++ )) |
315 | do | 320 | do |
316 | redo=1; # nb of try if not all segs is decoded | 321 | redo=1; # nb of try if not all segs is decoded |
317 | if [ -e $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst ] | 322 | if [ -e $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst ] |
318 | then | 323 | then |
319 | todo=$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst | 324 | todo=$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst |
320 | while [ $redo -gt 0 ]; do | 325 | while [ $redo -gt 0 ]; do |
321 | rm $RES_DIR/*.lock > /dev/null 2>&1 | 326 | rm $RES_DIR/*.lock > /dev/null 2>&1 |
322 | print_info "$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" 2 | 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 |
323 | # Run speeral | 328 | # Run speeral |
324 | $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 |
325 | 330 | ||
326 | # Check if error | 331 | # Check if error |
327 | if [ $CHECK -eq 1 ] | 332 | if [ $CHECK -eq 1 ] |
328 | then | 333 | then |
329 | 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" |
330 | # if error | 335 | # if error |
331 | if [ $? -eq 1 ] | 336 | if [ $? -eq 1 ] |
332 | then | 337 | then |
333 | # rerun | 338 | # rerun |
334 | redo=$(($redo - 1)); | 339 | redo=$(($redo - 1)); |
335 | echo -e "WARN : Speeral output ERROR ${OUTPUT_DIR_BASENAME}/plp_${MODS[$i]}.lst" >> $ERRORFILE | 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" | ||
336 | # new plp list | 342 | # new plp list |
337 | # list .seg done and compare to list of seg to do | 343 | # list .seg done and compare to list of seg to do |
338 | 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 |
339 | 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 |
340 | rm ${OUTPUT_DIR_BASENAME}/.tmp | 346 | rm ${OUTPUT_DIR_BASENAME}/.tmp |
341 | # log seg to do | 347 | # log seg to do |
342 | cat ${OUTPUT_DIR_BASENAME}/todo.lst >> $ERRORFILE | 348 | print_log_file $LOGFILE "Segs not done :" |
349 | cat ${OUTPUT_DIR_BASENAME}/todo.lst >> $LOGFILE | ||
343 | todo=${OUTPUT_DIR_BASENAME}/todo.lst | 350 | todo=${OUTPUT_DIR_BASENAME}/todo.lst |
344 | echo -e "WARN : Try $redo" >> $ERRORFILE | 351 | print_warn "[${BASENAME}] Try $redo" 3 |
345 | fi | 352 | fi |
346 | else | ||
347 | redo=-5; | ||
348 | fi | 353 | fi |
349 | done | 354 | done |
350 | if [ $redo -eq 0 ] | ||
351 | then | ||
352 | echo -e "ERROR : Speeral $todo" >> $ERRORFILE | ||
353 | cat ${OUTPUT_DIR_BASENAME}/todo.lst >> $ERRORFILE | ||
354 | #exit 1 | ||
355 | fi | ||
356 | rm ${OUTPUT_DIR_BASENAME}/todo.lst > /dev/null 2>&1 | 355 | rm ${OUTPUT_DIR_BASENAME}/todo.lst > /dev/null 2>&1 |
357 | #rm $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst | 356 | #rm $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst |
358 | rm $RES_DIR/*.lock > /dev/null 2>&1 | 357 | rm $RES_DIR/*.lock > /dev/null 2>&1 |
359 | fi | 358 | fi |
360 | done | 359 | done |
361 | 360 | ||
362 | print_info "<= End P1 $BASENAME | $(date +'%d/%m/%y %H:%M:%S')" 1 | ||
363 | |||
364 | ## Check missing seg and log it | 361 | ## Check missing seg and log it |
365 | ls $RES_DIR/*.seg | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp | 362 | if [ $CHECK -eq 1 ] |
366 | echo -e "$BASENAME P1 END\n[" >> $LOGFILE | 363 | then |
367 | diff ${OUTPUT_DIR_BASENAME}/plp.lst ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> $LOGFILE | 364 | ls $RES_DIR/*.seg | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp |
368 | todo=$(cat ${OUTPUT_DIR_BASENAME}/plp.lst | wc -l) | 365 | todo=$(cat ${OUTPUT_DIR_BASENAME}/plp.lst | wc -l) |
369 | notdone=$(($todo - $(cat ${OUTPUT_DIR_BASENAME}/.tmp | wc -l))) | 366 | if [ $todo -eq 0 ]; then todo=1;fi |
370 | pourcentage=$((($notdone*100)/$todo)) | 367 | notdone=$(($todo - $(cat ${OUTPUT_DIR_BASENAME}/.tmp | wc -l))) |
371 | echo -e "] $pourcentage% $BASENAME" >> $LOGFILE | 368 | pourcentage=$((($notdone*100)/$todo)) |
372 | rm ${OUTPUT_DIR_BASENAME}/.tmp | ||
373 | 369 | ||
370 | if [ $notdone -ne 0 ] | ||
371 | then | ||
372 | print_error "[${BASENAME}] ERROR : check $ERRORFILE" | ||
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 | ||
375 | print_log_file "$ERRORFILE" "] $pourcentage% $BASENAME" | ||
376 | else | ||
377 | print_log_file "$LOGFILE" "P1 OK $BASENAME | $(date +'%d/%m/%y %H:%M:%S')" | ||
378 | fi | ||
379 | rm ${OUTPUT_DIR_BASENAME}/.tmp | ||
380 | fi | ||
374 | 381 | ||
375 | #---------------# | 382 | #---------------# |
376 | # Convert res # | 383 | # Convert res # |
377 | #---------------# | 384 | #---------------# |
378 | 385 | print_info "[${BASENAME}] Convert .res into .ctm" 1 | |
379 | # .res => .ctm | 386 | # .res => .ctm |
380 | $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 |
main_tools/OneScriptToRuleThemAll.sh
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | ##################################### | 3 | ##################################### |
4 | # File: OneScriptToRuleThemAll.sh # | 4 | # File: OneScriptToRuleThemAll.sh # |
5 | # Brief : Script to launch OTMEDIA # | 5 | # Brief : Script to launch OTMEDIA # |
6 | # Version : 1.0 # | 6 | # Version : 1.0 # |
7 | # Date : 23/07/2013 # | 7 | # Date : 23/07/2013 # |
8 | # Author : Jean-François Rey # | 8 | # Author : Jean-François Rey # |
9 | ##################################### | 9 | ##################################### |
10 | 10 | ||
11 | echo -e "OneScriptToRuleThemAll :" | 11 | echo -e "OneScriptToRuleThemAll :" |
12 | LORD=" Three::rings | 12 | LORD=" Three::rings |
13 | for:::the::Elven-King | 13 | for:::the::Elven-King |
14 | under:the:sky,:Seven:for:the | 14 | under:the:sky,:Seven:for:the |
15 | Dwarf-Lords::in::their::halls:of | 15 | Dwarf-Lords::in::their::halls:of |
16 | stone,:Nine for:Mortal | 16 | stone,:Nine for:Mortal |
17 | :::Men::: ________ doomed::to | 17 | :::Men::: ________ doomed::to |
18 | die.:One _,-'...:... \`-. for:::the | 18 | die.:One _,-'...:... \`-. for:::the |
19 | ::Dark:: ,- .:::::::::::. \`. Lord::on | 19 | ::Dark:: ,- .:::::::::::. \`. Lord::on |
20 | his:dark ,' .:::::zzz:::::. \`. :throne: | 20 | his:dark ,' .:::::zzz:::::. \`. :throne: |
21 | In:::the/ ::::OTMEDIA:::: \ Land::of | 21 | In:::the/ ::::OTMEDIA:::: \ Land::of |
22 | :Mordor:\ ::::SCRIPTS:::: / :where:: | 22 | :Mordor:\ ::::SCRIPTS:::: / :where:: |
23 | ::the::: '. '::::YEEEP::::' ,' Shadows: | 23 | ::the::: '. '::::YEEEP::::' ,' Shadows: |
24 | lie.::One \`. \`\`:::::::::'' ,' Ring::to | 24 | lie.::One \`. \`\`:::::::::'' ,' Ring::to |
25 | ::rule:: \`-._\`\`\`:'''_,-' ::them:: | 25 | ::rule:: \`-._\`\`\`:'''_,-' ::them:: |
26 | all,::One \`-----' ring::to | 26 | all,::One \`-----' ring::to |
27 | ::find::: them,:One | 27 | ::find::: them,:One |
28 | Ring:::::to bring::them | 28 | Ring:::::to bring::them |
29 | all::and::in:the:darkness:bind | 29 | all::and::in:the:darkness:bind |
30 | them:In:the:Land:of:Mordor | 30 | them:In:the:Land:of:Mordor |
31 | where:::the::Shadows | 31 | where:::the::Shadows |
32 | :::lie.:::" | 32 | :::lie.:::" |
33 | 33 | ||
34 | 34 | ||
35 | # Check OTMEDIA_HOME env var | 35 | # Check OTMEDIA_HOME env var |
36 | if [ -z ${OTMEDIA_HOME} ] | 36 | if [ -z ${OTMEDIA_HOME} ] |
37 | then | 37 | then |
38 | OTMEDIA_HOME=$(dirname $(dirname $(readlink -e $0))) | 38 | OTMEDIA_HOME=$(dirname $(dirname $(readlink -e $0))) |
39 | export OTMEDIA_HOME=$OTMEDIA_HOME | 39 | export OTMEDIA_HOME=$OTMEDIA_HOME |
40 | fi | 40 | fi |
41 | 41 | ||
42 | # where is OneScriptToRuleThemAll.sh | 42 | # where is OneScriptToRuleThemAll.sh |
43 | MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0)) | 43 | MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0)) |
44 | 44 | ||
45 | RING="" | 45 | RING="" |
46 | $p1=0 | ||
47 | $p2=0 | ||
48 | $conf=0 | ||
49 | $exploitconf=0 | ||
50 | $p3=0 | ||
51 | $recompose=0 | ||
52 | $scoring=0 | ||
46 | 53 | ||
47 | #---------------# | 54 | #---------------# |
48 | # Parse Options # | 55 | # Parse Options # |
49 | #---------------# | 56 | #---------------# |
50 | while getopts ":hDv:cf:r" opt | 57 | while getopts ":hDv:cf:r123CeRs" opt |
51 | do | 58 | do |
52 | case $opt in | 59 | case $opt in |
53 | h) | 60 | h) |
54 | echo -e "$0 [OPTIONS] <WAV_FILE> <OUTPUT_DIRECTORY>\n" | 61 | echo -e "$0 [OPTIONS] <WAV_FILE> <OUTPUT_DIRECTORY>\n" |
55 | echo -e "\t Options:" | 62 | echo -e "\t Options:" |
56 | echo -e "\t\t-h :\tprint this message" | 63 | echo -e "\t\t-h :\tprint this message" |
57 | echo -e "\t\t-D :\tDEBUG mode on" | 64 | echo -e "\t\t-D :\tDEBUG mode on" |
58 | echo -e "\t\t-v l :\tVerbose mode, l=(1|2|3) level mode" | 65 | echo -e "\t\t-v l :\tVerbose mode, l=(1|2|3) level mode" |
59 | echo -e "\t\t-c :\tCheck process, stop if error detected" | 66 | echo -e "\t\t-c :\tCheck process, stop if error detected" |
60 | echo -e "\t\t-f n :\tspecify a speeral forks number (default 1)" | 67 | echo -e "\t\t-f n :\tSpecify a speeral forks number (default 1)" |
61 | echo -e "\t\t-r :\tforce rerun the wav file" | 68 | echo -e "\t\t-r :\tForce to rerun without deleting all files" |
69 | echo -e "\t\t-a :\tDo every pass" | ||
70 | echo -e "\t\t-1 :\tDo 1rt pass" | ||
71 | echo -e "\t\t-2 :\tDo 2nd pass" | ||
72 | echo -e "\t\t-3 :\tDo 3rd pass" | ||
73 | echo -e "\t\t-C :\tDo confidence pass" | ||
74 | echo -e "\t\t-e :\tDo exploit confidence pass (SOLR)" | ||
75 | echo -e "\t\t-R :\tDo recompose res" | ||
76 | echo -e "\t\t-s :\tDo scoring" | ||
62 | exit 1 | 77 | exit 1 |
63 | ;; | 78 | ;; |
64 | D) | 79 | D) |
65 | RING=$RING" -D" | 80 | RING=$RING" -D" |
66 | ;; | 81 | ;; |
67 | v) | 82 | v) |
68 | RING=$RING" -v $OPTARG" | 83 | RING=$RING" -v $OPTARG" |
69 | ;; | 84 | ;; |
70 | c) | 85 | c) |
71 | RING=$RING" -c" | 86 | RING=$RING" -c" |
72 | ;; | 87 | ;; |
73 | f) | 88 | f) |
74 | RING=$RING" -f $OPTARG" | 89 | RING=$RING" -f $OPTARG" |
75 | ;; | 90 | ;; |
76 | r) | 91 | r) |
77 | RING=$RING" -r" | 92 | RING=$RING" -r" |
78 | ;; | 93 | ;; |
94 | a) | ||
95 | p1=1 | ||
96 | p2=1 | ||
97 | p3=1 | ||
98 | conf=1 | ||
99 | exploitconf=1 | ||
100 | recompose=1 | ||
101 | scoring=1 | ||
102 | ;; | ||
103 | 1) | ||
104 | p1=1 | ||
105 | ;; | ||
106 | 2) | ||
107 | p2=1 | ||
108 | ;; | ||
109 | 3) | ||
110 | p3=1 | ||
111 | ;; | ||
112 | C) | ||
113 | conf=1 | ||
114 | ;; | ||
115 | e) | ||
116 | exploitconf=1 | ||
117 | ;; | ||
118 | a) | ||
119 | recompose=1 | ||
120 | ;; | ||
121 | s) | ||
122 | scoring=1 | ||
123 | ;; | ||
79 | :) | 124 | :) |
80 | echo "Option -$OPTARG requires an argument." >&2 | 125 | echo "Option -$OPTARG requires an argument." >&2 |
81 | exit 1 | 126 | exit 1 |
82 | ;; | 127 | ;; |
83 | \?) | 128 | \?) |
84 | echo "BAD USAGE : unknow opton -$OPTARG" | 129 | echo "BAD USAGE : unknow opton -$OPTARG" |
85 | exit 1 | 130 | exit 1 |
86 | ;; | 131 | ;; |
87 | esac | 132 | esac |
88 | done | 133 | done |
89 | 134 | ||
90 | # Check USAGE by arguments number | 135 | # Check USAGE by arguments number |
91 | if [ $(($#-($OPTIND-1))) -ne 2 ] | 136 | if [ $(($#-($OPTIND-1))) -ne 2 ] |
92 | then | 137 | then |
93 | echo "BAD USAGE : $0 [OPTIONS] <WAV_FILE> <OUTPUT_DIR>" | 138 | echo "BAD USAGE : $0 [OPTIONS] <WAV_FILE> <OUTPUT_DIR>" |
94 | echo "$0 -h for more info" | 139 | echo "$0 -h for more info" |
95 | exit 1 | 140 | exit 1 |
96 | fi | 141 | fi |
97 | 142 | ||
98 | shift $((OPTIND-1)) | 143 | shift $((OPTIND-1)) |
99 | # check audio file - First argument | 144 | # check audio file - First argument |
100 | if [ -e $1 ] && [ -s $1 ] | 145 | if [ -e $1 ] && [ -s $1 ] |
101 | then | 146 | then |
102 | echo -e "$LORD\n" | 147 | echo -e "$LORD\n" |
103 | REP_OUT=$2/${1%.*} | 148 | REP_OUT=$2/${1%.*} |
104 | ${MAIN_SCRIPT_PATH}/FirstPass.sh ${RING} $1 $2 | 149 | if [ $p1 -eq 1 ];then ${MAIN_SCRIPT_PATH}/FirstPass.sh ${RING} $1 $2;fi |
105 | ${MAIN_SCRIPT_PATH}/SecondPass.sh ${RING} ${REP_OUT} | 150 | if [ $p2 -eq 1 ];then ${MAIN_SCRIPT_PATH}/SecondPass.sh ${RING} ${REP_OUT};fi |
106 | ${MAIN_SCRIPT_PATH}/ConfPass.sh ${RING} ${REP_OUT} "res_p2" | 151 | if [ $conf -eq 1 ];then $p${MAIN_SCRIPT_PATH}/ConfPass.sh ${RING} ${REP_OUT} "res_p2";fi |
107 | ${MAIN_SCRIPT_PATH}/ExploitConfidencePass.sh ${RING} ${REP_OUT} | 152 | if [ $exploitconf -eq 1 ]; then ${MAIN_SCRIPT_PATH}/ExploitConfidencePass.sh ${RING} ${REP_OUT};fi |
108 | ${MAIN_SCRIPT_PATH}/ThirdPass.sh ${RING} ${REP_OUT} | 153 | if [ $p3 -eq 1 ];then ${MAIN_SCRIPT_PATH}/ThirdPass.sh ${RING} ${REP_OUT};fi |
109 | ${MAIN_SCRIPT_PATH}/ConfPass.sh ${RING} ${REP_OUT} "res_p3" | 154 | if [ $conf -eq 1 ];then ${MAIN_SCRIPT_PATH}/ConfPass.sh ${RING} ${REP_OUT} "res_p3";fi |
110 | ${MAIN_SCRIPT_PATH}/RecomposePass.sh ${RING} ${REP_OUT} | 155 | if [ $recompose -eq 1 ];then ${MAIN_SCRIPT_PATH}/RecomposePass.sh ${RING} ${REP_OUT};fi |
111 | ${MAIN_SCRIPT_PATH}/ScoringRes.sh ${RING} ${REP_OUT} | 156 | if [ $scoring -eq 1 ];then ${MAIN_SCRIPT_PATH}/ScoringRes.sh ${RING} ${REP_OUT};fi |
157 | echo "done" | ||
112 | else | 158 | else |
113 | echo "can't find $1 OR file is empty" | 159 | echo "can't find $1 OR file is empty" |
114 | exit 1 | 160 | exit 1 |
115 | fi | 161 | fi |
116 | 162 | ||
117 | 163 | ||
118 | 164 | ||
119 | 165 |
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" >&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] <FIRST_PASS_DIRECTORY>\n" | 47 | echo -e "$0 [OPTIONS] <FIRST_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 | REDIRECTION_OUTPUT="" | 88 | REDIRECTION_OUTPUT="" |
89 | else | 89 | else |
90 | REDIRECTION_OUTPUT=" 2> /dev/null" | 90 | REDIRECTION_OUTPUT=" 2> /dev/null" |
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 | SEG_FILE_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "SEG_FILE=" | cut -f2 -d"=") | 126 | 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"=") | 127 | 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"=") | 128 | RES_DIR_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "RES_DIR=" | cut -f2 -d"=") |
129 | else | 129 | else |
130 | print_error "can't find $FIRSTPASS_CONFIG_FILE file" | 130 | print_error "can't find $FIRSTPASS_CONFIG_FILE file" |
131 | exit 1 | 131 | exit 1 |
132 | fi | 132 | fi |
133 | LST=$OUTPUT_DIR_BASENAME"/lists" | 133 | LST=$OUTPUT_DIR_BASENAME"/lists" |
134 | HMM=$OUTPUT_DIR_BASENAME"/hmm/" | 134 | HMM=$OUTPUT_DIR_BASENAME"/hmm/" |
135 | RES_DIR=$OUTPUT_DIR_BASENAME"/res_p2" | 135 | RES_DIR=$OUTPUT_DIR_BASENAME"/res_p2" |
136 | LOGFILE="$OUTPUT_DIR/info_p2.log" | 136 | LOGFILE="$OUTPUT_DIR/info_p2.log" |
137 | ERRORFILE="$OUTPUT_DIR/error_p2.log" | 137 | ERRORFILE="$OUTPUT_DIR/error_p2.log" |
138 | 138 | ||
139 | #------------------# | 139 | #------------------# |
140 | # Create WORKSPACE # | 140 | # Create WORKSPACE # |
141 | #------------------# | 141 | #------------------# |
142 | 142 | ||
143 | # Lock directory | 143 | # Lock directory |
144 | if [ -e $OUTPUT_DIR_BASENAME/SECONDPASS.lock ] && [ $RERUN -eq 0 ]; then exit 1;fi | 144 | if [ -e $OUTPUT_DIR_BASENAME/SECONDPASS.lock ] && [ $RERUN -eq 0 ]; then exit 1;fi |
145 | rm "$OUTPUT_DIR_BASENAME/SECONDPASS.unlock" > /dev/null 2>&1 | 145 | rm "$OUTPUT_DIR_BASENAME/SECONDPASS.unlock" > /dev/null 2>&1 |
146 | touch "$OUTPUT_DIR_BASENAME/SECONDPASS.lock" > /dev/null 2>&1 | 146 | touch "$OUTPUT_DIR_BASENAME/SECONDPASS.lock" > /dev/null 2>&1 |
147 | 147 | ||
148 | rm -r $LST > /dev/null 2>&1 | 148 | rm -r $LST > /dev/null 2>&1 |
149 | mkdir -p $LST | 149 | mkdir -p $LST |
150 | print_info "Make directory $LST" 1 | 150 | print_info "Make directory $LST" 1 |
151 | if [ $RERUN -eq 0 ]; then rm -r $HMM > /dev/null 2>&1; fi | 151 | if [ $RERUN -eq 0 ]; then rm -r $HMM > /dev/null 2>&1; fi |
152 | mkdir -p $HMM | 152 | mkdir -p $HMM |
153 | print_info "Make directory $HMM" 1 | 153 | print_info "Make directory $HMM" 1 |
154 | if [ $RERUN -eq 0 ]; then rm -r $RES_DIR > /dev/null 2>&1; fi | 154 | if [ $RERUN -eq 0 ]; then rm -r $RES_DIR > /dev/null 2>&1; fi |
155 | mkdir -p $RES_DIR > /dev/null 2>&1 | 155 | mkdir -p $RES_DIR > /dev/null 2>&1 |
156 | print_info "Make directory $RES_DIR" 1 | 156 | print_info "Make directory $RES_DIR" 1 |
157 | 157 | ||
158 | #-------------------# | 158 | #-------------------# |
159 | # Check Pass # | 159 | # Check Pass # |
160 | #-------------------# | 160 | #-------------------# |
161 | print_info "Check Pass 2 directory" 1 | 161 | print_info "Check Pass 2 directory" 1 |
162 | for treil in $(ls $RES_DIR/ | grep treil) | 162 | for treil in $(ls $RES_DIR/ | grep treil) |
163 | do | 163 | do |
164 | if [ ! -s $RES_DIR/$treil ] | 164 | if [ ! -s $RES_DIR/$treil ] |
165 | then | 165 | then |
166 | bn = $(basename $treil ".treil") | 166 | bn = $(basename $treil ".treil") |
167 | rm $RES_DIR/$treil $RES_DIR/$bn.seg $RES_DIR/$bn.res $RES_DIR/$bn.pho 2> /dev/null | 167 | 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 | 168 | print_info "$RES_DIR/$bn.* files deleted.." 2 |
169 | fi | 169 | fi |
170 | done | 170 | done |
171 | 171 | ||
172 | # Check if more then 89% of treil are done | 172 | # Check if more then 89% of treil are done |
173 | nbres_p1=$(ls $RES_DIR_P1/*.res | wc -l) | 173 | nbres_p1=$(ls $RES_DIR_P1/*.res 2> /dev/null | wc -l) |
174 | nbtreil_p2=$(ls $RES_DIR/*.treil | wc -l) | 174 | nbtreil_p2=$(ls $RES_DIR/*.treil 2> /dev/null | wc -l) |
175 | if [ $nbres_p1 -gt 0 ] | 175 | if [ $nbres_p1 -gt 0 ] |
176 | then | 176 | then |
177 | pourcentage=$((($nbtreil_p2*100)/$nbres_p1)) | 177 | pourcentage=$((($nbtreil_p2*100)/$nbres_p1)) |
178 | if [ $pourcentage -gt 89 ] | 178 | if [ $pourcentage -gt 89 ] |
179 | then | 179 | then |
180 | echo "Lattice already done, skipping $BASENAME" | 180 | echo "Lattice already done, skipping $BASENAME" |
181 | exit 0 | 181 | exit 0 |
182 | fi | 182 | fi |
183 | fi | 183 | fi |
184 | 184 | ||
185 | #--------------------# | 185 | #--------------------# |
186 | # Save configuration # | 186 | # Save configuration # |
187 | #--------------------# | 187 | #--------------------# |
188 | cp $SECONDPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/SecondPass.cfg | 188 | cp $SECONDPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/SecondPass.cfg |
189 | echo "WAV_FILE=$WAV_FILE" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg | 189 | echo "WAV_FILE=$WAV_FILE" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg |
190 | echo "BASENAME=$BASENAME" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg | 190 | echo "BASENAME=$BASENAME" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg |
191 | echo "FIRSTPASS_DIR=$FIRSTPASS_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg | 191 | echo "FIRSTPASS_DIR=$FIRSTPASS_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg |
192 | echo "PLP_DIR_P1=$PLP_DIR_P1" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg | 192 | echo "PLP_DIR_P1=$PLP_DIR_P1" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg |
193 | echo "OUTPUT_DIR=$OUTPUT_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg | 193 | echo "OUTPUT_DIR=$OUTPUT_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg |
194 | echo "OUTPUT_DIR_BASENAME=$OUTPUT_DIR_BASENAME" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg | 194 | echo "OUTPUT_DIR_BASENAME=$OUTPUT_DIR_BASENAME" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg |
195 | echo "LST=$LST" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg | 195 | echo "LST=$LST" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg |
196 | echo "HMM=$HMM" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg | 196 | echo "HMM=$HMM" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg |
197 | echo "RES_DIR=$RES_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg | 197 | echo "RES_DIR=$RES_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg |
198 | print_info "save config in $OUTPUT_DIR_BASENAME/SecondPass.cfg" 1 | 198 | print_info "save config in $OUTPUT_DIR_BASENAME/SecondPass.cfg" 1 |
199 | 199 | ||
200 | 200 | ||
201 | #--------------------------------------------------# | 201 | #--------------------------------------------------# |
202 | # Speaker Adaptation (AM) + Second pass (DECODING) # | 202 | # Speaker Adaptation (AM) + Second pass (DECODING) # |
203 | #--------------------------------------------------# | 203 | #--------------------------------------------------# |
204 | print_info "Launch Second Pass" 2 | 204 | print_info "Launch Second Pass" 1 |
205 | 205 | ||
206 | # for all speaker | 206 | # for all speaker |
207 | for speaker in $(cat $LBL_FILE_P1 | cut -f4 -d" " | sort | uniq) | 207 | for speaker in $(cat $LBL_FILE_P1 | cut -f4 -d" " | sort | uniq) |
208 | do | 208 | do |
209 | ## get seg file from P1 containing the speaker | 209 | ## get seg file from P1 containing the speaker |
210 | find $RES_DIR_P1 -name "*${speaker}.seg" -exec basename "{}" .seg \; | sort > $LST/$speaker.lst | 210 | 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 | 211 | print_info "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 | 212 | if [ ! -s $LST/$speaker.lst ]; then print_warn "no ${speaker} file in $RES_DIR_P1" 3; continue; fi |
213 | 213 | ||
214 | 214 | ||
215 | # for all AM | 215 | # for all AM |
216 | for (( i=0; $i<${#MTAG[@]} ; i++ )) | 216 | for (( i=0; $i<${#MTAG[@]} ; i++ )) |
217 | do | 217 | do |
218 | if [ -e $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst ]; then | 218 | if [ -e $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst ]; then |
219 | type=$(grep -e "${speaker}$" "$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst") | 219 | type=$(grep -e "${speaker}$" "$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst") |
220 | ## if is the good AM for the speaker | 220 | ## if is the good AM for the speaker |
221 | if [ -n "$type" ] | 221 | if [ -n "$type" ] |
222 | then | 222 | then |
223 | ## HMM adaptation | 223 | ## HMM adaptation |
224 | if [ $RERUN -eq 0 ] || ( [ ! -e $HMM/$speaker.hmm ] || [ -z $HMM/$speaker.hmm ] ) | 224 | if [ $RERUN -eq 0 ] || ( [ ! -e $HMM/$speaker.hmm ] || [ -z $HMM/$speaker.hmm ] ) |
225 | then | 225 | 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 | 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 |
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 | 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 |
228 | fi | 228 | fi |
229 | 229 | ||
230 | if [ $CHECK -eq 1 ] && ( [ ! -e $HMM/$speaker.hmm ] || [ -z $HMM/$speaker.hmm ] ) | 230 | if [ $CHECK -eq 1 ] && ( [ ! -e $HMM/$speaker.hmm ] || [ -z $HMM/$speaker.hmm ] ) |
231 | then | 231 | then |
232 | echo "ERROR [$(date +'%d/%m/%y %H:%M:%S')] $HMM/$speaker.hmm" >> $ERRORFILE | 232 | echo "ERROR [$(date +'%d/%m/%y %H:%M:%S')] $HMM/$speaker.hmm" >> $ERRORFILE |
233 | #exit 1 | 233 | #exit 1 |
234 | fi | 234 | fi |
235 | 235 | ||
236 | ## cp map files | 236 | ## cp map files |
237 | cp $SPEERAL_AM/${MODS[$i]}.map $HMM/$speaker.map | 237 | cp $SPEERAL_AM/${MODS[$i]}.map $HMM/$speaker.map |
238 | 238 | ||
239 | ## class clustering | 239 | ## class clustering |
240 | if [ -s $HMM/$speaker.hmm ] && ( [ $RERUN -eq 0 ] || ( [ ! -e $HMM/$speaker.cls ] || [ -z $HMM/$speaker.cls ] )) | 240 | if [ -s $HMM/$speaker.hmm ] && ( [ $RERUN -eq 0 ] || ( [ ! -e $HMM/$speaker.cls ] || [ -z $HMM/$speaker.cls ] )) |
241 | then | 241 | then |
242 | print_info "$SPEERAL_TOOLS/gclust_pdf $HMM/$speaker.hmm $HMM/$speaker.cls -i $SPEERAL_AM/${MODS[$i]}.cls" 3 | 242 | print_info "$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 | 243 | $SPEERAL_TOOLS/gclust_pdf $HMM/$speaker.hmm $HMM/$speaker.cls -i $SPEERAL_AM/${MODS[$i]}.cls $REDIRECTION_OUTPUT |
244 | fi | 244 | fi |
245 | if [ $CHECK -eq 1 ] && ( [ ! -e $HMM/$speaker.cls ] || [ -z $HMM/$speaker.cls ] ) | 245 | if [ $CHECK -eq 1 ] && ( [ ! -e $HMM/$speaker.cls ] || [ -z $HMM/$speaker.cls ] ) |
246 | then | 246 | then |
247 | echo "ERROR [$(date +'%d/%m/%y %H:%M:%S')] $HMM/$speaker.cls" >> $ERRORFILE | 247 | echo "ERROR [$(date +'%d/%m/%y %H:%M:%S')] $HMM/$speaker.cls" >> $ERRORFILE |
248 | #exit 1 | 248 | #exit 1 |
249 | fi | 249 | fi |
250 | 250 | ||
251 | ## Speeral decoding | 251 | ## Speeral decoding |
252 | if [ -s $HMM/$speaker.hmm ] && [ -s $HMM/$speaker.cls ] | 252 | if [ -s $HMM/$speaker.hmm ] && [ -s $HMM/$speaker.cls ] |
253 | then | 253 | 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 | 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 |
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 | 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 |
256 | else | 256 | else |
257 | print_warn "$HMM/$speaker.hmm and $speaker.cls empty, do default decoding..." 2 | 257 | print_warn "$HMM/$speaker.hmm and $speaker.cls empty, do default decoding..." 2 |
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 | 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 |
259 | fi | 259 | fi |
260 | 260 | ||
261 | if [ $CHECK -eq 1 ] | 261 | if [ $CHECK -eq 1 ] |
262 | then | 262 | then |
263 | check_second_pass_output_speeral "$LST/$speaker.lst" "$RES_DIR" | 263 | check_second_pass_output_speeral "$LST/$speaker.lst" "$RES_DIR" |
264 | if [ $? -eq 1 ] | 264 | if [ $? -eq 1 ] |
265 | then | 265 | then |
266 | echo -e "ERROR : Speeral $LST/$speaker.lst\n[" >> $ERRORFILE | 266 | echo -e "ERROR : Speeral $LST/$speaker.lst\n[" >> $ERRORFILE |
267 | ls $RES_DIR/*.seg | grep -e "$speaker" | sed -e "s|$RES_DIR\/||" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp | 267 | 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 | 268 | diff $LST/$speaker.lst ${OUTPUT_DIR_BASENAME}/.tmp >> $ERRORFILE |
269 | echo -e "] " >> $ERRORFILE | 269 | echo -e "] " >> $ERRORFILE |
270 | rm ${OUTPUT_DIR_BASENAME}/.tmp | 270 | rm ${OUTPUT_DIR_BASENAME}/.tmp |
271 | #exit 1 | 271 | #exit 1 |
272 | fi | 272 | fi |
273 | fi | 273 | fi |
274 | break | 274 | break |
275 | fi | 275 | fi |
276 | fi | 276 | fi |
277 | done | 277 | done |
278 | #rm "$HMM/$speaker.*" > /dev/null 2>&1 | 278 | #rm "$HMM/$speaker.*" > /dev/null 2>&1 |
279 | #rm "$LST/$speaker.lst" > /dev/null 2>&1 | 279 | #rm "$LST/$speaker.lst" > /dev/null 2>&1 |
280 | done | 280 | done |
281 | 281 | ||
282 | print_info "<= End $BASENAME P2 | $(date +'%d/%m/%y %H:%M:%S')" 1 | 282 | print_info "<= End $BASENAME P2 | $(date +'%d/%m/%y %H:%M:%S')" 1 |
283 | 283 | ||
284 | ## Check missing seg and log it | 284 | ## 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 | 285 | ls $RES_DIR/*.treil | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.treil//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp |
286 | echo -e "$BASENAME P2 END\n[" >> $LOGFILE | 286 | echo -e "$BASENAME P2 END\n[" >> $LOGFILE |
287 | diff ${OUTPUT_DIR_BASENAME}/plp.lst ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> $LOGFILE | 287 | diff ${OUTPUT_DIR_BASENAME}/plp.lst ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> $LOGFILE |
288 | echo -e "] $BASENAME" >> $LOGFILE | 288 | echo -e "] $BASENAME" >> $LOGFILE |
289 | rm ${OUTPUT_DIR_BASENAME}/.tmp > /dev/null 2>&1 | 289 | rm ${OUTPUT_DIR_BASENAME}/.tmp > /dev/null 2>&1 |
290 | 290 | ||
291 | #---------------# | 291 | #---------------# |
292 | # Convert res # | 292 | # Convert res # |
293 | #---------------# | 293 | #---------------# |
294 | 294 | ||
295 | # .res => .ctm | 295 | # .res => .ctm |
296 | $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.2pass.ctm $REDIRECTION_OUTPUT | 296 | $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.2pass.ctm $REDIRECTION_OUTPUT |
297 | # .res => .trs | 297 | # .res => .trs |
298 | echo -e "name $AUTHOR\nfileName ${BASENAME}\nfileExt wav\nsegFile ${OUTPUT_DIR_BASENAME}/${BASENAME}.seg" > ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg | 298 | 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 | 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 |
300 | rm ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg > /dev/null 2>&1 | 300 | rm ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg > /dev/null 2>&1 |
301 | # .res => .txt | 301 | # .res => .txt |
302 | $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.2pass.txt $REDIRECTION_OUTPUT | 302 | $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.2pass.txt $REDIRECTION_OUTPUT |
303 | 303 | ||
304 | 304 | ||
305 | # unlock directory | 305 | # unlock directory |
306 | mv "$OUTPUT_DIR_BASENAME/SECONDPASS.lock" "$OUTPUT_DIR_BASENAME/SECONDPASS.unlock" | 306 | mv "$OUTPUT_DIR_BASENAME/SECONDPASS.lock" "$OUTPUT_DIR_BASENAME/SECONDPASS.unlock" |
307 | 307 | ||
308 | 308 |
tools/scripts/Tools.sh
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | ################################################# | 3 | ################################################# |
4 | # File : Tools.sh # | 4 | # File : Tools.sh # |
5 | # Brief : Tool functions # | 5 | # Brief : Tool functions # |
6 | # Author : Jean-François Rey # | 6 | # Author : Jean-François Rey # |
7 | # Version : 1.0 # | 7 | # Version : 1.0 # |
8 | # Date : 13/06/13 # | 8 | # Date : 13/06/13 # |
9 | ################################################# | 9 | ################################################# |
10 | 10 | ||
11 | # Type | 11 | # Type |
12 | ERROR=2 | 12 | ERROR=2 |
13 | WARN=1 | 13 | WARN=1 |
14 | INFO=0 | 14 | INFO=0 |
15 | 15 | ||
16 | # Global Verbose variable (have to be define in scripts) | 16 | # Global Verbose variable (have to be define in scripts) |
17 | # 0 : mute | 17 | # 0 : mute |
18 | # 1 : basic info (start,config,end) | 18 | # 1 : basic info (start,config,end) |
19 | # 2 : add process | 19 | # 2 : add process |
20 | # 3 : all | 20 | # 3 : all |
21 | VERBOSE=0 | 21 | VERBOSE=0 |
22 | 22 | ||
23 | # print_message( verbose_level, message) | 23 | # print_message( verbose_level, message) |
24 | # - message_type : ERROR, WARN, INFO | 24 | # - message_type : ERROR, WARN, INFO |
25 | # - verbose_level : level to print message | 25 | # - verbose_level : level to print message |
26 | # - message : the message to print | 26 | # - message : the message to print |
27 | function print_message() | 27 | function print_message() |
28 | { | 28 | { |
29 | if [ $# -eq 3 ] | 29 | if [ $# -eq 3 ] |
30 | then | 30 | then |
31 | # print error | 31 | # print error |
32 | if [ $1 -eq $ERROR ]; then echo -ne "###ERROR : $3\n" > 2; fi | 32 | if [ $1 -eq $ERROR ]; then echo -ne "###ERROR : $3\n" > /dev/stderr; exit 0; fi |
33 | # check verbose level | 33 | # check verbose level |
34 | if [ $2 -le $VERBOSE ] | 34 | if [ $2 -le $VERBOSE ] |
35 | then | 35 | then |
36 | for (( dec=1 ; $dec<$2 ; dec++ )); do echo -ne "\t"; done | 36 | for (( dec=1 ; $dec<$2 ; dec++ )); do echo -ne "\t"; done |
37 | # print warn | 37 | # print warn |
38 | if [ $1 = $WARN ]; then echo -ne "##WARNING : $3\n"; fi | 38 | if [ $1 = $WARN ]; then echo -ne "##WARNING : $3\n"; exit 0; fi |
39 | # default info | 39 | # default info |
40 | echo -ne "#INFO : $3\n" | 40 | echo -ne "#INFO : $3\n" |
41 | fi | 41 | fi |
42 | fi | 42 | fi |
43 | } | 43 | } |
44 | 44 | ||
45 | # print_error(message) | 45 | # print_error(message) |
46 | # - message : error message to print | 46 | # - message : error message to print |
47 | function print_error() | 47 | function print_error() |
48 | { | 48 | { |
49 | print_message $ERROR 3 "$1" | 49 | print_message $ERROR 3 "$1" |
50 | } | 50 | } |
51 | 51 | ||
52 | # print_warn(message,[level]) | 52 | # print_warn(message,[level]) |
53 | # - message : message to print | 53 | # - message : message to print |
54 | # - level : optional option - verbose level to print | 54 | # - level : optional option - verbose level to print |
55 | function print_warn() | 55 | function print_warn() |
56 | { | 56 | { |
57 | if [ $# -eq 2 ] | 57 | if [ $# -eq 2 ] |
58 | then | 58 | then |
59 | print_message $WARN $2 "$1" | 59 | print_message $WARN $2 "$1" |
60 | else | 60 | else |
61 | print_message $WARN $VERBOSE "$1" | 61 | print_message $WARN $VERBOSE "$1" |
62 | fi | 62 | fi |
63 | } | 63 | } |
64 | 64 | ||
65 | # print_info(message,[level]) | 65 | # print_info(message,[level]) |
66 | # - message : message to print | 66 | # - message : message to print |
67 | # - level : optional option - verbose level to print | 67 | # - level : optional option - verbose level to print |
68 | function print_info() | 68 | function print_info() |
69 | { | 69 | { |
70 | if [ $# -eq 2 ] | 70 | if [ $# -eq 2 ] |
71 | then | 71 | then |
72 | print_message $INFO $2 "$1" | 72 | print_message $INFO $2 "$1" |
73 | else | 73 | else |
74 | print_message $INFO $VERBOSE "$1" | 74 | print_message $INFO $VERBOSE "$1" |
75 | fi | ||
76 | } | ||
77 | |||
78 | # print_log_file(filename,message) | ||
79 | # - filename : full path to log file | ||
80 | # - message : message to log | ||
81 | print_log_file() | ||
82 | { | ||
83 | if [ $# -eq 2 ] | ||
84 | then | ||
85 | echo -e "$message" >> $filename | ||
75 | fi | 86 | fi |
76 | } | 87 | } |
77 | 88 |