Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
LINAGORA
L
LGS
Labs
linstt-offline-decoding
Commits
1e1cd6b6
Commit
1e1cd6b6
authored
Feb 28, 2018
by
Yoann HOUPERT
Browse files
Merge branch 'feature/multimodel_support' into next
parents
7a1eabbd
5c6bd7ae
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
7 deletions
+20
-7
modules/server/master_server.py
modules/server/master_server.py
+10
-3
modules/worker_offline/start_worker.sh
modules/worker_offline/start_worker.sh
+7
-1
modules/worker_offline/worker_offline.py
modules/worker_offline/worker_offline.py
+3
-3
No files found.
modules/server/master_server.py
View file @
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
...
...
modules/worker_offline/start_worker.sh
View file @
1e1cd6b6
...
...
@@ -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
modules/worker_offline/worker_offline.py
View file @
1e1cd6b6
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment