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
e8507a20
Commit
e8507a20
authored
Jan 12, 2018
by
Rudy BARAGLIA
Browse files
Minor changes
parent
b22d2444
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
10 deletions
+17
-10
scripts/decode.sh
scripts/decode.sh
+2
-2
worker.cfg
worker.cfg
+2
-2
worker.py
worker.py
+13
-6
No files found.
scripts/decode.sh
View file @
e8507a20
#!/bin/bash
.
cmd.sh
.
path.sh
.
./scripts/
cmd.sh
.
./scripts/
path.sh
# call sh ./decoding.sh ../systems/sys1
...
...
worker.cfg
View file @
e8507a20
...
...
@@ -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
worker.py
View file @
e8507a20
...
...
@@ -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
...
...
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