Commit 8b14bf07 authored by Yoann HOUPERT's avatar Yoann HOUPERT

Merge branch 'next' into 'master'

Next

See merge request !4
parents 2634c97d 1e1cd6b6
......@@ -89,6 +89,12 @@ class DecodeRequestHandler(tornado.web.RequestHandler):
self.set_status(200, "Initial statut")
self.waitResponse = Condition()
self.waitWorker = Condition()
if not self.get_arguments('model'):
self.designation = 'uc1'
else:
self.designation = self.get_argument('model')
if self.request.method != 'POST' :
logging.debug("Received a non-POST request")
self.set_status(403, "Wrong request, server handles only POST requests")
......@@ -101,7 +107,7 @@ class DecodeRequestHandler(tornado.web.RequestHandler):
logging.debug("POST request from %s does not contain 'file_to_transcript' field.")
temp_file = self.request.files['wavFile'][0]['body']
self.temp_file = temp_file
#Writing file
try:
f = open(TEMP_FILE_PATH+self.uuid+'.wav', 'wb')
......@@ -117,8 +123,10 @@ class DecodeRequestHandler(tornado.web.RequestHandler):
@gen.coroutine
def post(self, *args, **kwargs):
logging.debug("Allocating Worker to %s" % self.uuid)
logging.info(self.designation)
yield self.allocate_worker()
self.worker.write_message(json.dumps({'uuid':self.uuid, 'file': self.temp_file.encode('base64')}))
self.worker.write_message(json.dumps({'uuid':self.uuid, 'designation': self.designation,'file': self.temp_file.encode('base64')}))
yield self.waitResponse.wait()
self.finish()
......@@ -146,7 +154,6 @@ class DecodeRequestHandler(tornado.web.RequestHandler):
self.set_status(200, "Transcription succeded")
self.application.num_requests_processed += 1
self.waitResponse.notify()
def on_finish(self):
#CLEANUP
......
......@@ -4,4 +4,10 @@ docker build -t linagora/stt-offline .
# Start
Path_model=$1
port=$2
docker run --rm -it -p $port:5000 -v $Path_model:/opt/models linagora/stt-offline
\ No newline at end of file
model_type=$3
if [ -z "${model_type}" ]; then
model_type="uc1"
fi
docker run --rm -it -p $port:5000 -v $Path_model:/opt/models -e MODEL_TYPE=$model_type linagora/stt-offline
\ No newline at end of file
......@@ -29,7 +29,6 @@ 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']
......@@ -54,6 +53,7 @@ class WorkerWebSocket(WebSocketClient):
else:
if 'uuid' in json_msg.keys():
self.client_uuid = json_msg['uuid']
self.designation = json_msg['designation']
self.fileName = self.client_uuid.replace('-', '')
self.file = json_msg['file'].decode('base64')
self.filepath = TEMP_FILE_PATH+self.fileName+'.wav'
......@@ -67,7 +67,7 @@ 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 "+str(INDICE_DATA), shell=True)
subprocess.call("cd scripts; ./decode.sh ../systems/models/"+self.designation+"/model/ "+self.fileName+".wav "+str(INDICE_DATA), shell=True)
# Check result
if os.path.isfile('trans/decode_'+self.fileName+'.log'):
......@@ -139,7 +139,7 @@ def main():
#thread.start_new_thread(loop.run, ())
if not os.path.isdir(TEMP_FILE_PATH):
os.mkdir(TEMP_FILE_PATH)
print('#'*50)
logging.basicConfig(level=logging.DEBUG, format="%(levelname)8s %(asctime)s %(message)s ")
logging.info('Starting up worker')
ws = WorkerWebSocket(args.uri)
......
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