From 1fd315c89e313c446c6f6ecf3a4ea98ac859ac88 Mon Sep 17 00:00:00 2001 From: rey jean-Francois Date: Tue, 30 Jul 2013 16:52:08 +0200 Subject: [PATCH] add Extract audio and check results scripts --- main_tools/CheckResults.sh | 141 +++++++++++++++++++++++++++++++++++ main_tools/ConfPass.sh | 18 +++-- main_tools/ExploitConfidencePass.sh | 27 ++++--- main_tools/FirstPass.sh | 6 +- main_tools/OneScriptToRuleThemAll.sh | 2 +- main_tools/SecondPass.sh | 27 ++++--- main_tools/ThirdPass.sh | 19 +++-- tools/scripts/ExtractAudioFromTV.sh | 50 +++++++++++++ 8 files changed, 247 insertions(+), 43 deletions(-) create mode 100755 main_tools/CheckResults.sh create mode 100755 tools/scripts/ExtractAudioFromTV.sh diff --git a/main_tools/CheckResults.sh b/main_tools/CheckResults.sh new file mode 100755 index 0000000..37fb154 --- /dev/null +++ b/main_tools/CheckResults.sh @@ -0,0 +1,141 @@ +#!/bin/bash + +################################# +# File : CheckResults.sh # +# Brief : Check the results # +# Autohr : Jean-François Rey # +# Date : 30/07/2013 # +# Version : 1.0 # +################################# + + +# CheckDir( dir ) +# dir : a directory path +# Brief : Check $dir results +function CheckDir() +{ + if [ $# -eq 1 ] + then + plp=$(ls $1/PLP/*.plp 2> /dev/null | wc -l) + res_p1=$(ls $1/res_p1/*.res 2> /dev/null | wc -l) + res_p2=$(ls $1/res_p2/*.treil 2> /dev/null | wc -l) + res_p3=$(ls $1/res_p3/*.treil 2> /dev/null | wc -l) + usf_p2=$1/$(basename $1).res_p2.usf + usf_p3=$1/$(basename $1).res_p3.usf + + if [ -e $usf_p2 ] + then + casix=`grep -c -E 'confidence="0.600"' ${usf_p2}` + call=`grep -c -E 'confidence=' ${usf_p2}` + if [ $call -eq 0 ] + then + pourcentage_p2=100 + else + pourcentage_p2=$((($casix*100)/$call)) + fi + if [ $pourcentage_p2 -gt 49 ] + then + usf2="ERR" + else + usf2="OK" + fi + else + usf2="NAN" + fi + if [ -e $usf_p3 ] + then + casix=`grep -c -E 'confidence="0.600"' ${usf_p3}` + call=`grep -c -E 'confidence=' ${usf_p3}` + if [ $call -eq 0 ] + then + pourcentage_p3=100 + else + pourcentage_p3=$((($casix*100)/$call)) + fi + if [ $pourcentage_p3 -gt 49 ] + then + usf3="ERR" + else + usf3="OK" + fi + else + usf3="NAN" + fi + fi + echo -e "$(basename $1)\t$plp\t$res_p1\t$res_p2\t\t$res_p3\t\t$usf2\t$usf3" + +} + + +# Check OTMEDIA_HOME env var +if [ -z ${OTMEDIA_HOME} ] +then + OTMEDIA_HOME=$(dirname $(dirname $(readlink -e $0))) + export OTMEDIA_HOME=$OTMEDIA_HOME +fi + +# where is CheckResults.sh +MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0)) + + +RECURSIVE=0 + +#---------------# +# Parse Options # +#---------------# +while getopts ":hr" opt +do + case $opt in + h) + echo -e "$0 [OPTIONS] \n" + echo -e "\t Options:" + echo -e "\t\t-h :\tprint this message" + echo -e "\t\t-r :\trecursive mode" + exit 1 + ;; + r) + RECURSIVE=1 + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + exit 1 + ;; + \?) + echo "BAD USAGE : unknow opton -$OPTARG" + exit 1 + ;; + esac +done + +# Check USAGE by arguments number +if [ $(($#-($OPTIND-1))) -ne 1 ] +then + echo "BAD USAGE : FirstPass.sh [OPTIONS] " + echo "$0 -h for more info" + exit 1 +fi + +shift $((OPTIND-1)) +# check Directory - First argument +if [ -e $1 ] && [ -s $1 ] +then + DIR=$(readlink -e $1) +else + echo "ERROR : can't open directory $1" + exit 1 +fi + + +# Check directory results +echo -e "Directory name\t\t#plp\t#res_p1\t#treil_p2\t#treil_p3\tusf_p2\tusf_p3" +if [ $RECURSIVE -eq 0 ] +then + CheckDir "$DIR" +else + for d in `ls $DIR` + do + if [ -d "$DIR/$d" ]; then CheckDir "$DIR/$d"; fi + done +fi + + diff --git a/main_tools/ConfPass.sh b/main_tools/ConfPass.sh index 9081324..5a41468 100755 --- a/main_tools/ConfPass.sh +++ b/main_tools/ConfPass.sh @@ -82,10 +82,13 @@ if [ $DEBUG -eq 1 ] then set -x echo -e "## Mode DEBUG ON ##" + REDIRECTION_OUTPUT="" + else + REDIRECTION_OUTPUT=" 2> /dev/null" fi # mode verbose enable -if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ; fi +if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ;fi # Check USAGE by arguments number if [ $(($#-($OPTIND-1))) -ne 2 ] @@ -137,8 +140,8 @@ rm "$OUTPUT_DIR/CONFPASS.unlock" > /dev/null 2>&1 touch "$OUTPUT_DIR/CONFPASS.lock" > /dev/null 2>&1 if [ $RERUN -eq 0 ]; then rm -r $CONF_DIR > /dev/null 2>&1; fi if [ $RERUN -eq 1 ]; then rm $USF_FILE > /dev/null 2>&1; fi -mkdir -p $CONF_DIR -mkdir -p $RES_CONF_DIR +mkdir -p $CONF_DIR > /dev/null 2>&1 +mkdir -p $RES_CONF_DIR > /dev/null 2>&1 #---------------# # Check Pass # @@ -184,7 +187,8 @@ then if [ $pourcentageres -lt 85 ] then print_info "Calcul Confidence $INPUT_DIR $RES_NAME" 1 - $MAIN_SCRIPT_PATH/ConfidenceMeasure.sh $INPUT_DIR $RES_NAME + $MAIN_SCRIPT_PATH/ConfidenceMeasure.sh $INPUT_DIR $RES_NAME $REDIRECTION_OUTPUT + else print_info "skipping Confidence Calcul $INPUT_DIR/$RES_NAME" 1 fi @@ -204,11 +208,11 @@ for f in `ls ${RES_CONF_DIR}`; do $SCRIPT_PATH/formatRES.pl $RES_CONF_DIR/$f; do # create USF configuration file echo -e "name $AUTHOR\nfileName $BASENAME\nfileExt wav\nsegFile $OUTPUT_DIR/$BASENAME.seg" > $OUTPUT_DIR/$BASENAME.usf_cfg # create USF file -$SCRIPT_PATH/res2out.pl --dir $RES_CONF_DIR --format USF --ignore $RULES/asupp --out $USF_FILE.tmp --usf_config $OUTPUT_DIR/$BASENAME.usf_cfg -rm $OUTPUT_DIR/$BASENAME.usf_cfg +$SCRIPT_PATH/res2out.pl --dir $RES_CONF_DIR --format USF --ignore $RULES/asupp --out $USF_FILE.tmp --usf_config $OUTPUT_DIR/$BASENAME.usf_cfg $REDIRECTION_OUTPUT +rm $OUTPUT_DIR/$BASENAME.usf_cfg > /dev/null 2>&1 cat $USF_FILE.tmp | $SCRIPT_PATH/BdlexUC.pl $RULES/basic -f > $USF_FILE cp $USF_FILE ${OUTPUT_DIR}/${BASENAME}.usf -rm $USF_FILE.tmp +rm $USF_FILE.tmp > /dev/null 2>&1 #----------------# # Check USF file # diff --git a/main_tools/ExploitConfidencePass.sh b/main_tools/ExploitConfidencePass.sh index 01b5410..a081586 100755 --- a/main_tools/ExploitConfidencePass.sh +++ b/main_tools/ExploitConfidencePass.sh @@ -90,10 +90,13 @@ if [ $DEBUG -eq 1 ] then set -x echo -e "## Mode DEBUG ON ##" + REDIRECTION_OUTPUT="" + else + REDIRECTION_OUTPUT=" 2> /dev/null" fi # mode verbose enable -if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ; fi +if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ;fi # Check USAGE by arguments number if [ $(($#-($OPTIND-1))) -ne 1 ] @@ -140,10 +143,10 @@ else } fi -mkdir -p $SHOW_DIR -mkdir -p $SOLR_RES -mkdir -p $EXT_LEX -mkdir -p $TRIGGER_CONFZONE +mkdir -p $SHOW_DIR > /dev/null 2>&1 +mkdir -p $SOLR_RES > /dev/null 2>&1 +mkdir -p $EXT_LEX > /dev/null 2>&1 +mkdir -p $TRIGGER_CONFZONE > /dev/null 2>&1 #------------------# # Create Workspace # @@ -207,7 +210,7 @@ fi # Segment ctm into several show files and create a seg list by show print_info "Segment ctm into show files and a seg list by show" 2 -$SCRIPT_PATH/ctm2show.pl $INPUT_DIR/$BASENAME.ctl $INPUT_DIR/$BASENAME.show.seg $SHOW_DIR +$SCRIPT_PATH/ctm2show.pl $INPUT_DIR/$BASENAME.ctl $INPUT_DIR/$BASENAME.show.seg $SHOW_DIR $REDIRECTION_OUTPUT #-----------------------------------------------------------# # SOLR QUERIES # @@ -231,10 +234,10 @@ do if [ $(wc -w "$SHOW_DIR/$bn.queries" | cut -f1 -d' ') -gt 0 ]; then query=$(cat $SHOW_DIR/$bn.queries)"&fq=docDate:[$datePattern]" echo $query > $SHOW_DIR/$bn.queries - python $SCRIPT_PATH/ProcessSOLRQueries.py $SHOW_DIR/$bn.queries $SOLR_RES/$bn.keywords.tmp $SOLR_RES/$bn.txt.tmp + python $SCRIPT_PATH/ProcessSOLRQueries.py $SHOW_DIR/$bn.queries $SOLR_RES/$bn.keywords.tmp $SOLR_RES/$bn.txt.tmp $REDIRECTION_OUTPUT cat $SOLR_RES/$bn.keywords.tmp | sort -u > $SOLR_RES/$bn.keywords cat $SOLR_RES/$bn.txt.tmp | sort -u > $SOLR_RES/$bn.txt - rm $SOLR_RES/*.tmp + rm $SOLR_RES/*.tmp > /dev/null 2>&1 fi if [ $CHECK -eq 1 ] @@ -290,7 +293,7 @@ do # For each treil for baseseg in $(cat "$SHOW_DIR/$basename.lst") do - $OTMEDIA_HOME/tools/QUOTE_FINDER/bin/acousticFinder ${LEXICON}.speer_phon $RES_CONF/wlat/$baseseg.wlat $TRIGGER_CONFZONE/${basename}.tosearch $SOLR_RES/$basename.phon_oov > $TRIGGER_CONFZONE/$baseseg.acousticlyfound + $OTMEDIA_HOME/tools/QUOTE_FINDER/bin/acousticFinder ${LEXICON}.speer_phon $RES_CONF/wlat/$baseseg.wlat $TRIGGER_CONFZONE/${basename}.tosearch $SOLR_RES/$basename.phon_oov > $TRIGGER_CONFZONE/$baseseg.acousticlyfound $OUTPUT_REDIRECTION # # Produce the boost file for the next decoding pass # @@ -331,7 +334,7 @@ do # Extract OOV really added # cat $SOLR_RES/$basename.phon_oov | cut -f1 | sort -u > $EXT_LEX/$basename.oov - $SCRIPT_PATH/intersec.pl $EXT_LEX/$basename.oov $EXT_LEX/$basename.acousticlyfound > $EXT_LEX/$basename.oov_acousticlyfound + $SCRIPT_PATH/intersec.pl $EXT_LEX/$basename.oov $EXT_LEX/$basename.acousticlyfound > $EXT_LEX/$basename.oov_acousticlyfound $REDIRECTION_OUTPUT # # Retrieve all phonetisation # @@ -345,7 +348,7 @@ print_info "Merge OOV and their phonetisation" 2 lexname=$(basename $LEXICON) cat $EXT_LEX/*.oov_acousticlyfound_phon | sort -u > $EXT_LEX/final/all.oov_acousticlyfound_phon cat $EXT_LEX/*.oov_acousticlyfound | sort -u | grep --perl-regex -v "^([a-z']){3}$" > $EXT_LEX/final/all.oov_acousticlyfound -$SCRIPT_PATH/MergeLexicon.pl $EXT_LEX/final/all.oov_acousticlyfound_phon > $EXT_LEX/final/${lexname}_ext.phon +$SCRIPT_PATH/MergeLexicon.pl $EXT_LEX/final/all.oov_acousticlyfound_phon > $EXT_LEX/final/${lexname}_ext.phon $REDIRECTION_OUTPUT # # Collect + clean retrieved txt @@ -428,7 +431,7 @@ done # Compile the speeral extended lexicon # print_info "Compile Speeral extended lexicon" 2 -$SPEERAL_PATH/bin/buildmappedbinode $LEXICON.bdlex_phon $EXT_LEX/final/${lexname}_ext.map $AM_SKL $EXT_LEX/speeral/${lexname}_ext +$SPEERAL_PATH/bin/buildmappedbinode $LEXICON.bdlex_phon $EXT_LEX/final/${lexname}_ext.map $AM_SKL $EXT_LEX/speeral/${lexname}_ext $REDIRECTION_OUTPUT if [ $CHECK -eq 1 ] then diff --git a/main_tools/FirstPass.sh b/main_tools/FirstPass.sh index 9d93d7c..113b11c 100755 --- a/main_tools/FirstPass.sh +++ b/main_tools/FirstPass.sh @@ -87,11 +87,11 @@ then echo -e "## Mode DEBUG ON ##" REDIRECTION_OUTPUT="" else - REDIRECTION_OUTPUT=" > /dev/null 2>&1" + REDIRECTION_OUTPUT=" 2> /dev/null" fi # mode verbose enable -if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ; REDIRECTION_OUTPUT=" 2> /dev/null"; fi +if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ;fi # Check USAGE by arguments number if [ $(($#-($OPTIND-1))) -ne 2 ] @@ -163,7 +163,7 @@ then else rm $RES_DIR/*.lock > /dev/null 2>&1 fi -mkdir -p $RES_DIR $REDIRECTION_OUTPUT +mkdir -p $RES_DIR > /dev/null 2>&1 print_info "Make directory $RES_DIR" 1 #--------------------# diff --git a/main_tools/OneScriptToRuleThemAll.sh b/main_tools/OneScriptToRuleThemAll.sh index 04824a0..edac1c0 100755 --- a/main_tools/OneScriptToRuleThemAll.sh +++ b/main_tools/OneScriptToRuleThemAll.sh @@ -104,7 +104,7 @@ then ${MAIN_SCRIPT_PATH}/FirstPass.sh ${RING} $1 $2 ${MAIN_SCRIPT_PATH}/SecondPass.sh ${RING} ${REP_OUT} ${MAIN_SCRIPT_PATH}/ConfPass.sh ${RING} ${REP_OUT} "res_p2" - ${MAIN_SCRIPT_PATH}/ExploitConfPass.sh ${RING} ${REP_OUT} + ${MAIN_SCRIPT_PATH}/ExploitConfidencePass.sh ${RING} ${REP_OUT} ${MAIN_SCRIPT_PATH}/ThirdPass.sh ${RING} ${REP_OUT} ${MAIN_SCRIPT_PATH}/ConfPass.sh ${RING} ${REP_OUT} "res_p3" ${MAIN_SCRIPT_PATH}/RecomposePass.sh ${RING} ${REP_OUT} diff --git a/main_tools/SecondPass.sh b/main_tools/SecondPass.sh index 60b64ba..4fad46d 100755 --- a/main_tools/SecondPass.sh +++ b/main_tools/SecondPass.sh @@ -85,10 +85,13 @@ if [ $DEBUG -eq 1 ] then set -x echo -e "## Mode DEBUG ON ##" + REDIRECTION_OUTPUT="" + else + REDIRECTION_OUTPUT=" 2> /dev/null" fi # mode verbose enable -if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ; fi +if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ;fi # Check USAGE by arguments number if [ $(($#-($OPTIND-1))) -ne 1 ] @@ -149,7 +152,7 @@ if [ $RERUN -eq 0 ]; then rm -r $HMM > /dev/null 2>&1; fi mkdir -p $HMM print_info "Make directory $HMM" 1 if [ $RERUN -eq 0 ]; then rm -r $RES_DIR > /dev/null 2>&1; fi -mkdir -p $RES_DIR +mkdir -p $RES_DIR > /dev/null 2>&1 print_info "Make directory $RES_DIR" 1 #-------------------# @@ -221,7 +224,7 @@ do if [ $RERUN -eq 0 ] || ( [ ! -e $HMM/$speaker.hmm ] || [ -z $HMM/$speaker.hmm ] ) then 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 - $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/ + $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 fi if [ $CHECK -eq 1 ] && ( [ ! -e $HMM/$speaker.hmm ] || [ -z $HMM/$speaker.hmm ] ) @@ -237,7 +240,7 @@ do if [ -s $HMM/$speaker.hmm ] && ( [ $RERUN -eq 0 ] || ( [ ! -e $HMM/$speaker.cls ] || [ -z $HMM/$speaker.cls ] )) then print_info "$SPEERAL_TOOLS/gclust_pdf $HMM/$speaker.hmm $HMM/$speaker.cls -i $SPEERAL_AM/${MODS[$i]}.cls" 3 - $SPEERAL_TOOLS/gclust_pdf $HMM/$speaker.hmm $HMM/$speaker.cls -i $SPEERAL_AM/${MODS[$i]}.cls + $SPEERAL_TOOLS/gclust_pdf $HMM/$speaker.hmm $HMM/$speaker.cls -i $SPEERAL_AM/${MODS[$i]}.cls $REDIRECTION_OUTPUT fi if [ $CHECK -eq 1 ] && ( [ ! -e $HMM/$speaker.cls ] || [ -z $HMM/$speaker.cls ] ) then @@ -248,11 +251,11 @@ do ## Speeral decoding if [ -s $HMM/$speaker.hmm ] && [ -s $HMM/$speaker.cls ] then - 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" 3 - $SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_CFG[$i]} -r $PLP_DIR_P1 -m $HMM/$speaker.hmm -c $HMM/$speaker.cls $FORKS --lock + 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 + $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 else print_warn "$HMM/$speaker.hmm and $speaker.cls empty, do default decoding..." 2 - $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 + $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 fi if [ $CHECK -eq 1 ] @@ -283,20 +286,20 @@ ls $RES_DIR/*.treil | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.treil//' | sort > $ echo -e "$BASENAME P2 END\n[" >> $LOGFILE diff ${OUTPUT_DIR_BASENAME}/plp.lst ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> $LOGFILE echo -e "] $BASENAME" >> $LOGFILE -rm ${OUTPUT_DIR_BASENAME}/.tmp +rm ${OUTPUT_DIR_BASENAME}/.tmp > /dev/null 2>&1 #---------------# # Convert res # #---------------# # .res => .ctm -$SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.2pass.ctm +$SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.2pass.ctm $REDIRECTION_OUTPUT # .res => .trs echo -e "name $AUTHOR\nfileName ${BASENAME}\nfileExt wav\nsegFile ${OUTPUT_DIR_BASENAME}/${BASENAME}.seg" > ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg -$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 -rm ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg +$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 +rm ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg > /dev/null 2>&1 # .res => .txt -$SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.2pass.txt +$SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.2pass.txt $REDIRECTION_OUTPUT # unlock directory diff --git a/main_tools/ThirdPass.sh b/main_tools/ThirdPass.sh index effd950..411cd54 100755 --- a/main_tools/ThirdPass.sh +++ b/main_tools/ThirdPass.sh @@ -83,6 +83,9 @@ if [ $DEBUG -eq 1 ] then set -x echo -e "## Mode DEBUG ON ##" + REDIRECTION_OUTPUT="" + else + REDIRECTION_OUTPUT=" 2> /dev/null" fi # mode verbose enable @@ -191,11 +194,11 @@ do ## Speeral decoding if [ -s $HMM/$speaker.hmm ] && [ -s $HMM/$speaker.cls ] then - print_info "$SPEERAL_BIN $LST/$speaker.lst $RES_DIR $SPEERAL_THIRD_CFG -r $PLP_DIR_P1 -m $HMM/$speaker.hmm -c $HMM/$speaker.cls $FORKS --lock" 3 - $SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_THIRD_CFG} -r $PLP_DIR_P1 -m $HMM/$speaker.hmm -c $HMM/$speaker.cls $FORKS --lock + print_info "$SPEERAL_BIN $LST/$speaker.lst $RES_DIR $SPEERAL_THIRD_CFG -r $PLP_DIR_P1 -m $HMM/$speaker.hmm -c $HMM/$speaker.cls $FORKS --lock $REDIRECTION_OUTPUT" 3 + $SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_THIRD_CFG} -r $PLP_DIR_P1 -m $HMM/$speaker.hmm -c $HMM/$speaker.cls $FORKS --lock $REDIRECTION_OUTPUT else print_warn "$HMM/$speaker.hmm and $speaker.cls empty, do default decoding..." 2 - $SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_THIRD_CFG} -r $PLP_DIR_P1 -m $SPEERAL_AM/${MODS[$i]}.hmm -c $SPEERAL_AM/${MODS[$i]}.cls $FORKS --lock + $SPEERAL_BIN $LST/$speaker.lst $RES_DIR ${SPEERAL_THIRD_CFG} -r $PLP_DIR_P1 -m $SPEERAL_AM/${MODS[$i]}.hmm -c $SPEERAL_AM/${MODS[$i]}.cls $FORKS --lock $REDIRECTION_OUTPUT fi if [ $CHECK -eq 1 ] @@ -222,20 +225,20 @@ ls $RES_DIR/*.res | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.res//' | sort > ${OUT echo -e "$BASENAME P3 END\n[" >> $LOGFILE diff ${OUTPUT_DIR_BASENAME}/plp.lst ${OUTPUT_DIR_BASENAME}/.tmp | grep -e "^< " | sed -e "s/< //" >> $LOGFILE echo -e "] $BASENAME" >> $LOGFILE -rm ${OUTPUT_DIR_BASENAME}/.tmp +rm ${OUTPUT_DIR_BASENAME}/.tmp > /dev/null 2>&1 #---------------# # Convert res # #---------------# # .res => .ctm -$SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.3pass.ctm +$SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.3pass.ctm $REDIRECTION_OUTPUT # .res => .trs echo -e "name $AUTHOR\nfileName ${BASENAME}\nfileExt wav\nsegFile ${OUTPUT_DIR_BASENAME}/${BASENAME}.seg" > ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg -$SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TRS --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.3pass.trs --trs_config ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg -rm ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg +$SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TRS --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.3pass.trs --trs_config ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg $REDIRECTION_OUTPUT +rm ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg > /dev/null 2>&1 # .res => .txt -$SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.3pass.txt +$SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.3pass.txt $REDIRECTION_OUTPUT print_info "<= End $BASENAME P3 | $(date +'%d/%m/%y %H:%M:%S')" 1 diff --git a/tools/scripts/ExtractAudioFromTV.sh b/tools/scripts/ExtractAudioFromTV.sh new file mode 100755 index 0000000..54f40e4 --- /dev/null +++ b/tools/scripts/ExtractAudioFromTV.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# File : ExtractAudioFromTV.sh +# Brief : extract audio file and subtitle from TV corpus +# version 1.0 +# + +### ExtractAudioFromCorpus.sh INA-TV2 MYTV + +if [ $(($#-($OPTIND-1))) -ne 2 ] +then + echo "BAD USAGE : $0 " + exit 1 +fi + +if [ -e $1 ] +then + IN=$(readlink -e $1) +else + echo "ERROR : Can't read input $1" + exit 1 +fi + +if [ -e $2 ] +then + OUT=$(readlink -e $2) +else + echo "ERROR : Can't read OUTPUT $2" + exit 1 +fi + + +for f in `ls $IN` +do + channel=`echo $f | sed -re 's/NAS_//'` + mkdir $OUT/$channel + cd $f + for d in `ls $f` + do + for file in `ls ${f}/${d} | grep MP4` + do + avconv -i ${IN}/${f}/${d}/${file} -threads 4 -vn -f wav -ac 1 -ar 16000 -ab 256000 ${OUT}/${channel}/${d}_$(basename ${file} .MP4).wav + if [ -e ${IN}/${f}/${d}/$(basename ${file} .MP4).SRT ] + then + cp ${IN}/${f}/${d}/$(basename ${file} .MP4).SRT ${OUT}/${channel}/${d}_$(basename ${file} .MP4).SRT + fi + done + done +done + -- 1.8.2.3