Commit b9a54507e83742a03321b352e5cb12deaae84876

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

update bugfix + readme

Showing 6 changed files with 76 additions and 11 deletions Inline Diff

1 ___ _____ __ __ _____ ____ ___ _ _ ___ _ 1 ___ _____ __ __ _____ ____ ___ _ _ ___ _
2 / _ \_ _| \/ | ____| _ \_ _| / \ | | |_ _| / \ 2 / _ \_ _| \/ | ____| _ \_ _| / \ | | |_ _| / \
3 | | | || | | |\/| | _| | | | | | / _ \ | | | | / _ \ 3 | | | || | | |\/| | _| | | | | | / _ \ | | | | / _ \
4 | |_| || | | | | | |___| |_| | | / ___ \ | |___ | | / ___ \ 4 | |_| || | | | | | |___| |_| | | / ___ \ | |___ | | / ___ \
5 \___/ |_| |_| |_|_____|____/___/_/ \_\ |_____|___/_/ \_\ 5 \___/ |_| |_| |_|_____|____/___/_/ \_\ |_____|___/_/ \_\
6 6
7 7
8 #-------------------# 8 #-------------------#
9 # OTMEDIA LIA # 9 # OTMEDIA LIA #
10 # README # 10 # README #
11 # version 1.0 # 11 # version 1.0 #
12 #-------------------# 12 #-------------------#
13 13
14 DESCRIPTION 14 DESCRIPTION
15 ----------- 15 -----------
16 16
17 OTMEDIA means "Observatoire Transmedia", its main objective is to study the evolution and transformation of the media world. 17 OTMEDIA means "Observatoire Transmedia", its main objective is to study the evolution and transformation of the media world.
18 The scientific objective of the project is the creation of a new generation of media observatory 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 19 based on an interactive automatic analysis system (semi-automatic) transmedia to understand
20 the world of information and developments. 20 the world of information and developments.
21 21
22 Web Site : http://www.otmedia.fr 22 Web Site : http://www.otmedia.fr
23 23
24 OTMEDIA LIA project is a set of tools to transcribe radio and TV shows. 24 OTMEDIA LIA project is a set of tools to transcribe radio and TV shows.
25 25
26 DEPENDENCIES 26 DEPENDENCIES
27 ------------ 27 ------------
28
29 28
29 GNU Toolchain
30 Available from : http://www.gnu.org
31 and debian packages
30 32
33 Compiling, linking, and building applications.
34
35
36 avconv (libav-tools >= 0.8)
37 Available from : http://libav.org
38 and debian package
39
40 avconv is a very fast video and audio converter.
41
42 JAVA JDK and JRE ( >= 6)
43 Available from : http://www.oralce.com
44 and debian packages
45
46 JAVA Developpment kit and JAVA runtime environment.
47
48 Python ( >= 2.7.0)
49 Available from : http://http://www.python.org/
50 and debian packages
51
52 Python is a programming language.
53
54 Perl ( >= 5.0.0)
55 Available from : http://www.perl.org/
56 and debian packages
57
58 Perl is a programming language.
59
60 iconvi ( >= 2.0.0)
61 Available from : http://www.gnu.org
62 and debian package
63
64 Character set conversion.
65
66 csh shell (csh)
67 Available on debian packages.
68
69 The C shell was originally written at UCB to overcome limitations in the
70 Bourne shell. Its flexibility and comfort (at that time) quickly made it
71 the shell of choice until more advanced shells like ksh, bash, zsh or
72 tcsh appeared. Most of the latter incorporate features original to csh
73
74 The SRI Language Modeling Toolkit (SRILM >= 1.6.0)
75 Available from : http://www.speech.sri.com/projects/srilm/
76
77 SRILM is a toolkit for building and applying statistical language models.
78
79 Tomcat ( >= 7.0.0)
80 Available from : http://tomcat.apache.org/
81 and debian packages
82
83 Apache Tomcat is an open source software implementation of the Java Servlet and JavaServer Pages technologies.
84
31 INSTALLATION 85 INSTALLATION
32 ------------ 86 ------------
33 87
34 See the INSTALL file for the installation procedure. 88 See the INSTALL file for the installation procedure.
35 89
36 Quick install below. 90 Quick install below.
37 91
38 Before launch installation : 92 Before launch installation :
39 93
40 Be certain that all dependencies are satisfied. 94 Be certain that all dependencies are satisfied.
41 95
42 Issue the following commands to the shell : 96 Issue the following commands to the shell :
43 $> ./install.sh 97 $> ./install.sh
44 $> export OTMEDIA_HOME=path/to/OTMEDIA/directory 98 $> export OTMEDIA_HOME=path/to/OTMEDIA/directory
45 99
100 Read SOLR.INSTALL part 3/ to install SOLRDB.
46 101
102 RUNNING
103 -------
104
105 See HOWTO file.
106
47 ACKNOWLEDGEMENTS 107 ACKNOWLEDGEMENTS
48 ---------------- 108 ----------------
49 Many thanks to Jean-François Rey for useful help.
50 109
110 Many thanks to Jean-François Rey for useful help and work done.
111
51 KNOWN BUGS 112 KNOWN BUGS
52 ---------- 113 ----------
114
53 Many. 115 Many.
54 116
55 COPYRIGHT 117 COPYRIGHT
56 --------- 118 ---------
119
57 See the COPYING file. 120 See the COPYING file.
58 121
59 AUTHORS 122 AUTHORS
60 ------- 123 -------
124
61 Jean-François Rey <jean-francois.rey@univ-avignon.fr> 125 Jean-François Rey <jean-francois.rey@univ-avignon.fr>
62 Hugo Mauchrétien <hugo.mauchretien@univ-avignon.fr> 126 Hugo Mauchrétien <hugo.mauchretien@univ-avignon.fr>
63 Emmanuel Ferreira <emmanuel.ferreira@univ-avignon.fr> 127 Emmanuel Ferreira <emmanuel.ferreira@univ-avignon.fr>
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 PLP_LIST="$OUTPUT_DIR_BASENAME/plp.lst" # list of plp files
138 SEG_FILE="$OUTPUT_DIR_BASENAME/$BASENAME.seg" # Global Seg file 138 SEG_FILE="$OUTPUT_DIR_BASENAME/$BASENAME.seg" # Global Seg file
139 LBL_FILE="$OUTPUT_DIR_BASENAME/$BASENAME.lbl" # Global LBL file 139 LBL_FILE="$OUTPUT_DIR_BASENAME/$BASENAME.lbl" # Global LBL file
140 RES_DIR=$OUTPUT_DIR_BASENAME"/res_p1" 140 RES_DIR=$OUTPUT_DIR_BASENAME"/res_p1"
141 LOGFILE="$OUTPUT_DIR_BASENAME/info_p1.log" 141 LOGFILE="$OUTPUT_DIR_BASENAME/info_p1.log"
142 ERRORFILE="$OUTPUT_DIR_BASENAME/error_p1.log" 142 ERRORFILE="$OUTPUT_DIR_BASENAME/error_p1.log"
143 143
144 #------------------# 144 #------------------#
145 # Create WORKSPACE # 145 # Create WORKSPACE #
146 #------------------# 146 #------------------#
147 if [ ! -e $OUTPUT_DIR_BASENAME ] 147 if [ ! -e $OUTPUT_DIR_BASENAME ]
148 then 148 then
149 mkdir -p $OUTPUT_DIR_BASENAME 149 mkdir -p $OUTPUT_DIR_BASENAME
150 print_info "[${BASENAME}] Make directory $OUTPUT_DIR_BASENAME" 2 150 print_info "[${BASENAME}] Make directory $OUTPUT_DIR_BASENAME" 2
151 fi 151 fi
152 152
153 # Lock directory 153 # Lock directory
154 if [ -e $OUTPUT_DIR_BASENAME/FIRSTPASS.lock ] && [ $RERUN -eq 0 ]; then exit 1; fi 154 if [ -e $OUTPUT_DIR_BASENAME/FIRSTPASS.lock ] && [ $RERUN -eq 0 ]; then exit 1; fi
155 rm "$OUTPUT_DIR_BASENAME/FIRSTPASS.unlock" > /dev/null 2>&1 155 rm "$OUTPUT_DIR_BASENAME/FIRSTPASS.unlock" > /dev/null 2>&1
156 touch "$OUTPUT_DIR_BASENAME/FIRSTPASS.lock" > /dev/null 2>&1 156 touch "$OUTPUT_DIR_BASENAME/FIRSTPASS.lock" > /dev/null 2>&1
157 157
158 rm -r $PLP_DIR > /dev/null 2>&1; 158 rm -r $PLP_DIR > /dev/null 2>&1;
159 mkdir -p $PLP_DIR 159 mkdir -p $PLP_DIR
160 print_info "[${BASENAME}] Make directory $PLP_DIR" 2 160 print_info "[${BASENAME}] Make directory $PLP_DIR" 2
161 if [ $RERUN -eq 0 ]; 161 if [ $RERUN -eq 0 ];
162 then 162 then
163 rm -r $RES_DIR > /dev/null 2>&1; 163 rm -r $RES_DIR > /dev/null 2>&1;
164 else 164 else
165 rm $RES_DIR/*.lock > /dev/null 2>&1 165 rm $RES_DIR/*.lock > /dev/null 2>&1
166 fi 166 fi
167 mkdir -p $RES_DIR > /dev/null 2>&1 167 mkdir -p $RES_DIR > /dev/null 2>&1
168 print_info "[${BASENAME}] Make directory $RES_DIR" 2 168 print_info "[${BASENAME}] Make directory $RES_DIR" 2
169 rm $LOGFILE $ERRORFILE > /dev/null 2>&1 169 rm $LOGFILE $ERRORFILE > /dev/null 2>&1
170 170
171 #--------------------# 171 #--------------------#
172 # Save configuration # 172 # Save configuration #
173 #--------------------# 173 #--------------------#
174 cp $FIRSTPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/FirstPass.cfg 174 cp $FIRSTPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/FirstPass.cfg
175 echo "FIRSTPASS_SCRIPT_PATH=$MAIN_SCRIPT_PATH" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 175 echo "FIRSTPASS_SCRIPT_PATH=$MAIN_SCRIPT_PATH" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
176 echo "WAV_FILE=$WAV_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 176 echo "WAV_FILE=$WAV_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
177 echo "BASENAME=$BASENAME" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 177 echo "BASENAME=$BASENAME" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
178 echo "OUTPUT_DIR=$OUTPUT_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 178 echo "OUTPUT_DIR=$OUTPUT_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
179 echo "OUTPUT_DIR_BASENAME=$OUTPUT_DIR_BASENAME" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 179 echo "OUTPUT_DIR_BASENAME=$OUTPUT_DIR_BASENAME" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
180 echo "PLP_FILE=$PLP_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 180 echo "PLP_FILE=$PLP_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
181 echo "PLP_DIR=$PLP_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 181 echo "PLP_DIR=$PLP_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
182 echo "PLP_LIST=$PLP_LIST" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 182 echo "PLP_LIST=$PLP_LIST" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
183 echo "SEG_FILE=$SEG_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 183 echo "SEG_FILE=$SEG_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
184 echo "LBL_FILE=$LBL_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 184 echo "LBL_FILE=$LBL_FILE" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
185 echo "RES_DIR=$RES_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg 185 echo "RES_DIR=$RES_DIR" >> $OUTPUT_DIR_BASENAME/FirstPass.cfg
186 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
187 187
188 #-------------------------# 188 #-------------------------#
189 # Check Audio File Format # 189 # Check Audio File Format #
190 #-------------------------# 190 #-------------------------#
191 error=0 191 error=0
192 temp=$(avconv -i $WAV_FILE 2>&1 | grep "16000 Hz") 192 temp=$(avconv -i $WAV_FILE 2>&1 | grep "16000 Hz")
193 if [ -z "$temp" ]; then error=1; fi 193 if [ -z "$temp" ]; then error=1; fi
194 temp=$(avconv -i $WAV_FILE 2>&1 | grep "1 channels") 194 temp=$(avconv -i $WAV_FILE 2>&1 | grep "1 channels")
195 if [ -z "$temp" ]; then error=1; fi 195 if [ -z "$temp" ]; then error=1; fi
196 temp=$(avconv -i $WAV_FILE 2>&1 | grep "s16") 196 temp=$(avconv -i $WAV_FILE 2>&1 | grep "s16")
197 if [ -z "$temp" ]; then error=1; fi 197 if [ -z "$temp" ]; then error=1; fi
198 198
199 if [ $error -eq 1 ] 199 if [ $error -eq 1 ]
200 then 200 then
201 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"
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" 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"
203 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
204 WAV_FILE=$OUTPUT_DIR_BASENAME/$BASENAME.wav 204 WAV_FILE=$OUTPUT_DIR_BASENAME/$BASENAME.wav
205 FILENAME=$BASENAME.wav 205 FILENAME=$BASENAME.wav
206 print_message $INFO 1 "[${BASENAME}] new wav file : $WAV_FILE" 206 print_message $INFO 1 "[${BASENAME}] new wav file : $WAV_FILE"
207 fi 207 fi
208 208
209 #---------------# 209 #---------------#
210 # Get SRT file # 210 # Get SRT file #
211 #---------------# 211 #---------------#
212 if [ -s $(dirname $WAV_FILE)/$BASENAME.SRT ] 212 if [ -s $(dirname $WAV_FILE)/$BASENAME.SRT ]
213 then 213 then
214 cp $(dirname $WAV_FILE)/$BASENAME.SRT $OUTPUT_DIR_BASENAME/$BASENAME.SRT 214 cp $(dirname $WAV_FILE)/$BASENAME.SRT $OUTPUT_DIR_BASENAME/$BASENAME.SRT
215 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
216 fi 216 fi
217 217
218 #------------# 218 #------------#
219 # WAV -> PLP # 219 # WAV -> PLP #
220 #------------# 220 #------------#
221 print_info "[${BASENAME}] convert WAV -> PLP" 1 221 print_info "[${BASENAME}] convert WAV -> PLP" 1
222 echo $FILENAME > $OUTPUT_DIR_BASENAME/list.tmp 222 echo $FILENAME > $OUTPUT_DIR_BASENAME/list.tmp
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 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
224 224
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 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
226 226
227 if [ $CHECK -eq 1 ] 227 if [ $CHECK -eq 1 ]
228 then 228 then
229 check_first_pass_plp "$PLP_FILE" 229 check_first_pass_plp "$PLP_FILE"
230 if [ $? -eq 1 ] 230 if [ $? -eq 1 ]
231 then 231 then
232 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"
233 print_error "[${BASENAME}] -> exit, Check $ERRORFILE file" 233 print_error "[${BASENAME}] -> exit, Check $ERRORFILE file"
234 exit 1 234 exit 1
235 fi 235 fi
236 fi 236 fi
237 237
238 rm $OUTPUT_DIR_BASENAME/list.tmp 2> /dev/null 238 rm $OUTPUT_DIR_BASENAME/list.tmp 2> /dev/null
239 239
240 #------------------------------# 240 #------------------------------#
241 # S/NS + SPEAKERS SEGMENTATION # 241 # S/NS + SPEAKERS SEGMENTATION #
242 #------------------------------# 242 #------------------------------#
243 print_info "[${BASENAME}] Launch speakers diarization" 1 243 print_info "[${BASENAME}] Launch speakers diarization" 1
244 # Calcul seg file 244 # Calcul seg file
245 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
246 #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
247 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
248 248
249 if [ $CHECK -eq 1 ] && ( [ ! -e $SEG_FILE ] || [ -z $SEG_FILE ] ) 249 if [ $CHECK -eq 1 ] && ( [ ! -e $SEG_FILE ] || [ -z $SEG_FILE ] )
250 then 250 then
251 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"
252 print_error "[${BASENAME}] Check $ERRORFILE file" 252 print_error "[${BASENAME}] Check $ERRORFILE file"
253 exit 1 253 exit 1
254 fi 254 fi
255 255
256 256
257 # Create LBL file 257 # Create LBL file
258 print_info "Extract LBL file from SEG file" 1 258 print_info "Extract LBL file from SEG file" 1
259 259
260 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
261 261
262 if [ $CHECK -eq 1 ] && ( [ ! -e $LBL_FILE ] || [ -z $LBL_FILE ] ) 262 if [ $CHECK -eq 1 ] && ( [ ! -e $LBL_FILE ] || [ -z $LBL_FILE ] )
263 then 263 then
264 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"
265 print_error "[${BASENAME}] Check $ERRORFILE file" 265 print_error "[${BASENAME}] Check $ERRORFILE file"
266 exit 1 266 exit 1
267 fi 267 fi
268 268
269 269
270 #----------------------------------------------------# 270 #----------------------------------------------------#
271 # Cut global PLP file depending to LBL segmentations # 271 # Cut global PLP file depending to LBL segmentations #
272 #----------------------------------------------------# 272 #----------------------------------------------------#
273 print_info "[${BASENAME}] Cut PLP file depending to LBL segmentations" 1 273 print_info "[${BASENAME}] Cut PLP file depending to LBL segmentations" 1
274 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
275 275
276 $SPEERAL_TOOLS/gcep $PLP_FILE $LBL_FILE 500 $PLP_DIR -FSEG 276 $SPEERAL_TOOLS/gcep $PLP_FILE $LBL_FILE 500 $PLP_DIR -FSEG
277 277
278 if [ $CHECK -eq 1 ] 278 if [ $CHECK -eq 1 ]
279 then 279 then
280 check_first_pass_plps_lbl $PLP_DIR $LBL_FILE 280 check_first_pass_plps_lbl $PLP_DIR $LBL_FILE
281 if [ $? -eq 1 ] 281 if [ $? -eq 1 ]
282 then 282 then
283 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"
284 print_error "[${BASENAME}] Check $ERRORFILE file" 284 print_error "[${BASENAME}] Check $ERRORFILE file"
285 exit 1 285 exit 1
286 fi 286 fi
287 fi 287 fi
288 288
289 # change plp files names 289 # change plp files names
290 cd $PLP_DIR; 290 cd $PLP_DIR;
291 rename -f s/_/#/g *plp 291 rename -f s/_/#/g *plp
292 rename -f s/#/_/ *plp 292 rename -f s/#/_/ *plp
293 cd $OLDPWD 293 cd $OLDPWD
294 294
295 #---------------------------------------------# 295 #---------------------------------------------#
296 # PLP files list depending to acoustic models # 296 # PLP files list depending to acoustic models #
297 #---------------------------------------------# 297 #---------------------------------------------#
298 print_info "[${BASENAME}] Create PLP list depending of the model" 1 298 print_info "[${BASENAME}] Create PLP list depending of the model" 1
299 # Create a list of plp files 299 # Create a list of plp files
300 find $PLP_DIR -type f -exec basename "{}" .plp \; | sort > $PLP_LIST 300 find $PLP_DIR -type f -exec basename "{}" .plp \; | sort > $PLP_LIST
301 301
302 rm $OUTPUT_DIR_BASENAME/plp_*.lst > /dev/null 2>&1 302 rm $OUTPUT_DIR_BASENAME/plp_*.lst > /dev/null 2>&1
303 for (( i=0; $i<${#MTAG[@]} ; i++ )) 303 for (( i=0; $i<${#MTAG[@]} ; i++ ))
304 do 304 do
305 a=`grep -e "${MTAG[$i]}" $OUTPUT_DIR_BASENAME/plp.lst` 305 a=`grep -e "${MTAG[$i]}" $OUTPUT_DIR_BASENAME/plp.lst`
306 if [ -n "$a" ]; then 306 if [ -n "$a" ]; then
307 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
308 grep -e "${MTAG[$i]}" $PLP_LIST | sort > $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst 308 grep -e "${MTAG[$i]}" $PLP_LIST | sort > $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst
309 fi 309 fi
310 done 310 done
311 311
312 #-----------------------# 312 #-----------------------#
313 # First Pass (DECODING) # 313 # First Pass (DECODING) #
314 #-----------------------# 314 #-----------------------#
315 # 315 #
316 # For all AM do decoding 316 # For all AM do decoding
317 # if Check error -> iter on undone decoding (max 1 times) 317 # if Check error -> iter on undone decoding (max 1 times)
318 # 318 #
319 print_info "[${BASENAME}] Launch decoding" 1 319 print_info "[${BASENAME}] Launch decoding" 1
320 for (( i=0; $i<${#MTAG[@]} ; i++ )) 320 for (( i=0; $i<${#MTAG[@]} ; i++ ))
321 do 321 do
322 redo=1; # nb of try if not all segs is decoded 322 redo=1; # nb of try if not all segs is decoded
323 if [ -e $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst ] 323 if [ -e $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst ]
324 then 324 then
325 todo=$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst 325 todo=$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst
326 while [ $redo -gt 0 ]; do 326 while [ $redo -gt 0 ]; do
327 rm $RES_DIR/*.lock > /dev/null 2>&1 327 rm $RES_DIR/*.lock > /dev/null 2>&1
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 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
329 # Run speeral 329 # Run speeral
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 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
331 331
332 # Check if error 332 # Check if error
333 if [ $CHECK -eq 1 ] 333 if [ $CHECK -eq 1 ]
334 then 334 then
335 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"
336 # if error 336 # if error
337 if [ $? -eq 1 ] 337 if [ $? -eq 1 ]
338 then 338 then
339 # rerun 339 # rerun
340 redo=$(($redo - 1)); 340 redo=$(($redo - 1));
341 print_warn "[${BASENAME}] Speeral output error : check $LOGFILE" 2 341 print_warn "[${BASENAME}] Speeral output error : check $LOGFILE" 2
342 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"
343 # new plp list 343 # new plp list
344 # list .seg done and compare to list of seg to do 344 # list .seg done and compare to list of seg to do
345 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
346 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
347 rm ${OUTPUT_DIR_BASENAME}/.tmp 347 rm ${OUTPUT_DIR_BASENAME}/.tmp
348 # log seg to do 348 # log seg to do
349 print_log_file $LOGFILE "Segs not done :" 349 print_log_file $LOGFILE "Segs not done ["
350 cat ${OUTPUT_DIR_BASENAME}/todo.lst >> $LOGFILE 350 cat ${OUTPUT_DIR_BASENAME}/todo.lst >> $LOGFILE
351 todo=${OUTPUT_DIR_BASENAME}/todo.lst 351 todo=${OUTPUT_DIR_BASENAME}/todo.lst
352 print_log_file $LOGFILE "] [$(date +'%d/%m/%y %H:%M:%S')]"
352 print_warn "[${BASENAME}] Try $redo" 3 353 print_warn "[${BASENAME}] Try $redo" 3
353 fi 354 fi
354 fi 355 fi
355 done 356 done
356 rm ${OUTPUT_DIR_BASENAME}/todo.lst > /dev/null 2>&1 357 rm ${OUTPUT_DIR_BASENAME}/todo.lst > /dev/null 2>&1
357 #rm $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst 358 #rm $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst
358 rm $RES_DIR/*.lock > /dev/null 2>&1 359 rm $RES_DIR/*.lock > /dev/null 2>&1
359 fi 360 fi
360 done 361 done
361 362
362 ## Check missing seg and log it 363 ## Check missing seg and log it
363 if [ "$CHECK" -eq 1 ] 364 if [ "$CHECK" -eq 1 ]
364 then 365 then
365 ls $RES_DIR/*.seg | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp 366 ls $RES_DIR/*.seg | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.seg//' | sort > ${OUTPUT_DIR_BASENAME}/.tmp
366 todo=$(cat ${PLP_LIST} 2> /dev/null | wc -l) 367 todo=$(cat ${PLP_LIST} 2> /dev/null | wc -l)
367 if [ "$todo" -eq 0 ]; then todo=1;fi 368 if [ "$todo" -eq 0 ]; then todo=1;fi
368 notdone=$(($todo - $(cat ${OUTPUT_DIR_BASENAME}/.tmp | wc -l))) 369 notdone=$(($todo - $(cat ${OUTPUT_DIR_BASENAME}/.tmp | wc -l)))
369 pourcentage=$((($notdone*100)/$todo)) 370 pourcentage=$((($notdone*100)/$todo))
370 371
371 if [ "$notdone" -ne 0 ] 372 if [ "$notdone" -ne 0 ]
372 then 373 then
373 print_error "[${BASENAME}] Check ${ERRORFILE}" 374 print_error "[${BASENAME}] Check ${ERRORFILE}"
374 print_log_file "${ERRORFILE}" "ERROR : Segs not done [" 375 print_log_file "${ERRORFILE}" "ERROR : Segs not done ["
375 diff ${PLP_LIST} ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> ${ERRORFILE} 376 diff ${PLP_LIST} ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> ${ERRORFILE}
376 print_log_file "${ERRORFILE}" "] $pourcentage% $BASENAME" 377 print_log_file "${ERRORFILE}" "] $pourcentage% $BASENAME"
377 else 378 else
378 print_log_file "$LOGFILE" "P1 OK ${BASENAME} | $(date +'%d/%m/%y %H:%M:%S')" 379 print_log_file "$LOGFILE" "P1 OK ${BASENAME} | $(date +'%d/%m/%y %H:%M:%S')"
379 fi 380 fi
380 rm ${OUTPUT_DIR_BASENAME}/.tmp 381 rm ${OUTPUT_DIR_BASENAME}/.tmp
381 fi 382 fi
382 383
383 #---------------# 384 #---------------#
384 # Convert res # 385 # Convert res #
385 #---------------# 386 #---------------#
386 print_info "[${BASENAME}] Convert .res into .ctm" 1 387 print_info "[${BASENAME}] Convert .res into .ctm" 1
387 # .res => .ctm 388 # .res => .ctm
388 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out $OUTPUT_DIR_BASENAME/$BASENAME.1pass.ctm 389 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out $OUTPUT_DIR_BASENAME/$BASENAME.1pass.ctm
389 print_info "[${BASENAME}] Convert .res into .trs" 1 390 print_info "[${BASENAME}] Convert .res into .trs" 1
390 # .res => .trs 391 # .res => .trs
391 echo -e "name $AUTHOR\nfileName $BASENAME\nfileExt wav\nsegFile $OUTPUT_DIR_BASENAME/$BASENAME.seg" > $OUTPUT_DIR_BASENAME/$BASENAME.trs_cfg 392 echo -e "name $AUTHOR\nfileName $BASENAME\nfileExt wav\nsegFile $OUTPUT_DIR_BASENAME/$BASENAME.seg" > $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 393 $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
393 rm $OUTPUT_DIR_BASENAME/$BASENAME.trs_cfg 2> /dev/null 394 rm $OUTPUT_DIR_BASENAME/$BASENAME.trs_cfg 2> /dev/null
394 print_info "[${BASENAME}] Convert .res into .txt" 1 395 print_info "[${BASENAME}] Convert .res into .txt" 1
395 # .res => .txt 396 # .res => .txt
396 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out $OUTPUT_DIR_BASENAME/$BASENAME.1pass.txt 397 $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out $OUTPUT_DIR_BASENAME/$BASENAME.1pass.txt
397 398
398 print_info "[${BASENAME}] <= P1 End | $(date +'%d/%m/%y %H:%M:%S')" 1 399 print_info "[${BASENAME}] <= P1 End | $(date +'%d/%m/%y %H:%M:%S')" 1
399 # unlock directory 400 # unlock directory
400 mv "$OUTPUT_DIR_BASENAME/FIRSTPASS.lock" "$OUTPUT_DIR_BASENAME/FIRSTPASS.unlock" 401 mv "$OUTPUT_DIR_BASENAME/FIRSTPASS.lock" "$OUTPUT_DIR_BASENAME/FIRSTPASS.unlock"
401 402
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 PLP_LIST_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "PLP_LIST=" | cut -f2 -d"=")
127 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"=")
128 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"=")
129 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"=")
130 else 130 else
131 print_error "Can't find $FIRSTPASS_CONFIG_FILE file" 131 print_error "Can't find $FIRSTPASS_CONFIG_FILE file"
132 print_error "exit" 132 print_error "exit"
133 exit 1 133 exit 1
134 fi 134 fi
135 LST=$OUTPUT_DIR_BASENAME"/lists" 135 LST=$OUTPUT_DIR_BASENAME"/lists"
136 HMM=$OUTPUT_DIR_BASENAME"/hmm/" 136 HMM=$OUTPUT_DIR_BASENAME"/hmm/"
137 RES_DIR=$OUTPUT_DIR_BASENAME"/res_p2" 137 RES_DIR=$OUTPUT_DIR_BASENAME"/res_p2"
138 LOGFILE="$OUTPUT_DIR_BASENAME/info_p2.log" 138 LOGFILE="$OUTPUT_DIR_BASENAME/info_p2.log"
139 ERRORFILE="$OUTPUT_DIR_BASENAME/error_p2.log" 139 ERRORFILE="$OUTPUT_DIR_BASENAME/error_p2.log"
140 140
141 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
142 142
143 #------------------# 143 #------------------#
144 # Create WORKSPACE # 144 # Create WORKSPACE #
145 #------------------# 145 #------------------#
146 146
147 # Lock directory 147 # Lock directory
148 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
149 rm "$OUTPUT_DIR_BASENAME/SECONDPASS.unlock" > /dev/null 2>&1 149 rm "$OUTPUT_DIR_BASENAME/SECONDPASS.unlock" > /dev/null 2>&1
150 touch "$OUTPUT_DIR_BASENAME/SECONDPASS.lock" > /dev/null 2>&1 150 touch "$OUTPUT_DIR_BASENAME/SECONDPASS.lock" > /dev/null 2>&1
151 151
152 rm -r $LST > /dev/null 2>&1 152 rm -r $LST > /dev/null 2>&1
153 mkdir -p $LST 153 mkdir -p $LST
154 print_info "[${BASENAME}] Make directory $LST" 2 154 print_info "[${BASENAME}] Make directory $LST" 2
155 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
156 mkdir -p $HMM 156 mkdir -p $HMM
157 print_info "[${BASENAME}] Make directory $HMM" 2 157 print_info "[${BASENAME}] Make directory $HMM" 2
158 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
159 mkdir -p $RES_DIR > /dev/null 2>&1 159 mkdir -p $RES_DIR > /dev/null 2>&1
160 print_info "[${BASENAME}] Make directory $RES_DIR" 2 160 print_info "[${BASENAME}] Make directory $RES_DIR" 2
161 rm $LOGFILE $ERRORFILE > /dev/null 2>&1 161 rm $LOGFILE $ERRORFILE > /dev/null 2>&1
162 162
163 #-------------------# 163 #-------------------#
164 # Check Pass # 164 # Check Pass #
165 #-------------------# 165 #-------------------#
166 print_info "[${BASENAME}] Check Pass 2 directory" 1 166 print_info "[${BASENAME}] Check Pass 2 directory" 1
167 for treil in $(ls $RES_DIR/ | grep treil) 167 for treil in $(ls $RES_DIR/ | grep treil)
168 do 168 do
169 if [ ! -s $RES_DIR/$treil ] 169 if [ ! -s $RES_DIR/$treil ]
170 then 170 then
171 bn = $(basename $treil ".treil") 171 bn = $(basename $treil ".treil")
172 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
173 print_info "[${BASENAME}] $RES_DIR/$bn.* files deleted.." 2 173 print_info "[${BASENAME}] $RES_DIR/$bn.* files deleted.." 2
174 fi 174 fi
175 done 175 done
176 176
177 # Check if more then 89% of treil are done 177 # Check if more then 89% of treil are done
178 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)
179 nbtreil_p2=$(ls $RES_DIR/*.treil 2> /dev/null | wc -l) 179 nbtreil_p2=$(ls $RES_DIR/*.treil 2> /dev/null | wc -l)
180 if [ $nbres_p1 -gt 0 ] 180 if [ $nbres_p1 -gt 0 ]
181 then 181 then
182 pourcentage=$((($nbtreil_p2*100)/$nbres_p1)) 182 pourcentage=$((($nbtreil_p2*100)/$nbres_p1))
183 if [ $pourcentage -gt 89 ] 183 if [ $pourcentage -gt 89 ] && [ ${RERUN} -eq 0 ]
184 then 184 then
185 print_info "[${BASENAME}] Lattice already done, skipping $BASENAME" 1 185 print_info "[${BASENAME}] Lattice already done, skipping $BASENAME" 1
186 exit 0 186 exit 0
187 fi 187 fi
188 else 188 else
189 print_error "[${BASENAME}] No First Pass, No .res -> exit P2" 189 print_error "[${BASENAME}] No First Pass, No .res -> exit P2"
190 if [ $CHECK -eq 1 ]; then print_log_file $ERRORFILE "No First Pass, No .res -> exit P2" ;fi 190 if [ $CHECK -eq 1 ]; then print_log_file $ERRORFILE "No First Pass, No .res -> exit P2" ;fi
191 exit 1 191 exit 1
192 fi 192 fi
193 193
194 #--------------------# 194 #--------------------#
195 # Save configuration # 195 # Save configuration #
196 #--------------------# 196 #--------------------#
197 cp $SECONDPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/SecondPass.cfg 197 cp $SECONDPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/SecondPass.cfg
198 echo "WAV_FILE=$WAV_FILE" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 198 echo "WAV_FILE=$WAV_FILE" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
199 echo "BASENAME=$BASENAME" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 199 echo "BASENAME=$BASENAME" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
200 echo "FIRSTPASS_DIR=$FIRSTPASS_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 200 echo "FIRSTPASS_DIR=$FIRSTPASS_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
201 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
202 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 203 echo "PLP_LIST_P1=$PLP_LIST_P1" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
204 echo "OUTPUT_DIR=$OUTPUT_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 204 echo "OUTPUT_DIR=$OUTPUT_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
205 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
206 echo "LST=$LST" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 206 echo "LST=$LST" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
207 echo "HMM=$HMM" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 207 echo "HMM=$HMM" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
208 echo "RES_DIR=$RES_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg 208 echo "RES_DIR=$RES_DIR" >> $OUTPUT_DIR_BASENAME/SecondPass.cfg
209 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
210 210
211 211
212 #--------------------------------------------------# 212 #--------------------------------------------------#
213 # Speaker Adaptation (AM) + Second pass (DECODING) # 213 # Speaker Adaptation (AM) + Second pass (DECODING) #
214 #--------------------------------------------------# 214 #--------------------------------------------------#
215 print_info "[${BASENAME}] Launch Second Pass" 1 215 print_info "[${BASENAME}] Launch Second Pass" 1
216 216
217 # for all speaker 217 # for all speaker
218 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)
219 do 219 do
220 ## get seg file from P1 containing the speaker 220 ## get seg file from P1 containing the speaker
221 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
222 print_info "[${BASENAME}] file for $speaker in $LST/$speaker.lst" 3 222 print_info "[${BASENAME}] file for $speaker in $LST/$speaker.lst" 3
223 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
224 224
225 225
226 # for all AM 226 # for all AM
227 for (( i=0; $i<${#MTAG[@]} ; i++ )) 227 for (( i=0; $i<${#MTAG[@]} ; i++ ))
228 do 228 do
229 if [ -e $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst ]; then 229 if [ -e $OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst ]; then
230 type=$(grep -e "${speaker}$" "$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst") 230 type=$(grep -e "${speaker}$" "$OUTPUT_DIR_BASENAME/plp_${MODS[$i]}.lst")
231 ## if is the good AM for the speaker 231 ## if is the good AM for the speaker
232 if [ -n "$type" ] 232 if [ -n "$type" ]
233 then 233 then
234 ## HMM adaptation 234 ## HMM adaptation
235 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 ] )
236 then 236 then
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 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
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 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
239 fi 239 fi
240 240
241 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 ] )
242 then 242 then
243 print_warn "[${BASENAME}] No hmm files created for $speaker" 2 243 print_warn "[${BASENAME}] No hmm files created for $speaker" 2
244 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"
245 print_error "[${BASENAME}] Check $ERRORFILE" 245 print_error "[${BASENAME}] Check $ERRORFILE"
246 #exit 1 246 #exit 1
247 fi 247 fi
248 248
249 ## cp map files 249 ## cp map files
250 cp $SPEERAL_AM/${MODS[$i]}.map $HMM/$speaker.map 250 cp $SPEERAL_AM/${MODS[$i]}.map $HMM/$speaker.map
251 251
252 ## class clustering 252 ## class clustering
253 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 ] ))
254 then 254 then
255 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
256 $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
257 fi 257 fi
258 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 ] )
259 then 259 then
260 print_warn "[${BASENAME}] No cls file created for $speaker" 2 260 print_warn "[${BASENAME}] No cls file created for $speaker" 2
261 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"
262 print_error "[${BASENAME}] Check $ERRORFILE" 262 print_error "[${BASENAME}] Check $ERRORFILE"
263 #exit 1 263 #exit 1
264 fi 264 fi
265 265
266 ## Speeral decoding 266 ## Speeral decoding
267 if [ -s $HMM/$speaker.hmm ] && [ -s $HMM/$speaker.cls ] 267 if [ -s $HMM/$speaker.hmm ] && [ -s $HMM/$speaker.cls ]
268 then 268 then
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 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
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 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
271 else 271 else
272 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
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 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
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 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
275 fi 275 fi
276 276
277 if [ $CHECK -eq 1 ] 277 if [ $CHECK -eq 1 ]
278 then 278 then
279 check_second_pass_output_speeral "$LST/$speaker.lst" "$RES_DIR" 279 check_second_pass_output_speeral "$LST/$speaker.lst" "$RES_DIR"
280 if [ $? -eq 1 ] 280 if [ $? -eq 1 ]
281 then 281 then
282 print_warn "[${BASENAME}] Speeral output error : check $LOGFILE" 2 282 print_warn "[${BASENAME}] Speeral output error : check $LOGFILE" 2
283 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"
284 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
285 print_log_file $LOGFILE "Segs (and treil) not done :\n[" 285 print_log_file $LOGFILE "Segs (and treil) not done :\n["
286 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
287 print_log_file $LOGFILE "] [$(date +'%d/%m/%y %H:%M:%S')]" 287 print_log_file $LOGFILE "] [$(date +'%d/%m/%y %H:%M:%S')]"
288 rm ${OUTPUT_DIR_BASENAME}/.tmp 288 rm ${OUTPUT_DIR_BASENAME}/.tmp
289 #exit 1 289 #exit 1
290 fi 290 fi
291 fi 291 fi
292 break 292 break
293 fi 293 fi
294 fi 294 fi
295 done 295 done
296 #rm "$HMM/$speaker.*" > /dev/null 2>&1 296 #rm "$HMM/$speaker.*" > /dev/null 2>&1
297 #rm "$LST/$speaker.lst" > /dev/null 2>&1 297 #rm "$LST/$speaker.lst" > /dev/null 2>&1
298 done 298 done
299 299
300 ## Check missing seg and log it 300 ## Check missing seg and log it
301 if [ $CHECK -eq 1 ] 301 if [ $CHECK -eq 1 ]
302 then 302 then
303 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
304 todo=$(cat ${PLP_LIST_P1} | wc -l) 304 todo=$(cat ${PLP_LIST_P1} | wc -l)
305 if [ $todo -eq 0 ]; then todo=1;fi 305 if [ $todo -eq 0 ]; then todo=1;fi
306 notdone=$(($todo - $(cat ${OUTPUT_DIR_BASENAME}/.tmp | wc -l))) 306 notdone=$(($todo - $(cat ${OUTPUT_DIR_BASENAME}/.tmp | wc -l)))
307 pourcentage=$((($notdone*100)/$todo)) 307 pourcentage=$((($notdone*100)/$todo))
308 if [ $notdone -ne 0 ] 308 if [ $notdone -ne 0 ]
309 then 309 then
310 print_error "[${BASENAME}] Check $ERRORFILE" 310 print_error "[${BASENAME}] Check $ERRORFILE"
311 print_log_file "$ERRORFILE" "ERROR : Treil not done [" 311 print_log_file "$ERRORFILE" "ERROR : Treil not done ["
312 diff ${PLP_LIST_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}
313 print_log_file "$ERRORFILE" "] $pourcentage% $BASENAME" 313 print_log_file "$ERRORFILE" "] $pourcentage% $BASENAME"
314 else 314 else
315 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')"
316 fi 316 fi
317 rm ${OUTPUT_DIR_BASENAME}/.tmp > /dev/null 2>&1 317 rm ${OUTPUT_DIR_BASENAME}/.tmp > /dev/null 2>&1
318 fi 318 fi
319 319
320 #---------------# 320 #---------------#
321 # Convert res # 321 # Convert res #
322 #---------------# 322 #---------------#
323 323
324 print_info "[${BASENAME}] Convert .res into .ctm" 1 324 print_info "[${BASENAME}] Convert .res into .ctm" 1
325 # .res => .ctm 325 # .res => .ctm
326 $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
327 print_info "[${BASENAME}] Convert .res into .trs" 1 327 print_info "[${BASENAME}] Convert .res into .trs" 1
328 # .res => .trs 328 # .res => .trs
329 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
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 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
331 rm ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg > /dev/null 2>&1 331 rm ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg > /dev/null 2>&1
332 print_info "[${BASENAME}] Convert .res into .txt" 1 332 print_info "[${BASENAME}] Convert .res into .txt" 1
333 # .res => .txt 333 # .res => .txt
334 $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
335 335
336 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
337 # unlock directory 337 # unlock directory
338 mv "$OUTPUT_DIR_BASENAME/SECONDPASS.lock" "$OUTPUT_DIR_BASENAME/SECONDPASS.unlock" 338 mv "$OUTPUT_DIR_BASENAME/SECONDPASS.lock" "$OUTPUT_DIR_BASENAME/SECONDPASS.unlock"
339 339
340 340
tools/scripts/CheckFirstPass.sh
1 #!/bin/bash 1 #!/bin/bash
2 2
3 ################################################# 3 #################################################
4 # File : CheckFirstPass.sh # 4 # File : CheckFirstPass.sh #
5 # Brief : Check First Pass # 5 # Brief : Check First Pass #
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 # configuration file 11 # configuration file
12 . "$OTMEDIA_HOME/cfg/FirstPass.cfg" 12 . "$OTMEDIA_HOME/cfg/FirstPass.cfg"
13 13
14 # check_first_pass_plp(filenamefullpath) 14 # check_first_pass_plp(filenamefullpath)
15 # - filenamefullpath : full path to plp file 15 # - filenamefullpath : full path to plp file
16 # return 0 if ok, otherwise return 1 16 # return 0 if ok, otherwise return 1
17 function check_first_pass_plp() 17 function check_first_pass_plp()
18 { 18 {
19 if [ $# -eq 1 ] 19 if [ $# -eq 1 ]
20 then 20 then
21 if [ ! -e "$1" ] || [ -z "$1" ]; then return 1; fi 21 if [ ! -e "$1" ] || [ -z "$1" ]; then return 1; fi
22 LINESNB=$($BIN_PATH/aff_mat$ARCH "$1" | wc -l) 22 LINESNB=$($BIN_PATH/aff_mat$ARCH "$1" | wc -l)
23 if [ $LINESNB -lt 350000 ] 23 if [ $LINESNB -lt 350000 ]
24 then 24 then
25 return 1 25 return 1
26 fi 26 fi
27 fi 27 fi
28 return 0 28 return 0
29 } 29 }
30 30
31 # check_first_pass_plps_lbl(plppath,lblfile) 31 # check_first_pass_plps_lbl(plppath,lblfile)
32 # - plppath : path to plp files 32 # - plppath : path to plp files
33 # - lblfile : a lblfile 33 # - lblfile : a lblfile
34 # return 0 if plp files nb == nb files contain in lbl , 1 otherwise 34 # return 0 if plp files nb == nb files contain in lbl , 1 otherwise
35 function check_first_pass_plps_lbl() 35 function check_first_pass_plps_lbl()
36 { 36 {
37 if [ $# -eq 2 ] 37 if [ $# -eq 2 ]
38 then 38 then
39 if [ ! -e "$1" ] || [ -z "$1" ]; then return 1; fi 39 if [ ! -e "$1" ] || [ -z "$1" ]; then return 1; fi
40 if [ ! -e "$2" ] || [ -z "$2" ]; then return 1; fi 40 if [ ! -e "$2" ] || [ -z "$2" ]; then return 1; fi
41 FILENBLBL=$(cat "$2" | wc -l) 41 FILENBLBL=$(cat "$2" | wc -l)
42 FILENBPLP=$(ls "$1" 2>/dev/null | wc -l) 42 FILENBPLP=$(ls "$1" 2>/dev/null | wc -l)
43 if [ $FILENBLBL -ne $FILENBPLP ]; then return 1; fi 43 if [ $FILENBLBL -ne $FILENBPLP ]; then return 1; fi
44 fi 44 fi
45 return 0 45 return 0
46 } 46 }
47 47
48 48
49 #check_first_pass_output_speeral(plplist,resdir) 49 #check_first_pass_output_speeral(plplist,resdir)
50 # - plplist : filename containing plp list 50 # - plplist : filename containing plp list
51 # - resdir : output Speeral directory 51 # - resdir : output Speeral directory
52 check_first_pass_output_speeral() 52 check_first_pass_output_speeral()
53 { 53 {
54 if [ $# -eq 2 ] 54 if [ $# -eq 2 ]
55 then 55 then
56 if [ ! -e "$1" ] || [ -z "$1" ]; then return 1; fi 56 if [ ! -e "$1" ] || [ -z "$1" ]; then return 1; fi
57 FILENBSEG=$(ls $2/*.seg 2>/dev/null | grep -f "$1" | wc -l) 57 FILENBSEG=$(ls $2/*.seg 2>/dev/null | grep -f "$1" | wc -l)
58 FILENBRES=$(ls $2/*.res 2>/dev/null | grep -f "$1" | wc -l) 58 FILENBRES=$(ls $2/*.res 2>/dev/null | grep -f "$1" | wc -l)
59 #FILENBPHO=$(ls "$2/*.pho" | grep -f "$1" | wc -l) 59 #FILENBPHO=$(ls $2/*.pho | grep -f "$1" | wc -l)
60 FILENB=$(cat "$1" | wc -l) 60 FILENB=$(cat "$1" | wc -l)
61 FILENBPHO=$FILENB 61 FILENBPHO=$FILENB
62 if [ $FILENB -ne $FILENBSEG ] || [ $FILENB -ne $FILENBRES ] || [ $FILENB -ne $FILENBPHO ] ; then return 1;fi 62 if [ $FILENB -ne $FILENBSEG ] || [ $FILENB -ne $FILENBRES ] || [ $FILENB -ne $FILENBPHO ] ; then return 1;fi
63 fi 63 fi
64 return 0 64 return 0
65 } 65 }
66 66
67 67
tools/scripts/CheckSecondPass.sh
1 #!/bin/bash 1 #!/bin/bash
2 2
3 ################################################# 3 #################################################
4 # File : CheckSecondPass.sh # 4 # File : CheckSecondPass.sh #
5 # Brief : Check Second Pass # 5 # Brief : Check Second Pass #
6 # Author : Jean-François Rey # 6 # Author : Jean-François Rey #
7 # Version : 1.0 # 7 # Version : 1.0 #
8 # Date : 17/06/13 # 8 # Date : 17/06/13 #
9 ################################################# 9 #################################################
10 10
11 # configuration file 11 # configuration file
12 . "$OTMEDIA_HOME/cfg/SecondPass.cfg" 12 . "$OTMEDIA_HOME/cfg/SecondPass.cfg"
13 13
14 14
15 #check_second_pass_output_speeral(plplist,resdir) 15 #check_second_pass_output_speeral(plplist,resdir)
16 # - plplist : filename containing plp list 16 # - plplist : filename containing plp list
17 # - resdir : output Speeral directory 17 # - resdir : output Speeral directory
18 function check_second_pass_output_speeral() 18 function check_second_pass_output_speeral()
19 { 19 {
20 if [ $# -eq 2 ] 20 if [ $# -eq 2 ]
21 then 21 then
22 if [ ! -e "$1" ] || [ -z "$1" ]; then return 1; fi 22 if [ ! -e "$1" ] || [ -z "$1" ]; then return 1; fi
23 FILENBSEG=$(ls "$2/*.seg" 2> /dev/null | grep -f "$1" | wc -l) 23 FILENBSEG=$(ls $2/*.seg 2>/dev/null | grep -f "$1" | wc -l)
24 FILENBRES=$(ls "$2/*.res" 2> /dev/null | grep -f "$1" | wc -l) 24 FILENBRES=$(ls $2/*.res 2>/dev/null | grep -f "$1" | wc -l)
25 FILENBTREIL=$(ls "$2/*.treil" 2> /dev/null | grep -f "$1" | wc -l) 25 FILENBTREIL=$(ls $2/*.treil 2>/dev/null | grep -f "$1" | wc -l)
26 FILENB=$(cat "$1" | wc -l) 26 FILENB=$(cat "$1" | wc -l)
27 if [ $FILENB -ne $FILENBSEG ] || [ $FILENB -ne $FILENBRES ] || [ $FILENB -ne $FILENBTREIL ] ; then return 1;fi 27 if [ $FILENB -ne $FILENBSEG ] || [ $FILENB -ne $FILENBRES ] || [ $FILENB -ne $FILENBTREIL ] ; then return 1;fi
28 fi 28 fi
29 return 0 29 return 0
30 } 30 }
31 31
32 32
tools/scripts/CheckThirdPass.sh
1 #!/bin/bash 1 #!/bin/bash
2 2
3 ################################################# 3 #################################################
4 # File : CheckThirdPass.sh # 4 # File : CheckThirdPass.sh #
5 # Brief : Check Second Pass # 5 # Brief : Check Second Pass #
6 # Author : Jean-François Rey # 6 # Author : Jean-François Rey #
7 # Version : 1.0 # 7 # Version : 1.0 #
8 # Date : 25/06/13 # 8 # Date : 25/06/13 #
9 ################################################# 9 #################################################
10 10
11 # configuration file 11 # configuration file
12 . "$OTMEDIA_HOME/cfg/ThirdPass.cfg" 12 . "$OTMEDIA_HOME/cfg/ThirdPass.cfg"
13 13
14 14
15 #check_third_pass_output_speeral(plplist,resdir) 15 #check_third_pass_output_speeral(plplist,resdir)
16 # - plplist : filename containing plp list 16 # - plplist : filename containing plp list
17 # - resdir : output Speeral directory 17 # - resdir : output Speeral directory
18 function check_third_pass_output_speeral() 18 function check_third_pass_output_speeral()
19 { 19 {
20 if [ $# -eq 2 ] 20 if [ $# -eq 2 ]
21 then 21 then
22 if [ ! -e "$1" ] || [ -z "$1" ]; then return 1; fi 22 if [ ! -e "$1" ] || [ -z "$1" ]; then return 1; fi
23 FILENBSEG=$(ls "$2/*.seg" 2>/dev/null | grep -f "$1" | wc -l) 23 FILENBSEG=$(ls $2/*.seg 2>/dev/null | grep -f "$1" | wc -l)
24 FILENBRES=$(ls "$2/*.res" 2>/dev/null | grep -f "$1" | wc -l) 24 FILENBRES=$(ls $2/*.res 2>/dev/null | grep -f "$1" | wc -l)
25 FILENBTREIL=$(ls "$2/*.treil" 2>/deV/null | grep -f "$1" | wc -l) 25 FILENBTREIL=$(ls $2/*.treil 2>/deV/null | grep -f "$1" | wc -l)
26 FILENB=$(cat "$1" | wc -l) 26 FILENB=$(cat "$1" | wc -l)
27 if [ $FILENB -ne $FILENBSEG ] || [ $FILENB -ne $FILENBRES ] || [ $FILENB -ne $FILENBTREIL ] ; then return 1;fi 27 if [ $FILENB -ne $FILENBSEG ] || [ $FILENB -ne $FILENBRES ] || [ $FILENB -ne $FILENBTREIL ] ; then return 1;fi
28 fi 28 fi
29 return 0 29 return 0
30 } 30 }
31 31
32 32