Commit e8507a20 authored by Rudy BARAGLIA's avatar Rudy BARAGLIA
Browse files

Minor changes

parent b22d2444
#!/bin/bash
. cmd.sh
. path.sh
. ./scripts/cmd.sh
. ./scripts/path.sh
# call sh ./decoding.sh ../systems/sys1
......
......@@ -4,6 +4,6 @@ server_port : 8888
server_target : /worker/ws/speech
[worker_params]
temp_file_location : ../wavs/
decoder_command : "cd scripts; ./decode.sh ../systems/models"
temp_file_location : wavs/
decoder_command : "./scripts/decode.sh systems/models"
preprocessing : false
\ No newline at end of file
......@@ -47,22 +47,26 @@ class WorkerWebSocket(WebSocketClient):
self.fileName = self.client_uuid.replace('-', '')
self.file = json_msg['file'].decode('base64')
with open(TEMP_FILE_PATH+self.fileName+'.wav', 'wb') as f:
with open('./wavs/'+self.fileName+'.wav', 'wb') as f:
f.write(self.file)
logging.debug("FileName received: %s" % self.fileName)
# TODO: preprocessing ? (sox python)
if PREPROCESSING:
pass
# Offline decode call
logging.debug(DECODER_COMMAND + ' ' + self.fileName+'.wav')
subprocess.call(DECODER_COMMAND + ' ' + self.fileName+'.wav', shell=True)
logging.debug(DECODER_COMMAND + ' ' + TEMP_FILE_PATH + self.fileName+'.wav')
subprocess.call(DECODER_COMMAND + ' ' + TEMP_FILE_PATH + self.fileName+'.wav', shell=True)
# TODO: nettoyer les fichiers temporaires
# TODO: renvoyer la transcription au master
logging.debug(os.listdir('.'))
with open('trans/decode_'+self.fileName+'.log', 'r') as resultFile:
result = resultFile.read()
self.send_result(result)
if os.path.isfile('trans/decode_'+self.fileName+'.log'):
with open('trans/decode_'+self.fileName+'.log', 'r') as resultFile:
result = resultFile.read()
self.send_result(result)
else:
logging.error("Worker Failed to create transcription file")
self.send_error("File was not created by worker")
def post(self, m):
logging.debug('POST received')
......@@ -72,6 +76,9 @@ class WorkerWebSocket(WebSocketClient):
self.client_uuid = None
# TODO cleanup temp files.
self.send(msg)
def send_error(self, message):
msg = json.dumps({u'uuid': self.client_uuid, u'error':message})
self.send(msg)
def closed(self, code, reason=None):
pass
......
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