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

add communication with kaldi

parent 4a6f9243
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"
ports:
- "5000:5000"
kaldi:
image: linagora/kaldis
expose:
- "80"
volumes:
- ${MODELS_PATH}:/opt/models
env_file: .env
environment:
- NB_WORKERS
- YAML
- MODELS_PATH
ports:
- "80:80"
\ No newline at end of file
......@@ -19,15 +19,7 @@
*/
const request = require('request');
function enhancementlCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log('Upload successful!');
return body;
}
const enhancement = (wavFile, speechEnhancement) => {
const enhancement = (wavFile, speechEnhancement, enhancementlCallback) => {
const formData = {
wavFile: wavFile.data,
msg: '-n'
......@@ -37,9 +29,9 @@ const enhancement = (wavFile, speechEnhancement) => {
if (!speechEnhancement.debug) {
return request.post({url, form: formData}, enhancementlCallback);
}else {
return wavFile;
}
return wavFile;
};
module.exports = {
......
......@@ -32,9 +32,8 @@ const transcript = (audio, gstreamer) => {
audiofile: audio
};
const url = 'http://' + gstreamer.host + ':' + gstreamer.port + '/' + gstreamer.api.recognize;
// TODO until no docker-compose use debug mode
return request.post({url, form: formData}, sttCallback);
return request.post({url, body: audio}, sttCallback);
};
module.exports = {
......
......@@ -21,9 +21,8 @@
const routesFactory = config => {
/* eslint new-cap: ["error", { "capIsNew": false }] */
const routes = require('express').Router();
const enhancer = require('../speech-enhancement');
// TODO const stt = require('../speech-to-text');
const stt = require('../speech-to-text');
const control = require('../controller');
routes.post('/api/transcript', (req, res) => {
......@@ -36,10 +35,20 @@ const routesFactory = config => {
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});
/*wavEnhancement = enhancer.enhancement(req.files.wav, config.speechEnhancement,
(err, httpResponse, body) => {
if (err) {
return res.status(400).send('Error while enhancing audio.');
}
console.log('Upload successful!');
console.log(body)
//res.send(body);
return res.status(200).json({message: 'transcript call', transcript: 'toto'});
}
);*/
const transcriptRes = stt.transcript(wavEnhancement, config.gstreamer);
return res.status(200).json({message: 'transcript call', transcript: 'toto'});
});
return routes;
};
......
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