Commit 2f5312f1 authored by Rudy BARAGLIA's avatar Rudy BARAGLIA
Browse files

Corrected an issue where the worker use to crash after a failed transcription,...

Corrected an issue where the worker use to crash after a failed transcription, now return an empty transcription
parent 2ab14876
......@@ -185,7 +185,8 @@ class WorkerWebSocketHandler(tornado.websocket.WebSocketHandler):
def on_close(self):
if self.client_handler != None:
self.client_handler.send_error("Worker closed")
self.client_handler.set_status(503, "Worker failed to translate file")
self.client_handler.finish()
logging.debug("WORKER WebSocket closed")
self.application.available_workers.discard(self)
self.application.connected_worker -= 1
......
......@@ -31,7 +31,7 @@ sysRootName=$(echo $(basename $sysdir)|cut -f1 -d"=")
# java -Xmx2024m -jar $lvcsrRootDir/tools/lium_spkdiarization-8.4.1.jar \
# --fInputMask=$file --sOutputMask=$datadir/$fileRootName.seg --doCEClustering $fileRootName
duration=`soxi -D $file`
# echo "$fileRootName 1 0 $duration M S U S0" | sort -nk3 > $datadir/$fileRootName.seg
echo "$fileRootName 1 0 $duration M S U S0" | sort -nk3 > $datadir/$fileRootName.seg
fi
if [ $stage -le 2 ]; then
# Generate kaldi input for offline decoding
......@@ -50,7 +50,7 @@ sysRootName=$(echo $(basename $sysdir)|cut -f1 -d"=")
echo "$tag sox $file -t wav -r 16000 -c 1 - |"
done) > $datadir/wav.scp
cat $datadir/wav.scp | awk '{ print $1, $1, "A"; }' > $datadir/reco2file_and_channel
# echo validate_data_dir.sh
echo validate_data_dir.sh
$lvcsrRootDir/scripts/utils/validate_data_dir.sh --no-text --no-feats $datadir
$lvcsrRootDir/scripts/utils/fix_data_dir.sh $datadir
fi
......@@ -67,7 +67,7 @@ sysRootName=$(echo $(basename $sysdir)|cut -f1 -d"=")
if [ $stage -le 4 ]; then
if [ ! -f $transdir/trans.1 ]; then
# echo "run fmllr decoding"
echo "run fmllr decoding"
$lvcsrRootDir/scripts/steps/decode.sh --nj $decode_nj --cmd "$decode_cmd" --num-threads $num_threads --skip-scoring "true" \
$gmmdir/Graph $datadir $transdir || exit 1
fi
......
def signaltonoise(data, axis=0):
"""Calculates the signal-to-noise ratio, as the ratio of the mean over
standard deviation along the given axis.
Parameters
----------
data : sequence
Input data
axis : {0, int}, optional
Axis along which to compute. If None, the computation is performed
on a flat version of the array.
"""
data = ma.array(data, copy=False)
m = data.mean(axis)
sd = data.std(axis, ddof=0)
return m/sd
......@@ -5,7 +5,7 @@ Created on Thu Jan 18 17:32:23 2018
@author: rbaraglia
"""
import sys
from pydub import AudioSegment
......@@ -59,3 +59,5 @@ def trim_silence_segments(input_file,output_file, chunk_size=100, threshold_fact
trimmed_sound.export(output_file, format="wav")
if __name__ == '__main__':
trim_silence_segments(sys.argv[1], sys.argv[2])
\ No newline at end of file
......@@ -72,7 +72,7 @@ class WorkerWebSocket(WebSocketClient):
self.send_result(result)
else:
logging.error("Worker Failed to create transcription file")
self.send_error("File was not created by worker")
self.send_result("")
# Delete temporary files
for file in os.listdir(TEMP_FILE_PATH):
......@@ -81,7 +81,7 @@ class WorkerWebSocket(WebSocketClient):
def post(self, m):
logging.debug('POST received')
def send_result(self, result=None):
def send_result(self, result=""):
msg = json.dumps({u'uuid': self.client_uuid, u'transcription':result, u'trust_ind':u"0.1235"})
self.client_uuid = None
self.send(msg)
......
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