Commit 2b38a4d6 authored by Yoann HOUPERT's avatar Yoann HOUPERT

add switch transcript

parent a74219c8
......@@ -16,6 +16,8 @@ curentFile=$2
file="$wavdir/$curentFile"
sysRootName=$(echo $(basename $sysdir)|cut -f1 -d"=")
indiceData=$3
fileRootName=$(basename $file .wav)
datadir=$lvcsrRootDir/kaldi_input_data/$fileRootName
......@@ -71,11 +73,14 @@ sysRootName=$(echo $(basename $sysdir)|cut -f1 -d"=")
$lvcsrRootDir/scripts/steps/decode.sh --nj $decode_nj --cmd "$decode_cmd" --num-threads $num_threads --skip-scoring "true" \
$gmmdir/Graph $datadir $transdir || exit 1
gunzip -c $transdir/lat.1.gz |\
lattice-to-nbest --acoustic-scale=0.0883 --n=10 --lm-scale=1.0 ark:- ark:- | \
nbest-to-ctm --precision=1 ark:- - | utils/int2sym.pl -f 5 $gmmdir/Graph/words.txt > $transdir/indice_confiance_brut.txt
if [ "$indiceData" = "True" ] ; then
gunzip -c $transdir/lat.1.gz |\
lattice-to-nbest --acoustic-scale=0.0883 --n=10 --lm-scale=1.0 ark:- ark:- | \
nbest-to-ctm --precision=1 ark:- - | utils/int2sym.pl -f 5 $gmmdir/Graph/words.txt > $transdir/indice_confiance_brut.txt
$lvcsrRootDir/scripts/./extractorData.sh $transdir/indice_confiance_brut.txt > $transdir/indice_confiance.txt
fi
$lvcsrRootDir/scripts/./extractorData.sh $transdir/indice_confiance_brut.txt > $transdir/indice_confiance.txt
fi
mv $transdir $lvcsrRootDir/trans
cat $lvcsrRootDir/trans/decode_$fileRootName/log/decode.1.log | grep -v "#" | grep -v "LOG" | grep -v "gmm-latgen-faster" | grep -v "splice-feats" | grep -v "transform-feats" | grep -v "apply-cmvn" | awk '{$1=""; print $0}' | sed 's/^[ ]//' > $lvcsrRootDir/trans/decode_$fileRootName.log
......
......@@ -7,3 +7,4 @@ server_target : /worker/ws/speech
temp_file_location : wavs/
decoder_command : "./scripts/decode.sh systems/models"
preprocessing : true
indice_data : true
......@@ -27,6 +27,8 @@ SERVER_TARGET = worker_settings.get('server_params', 'server_target')
DECODER_COMMAND = worker_settings.get('worker_params', 'decoder_command')
TEMP_FILE_PATH = worker_settings.get('worker_params', 'temp_file_location')
PREPROCESSING = True if worker_settings.get('worker_params', 'preprocessing') == 'true' else False
INDICE_DATA = True if worker_settings.get('worker_params', 'indice_data') == 'true' else False
if "OFFLINE_PORT" in os.environ:
SERVER_PORT = os.environ['OFFLINE_PORT']
......@@ -65,14 +67,20 @@ class WorkerWebSocket(WebSocketClient):
# Offline decoder call
logging.debug(DECODER_COMMAND + ' ' + TEMP_FILE_PATH + self.fileName+'.wav')
subprocess.call("cd scripts; ./decode.sh ../systems/models "+self.fileName+".wav", shell=True)
subprocess.call("cd scripts; ./decode.sh ../systems/models "+self.fileName+".wav "+str(INDICE_DATA), shell=True)
# Check result
if os.path.isfile('trans/decode_'+self.fileName+'.log'):
with open('trans/decode_'+self.fileName+'/indice_confiance.txt', 'r') as resultFile:
result = resultFile.read().strip()
logging.debug("Transcription is: %s" % result)
self.send_result(result)
if INDICE_DATA and os.path.isfile('trans/decode_'+self.fileName+'/indice_confiance.txt'):
with open('trans/decode_'+self.fileName+'/indice_confiance.txt', 'r') as resultFile:
result = resultFile.read().strip()
logging.debug("Transcription is: %s" % result)
self.send_result(result)
else:
with open('trans/decode_'+self.fileName+'.log', 'r') as resultFile:
result = resultFile.read().strip()
logging.debug("Transcription is: %s" % result)
self.send_result(result)
else:
logging.error("Worker Failed to create transcription file")
self.send_result("")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment