Commit d98b050a authored by Yoann HOUPERT's avatar Yoann HOUPERT
Browse files

dockerisation

parent 6aa2163b
MODELS_PATH=./models/
YAML=/opt/models/gmm_hmm3.yaml
NB_WORKERS=2
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"]
......@@ -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
}
......
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
......@@ -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;
};
......
......@@ -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
......@@ -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
};
......@@ -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
};
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