Commit 9c793ec9 authored by Yoann HOUPERT's avatar Yoann HOUPERT
Browse files

manage full orchestration

parent d7df6453
Pipeline #6323 failed with stage
in 59 seconds
......@@ -2,21 +2,19 @@
"api": 3000,
"orchestrator": {
"gstreamer": {
"host": "linsttpocsocgen_kaldi_1",
"host": "linsttpoc_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": {
"host": "linsttpocsocgen_speech-enhencement_1",
"host": "linsttpoc_speech-enhencement_1",
"port": "5000",
"api" : {
"upload" : "upload"
},
"config" : "-n",
"debug" : false
"config" : "-n"
}
}
}
\ No newline at end of file
......@@ -17,30 +17,28 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const fs = require('fs');
const request = require('request');
const enhancement = (wavFile, speechEnhancement, nameFile, enhancementlCallback) => {
const enhancement = (wavFile, speechEnhancement, enhancementlCallback) => {
const url = 'http://' + speechEnhancement.host + ':' + speechEnhancement.port + '/' + speechEnhancement.api.upload;
fs.writeFile(nameFile + '.wav', wavFile.data, err => {
if (err) {
throw err;
}
const options = {
url,
headers: {
'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
const options = {
url,
formData: {
wavFile: {
value: wavFile.data,
options: {
filename: 'wavFile',
contentType: 'audio/x-wav'
}
},
formData: {
wavFile: fs.createReadStream(nameFile + '.wav'),
msg: '-n'
}
};
msg: '-n'
},
encoding: null
};
request.post(options, enhancementlCallback);
request.post(options, enhancementlCallback);
});
return wavFile;
};
......
......@@ -33,16 +33,12 @@ const routesFactory = config => {
return res.status(400).send('File is not valid.');
}
const nameFile = Math.random().toString(36).substring(7);
enhancer.enhancement(req.files.wav, config.speechEnhancement, nameFile,
enhancer.enhancement(req.files.wav, config.speechEnhancement,
(err, httpResponse, body) => {
if (err) {
return res.status(500).send('Error while enhancing audio.' + err);
}
util.cleanFile(nameFile);
util.writeFile('enchancementFile', body);
stt.transcript(body, config.gstreamer,
(err, httpResponse, body) => {
if (err) {
......@@ -55,7 +51,7 @@ const routesFactory = config => {
if (json.status === 5) {
return res.status(500).send('Error while transcript the audio.');
}
return res.status(200).json({message: 'transcript done', transcript: json.hypotheses[0].utterance});
return res.status(200).json({message: 'transcript done', transcript: json});
}
);
}
......
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