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-controller
Commits
d98b050a
Commit
d98b050a
authored
Nov 22, 2017
by
Yoann HOUPERT
Browse files
dockerisation
parent
6aa2163b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
89 additions
and
27 deletions
+89
-27
.env
.env
+3
-0
Dockerfile
Dockerfile
+20
-0
config.json
config.json
+10
-2
docker-compose.yml
docker-compose.yml
+31
-0
lib/controller.js
lib/controller.js
+2
-3
lib/speech-enhancement.js
lib/speech-enhancement.js
+9
-11
lib/speech-to-text.js
lib/speech-to-text.js
+4
-3
lib/webserver/routes.js
lib/webserver/routes.js
+10
-8
No files found.
.env
0 → 100644
View file @
d98b050a
MODELS_PATH=./models/
YAML=/opt/models/gmm_hmm3.yaml
NB_WORKERS=2
Dockerfile
0 → 100644
View file @
d98b050a
FROM
node:8-slim
RUN
apt-get update
&&
apt-get
install
-y
wget
--no-install-recommends
\
&&
wget
-q
-O
- https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
\
&&
sh
-c
'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
\
&&
apt-get update
\
&&
rm
-rf
/var/lib/apt/lists/
*
\
&&
apt-get purge
--auto-remove
-y
curl
\
&&
rm
-rf
/src/
*
.deb
WORKDIR
/usr/src/app/linstt-poc-socgen
COPY
package.json .
COPY
yarn.lock .
RUN
yarn
install
COPY
. /usr/src/app/linstt-poc-socgen
CMD
["yarn", "start"]
config.json
View file @
d98b050a
...
...
@@ -2,11 +2,19 @@
"api"
:
3000
,
"orchestrator"
:
{
"gstreamer"
:
{
"url"
:
"http://172.20.0.2:80/client/dynamic/recognize"
,
"host"
:
"linsttpocsocgen_kaldi_1"
,
"port"
:
"80"
,
"api"
:
{
"recognize"
:
"client/dynamic/recognize"
},
"ws"
:
"ws://hublot_kaldi-gstreamer_1:80/client/ws/speech?content-type=audio/x-matroska,+rate=(int)48000,+channels=(int)"
},
"speechEnhancement"
:
{
"url"
:
"http://172.17.0.2:5000/upload"
,
"host"
:
"linsttpocsocgen_speech-enhencement_1"
,
"port"
:
"5000"
,
"api"
:
{
"upload"
:
"upload"
},
"config"
:
"-n"
,
"debug"
:
false
}
...
...
docker-compose.yml
0 → 100644
View file @
d98b050a
version
:
'
3.2'
services
:
socgen
:
build
:
.
image
:
linagora/socgen
depends_on
:
-
speech-enhencement
-
kaldi
volumes
:
-
./media:/opt/media
ports
:
-
"
3000:3000"
speech-enhencement
:
image
:
linagora/speech-enhencement
expose
:
-
"
5000"
kaldi
:
image
:
linagora/kaldi
expose
:
-
"
80"
volumes
:
-
${MODELS_PATH}:/opt/models
env_file
:
.env
environment
:
-
NB_WORKERS
-
YAML
-
MODELS_PATH
lib/controller.js
View file @
d98b050a
...
...
@@ -19,10 +19,9 @@
*/
const
isFileValid
=
audio
=>
{
console
.
log
(
'
control of the audio
'
);
if
(
audio
.
mimetype
!==
'
audio/wave
'
)
if
(
audio
.
mimetype
!==
'
audio/wave
'
)
{
return
false
;
}
return
true
;
};
...
...
lib/speech-enhancement.js
View file @
d98b050a
...
...
@@ -18,32 +18,30 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const
request
=
require
(
'
request
'
);
const
bodyParser
=
require
(
'
body-parser
'
);
const
fs
=
require
(
'
fs
'
);
function
enhancementlCallback
(
err
,
httpResponse
,
body
)
{
if
(
err
)
{
return
console
.
error
(
'
upload failed:
'
,
err
);
}
console
.
log
(
'
Upload successful!
'
);
return
httpResponse
;
return
body
;
}
const
enhancement
=
(
wavFile
,
speechEnhancement
)
=>
{
const
formData
=
{
wavFile
:
wavFile
.
data
,
msg
:
"
-n
"
msg
:
'
-n
'
};
// TODO until no docker-compose use debug mode
const
url
=
'
http://
'
+
speechEnhancement
.
host
+
'
:
'
+
speechEnhancement
.
port
+
'
/
'
+
speechEnhancement
.
api
.
upload
;
if
(
!
speechEnhancement
.
debug
)
{
return
request
.
post
({
url
:
speechEnhancement
.
url
,
form
:
formData
},
enhancementlCallback
);
}
else
{
return
wavFile
;
return
request
.
post
({
url
,
form
:
formData
},
enhancementlCallback
);
}
return
wavFile
;
};
module
.
exports
=
{
enhancement
};
};
\ No newline at end of file
lib/speech-to-text.js
View file @
d98b050a
...
...
@@ -24,7 +24,6 @@ function sttCallback(err, httpResponse, body) {
if
(
err
)
{
return
console
.
error
(
'
upload failed:
'
,
err
);
}
console
.
log
(
'
Transcript successful!
'
);
return
body
;
}
...
...
@@ -32,10 +31,12 @@ const transcript = (audio, gstreamer) => {
const
formData
=
{
audiofile
:
audio
};
const
url
=
'
http://
'
+
gstreamer
.
host
+
'
:
'
+
gstreamer
.
port
+
'
/
'
+
gstreamer
.
api
.
recognize
;
// TODO until no docker-compose use debug mode
return
request
.
post
({
url
:
gstreamer
.
url
,
form
:
formData
},
sttCallback
);
return
request
.
post
({
url
,
form
:
formData
},
sttCallback
);
};
module
.
exports
=
{
transcript
};
\ No newline at end of file
};
lib/webserver/routes.js
View file @
d98b050a
...
...
@@ -21,13 +21,11 @@
const
routesFactory
=
config
=>
{
/* eslint new-cap: ["error", { "capIsNew": false }] */
const
routes
=
require
(
'
express
'
).
Router
();
const
enhancer
=
require
(
'
../speech-enhancement
'
);
const
stt
=
require
(
'
../speech-to-text
'
);
// TODO
const stt = require('../speech-to-text');
const
control
=
require
(
'
../controller
'
);
let
transcript
=
'
result
'
;
routes
.
post
(
'
/api/transcript
'
,
(
req
,
res
)
=>
{
if
(
!
req
.
files
)
{
return
res
.
status
(
400
).
send
(
'
No files were uploaded.
'
);
...
...
@@ -35,13 +33,17 @@ const routesFactory = config => {
if
(
!
control
.
isFileValid
(
req
.
files
.
wav
))
{
return
res
.
status
(
400
).
send
(
'
File is not valid.
'
);
}
const
wavEnhancement
=
enhancer
.
enhancement
(
req
.
files
.
wav
,
config
.
speechEnhancement
);
//const transcriptRes = stt.transcript(wavEnhancement, config.gstreamer);
res
.
status
(
200
).
json
({
message
:
'
transcript call
'
,
transcript
:
wavEnhancement
});
let
wavEnhancement
=
req
.
files
.
wav
.
data
;
wavEnhancement
=
enhancer
.
enhancement
(
req
.
files
.
wav
,
config
.
speechEnhancement
);
// Const transcriptRes = stt.transcript(wavEnhancement, config.gstreamer);
const
result
=
wavEnhancement
;
res
.
status
(
200
).
json
({
message
:
'
transcript call
'
,
transcript
:
result
});
});
return
routes
;
};
module
.
exports
=
{
routesFactory
};
\ No newline at end of file
};
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