Commit 5585cf2d authored by Yoann HOUPERT's avatar Yoann HOUPERT
Browse files

improvement router promise

parent 3879e823
Pipeline #5911 failed with stage
in 22 seconds
......@@ -36,18 +36,26 @@ const routesFactory = config => {
enhancer.enhancement(req.files.wav, config.speechEnhancement,
(err, httpResponse, body) => {
if (err) {
return res.status(400).send('Error while enhancing audio.' + err);
return res.status(500).send('Error while enhancing audio.' + err);
}
// TODO Manage 'body' raw for kaldis api
let buff = new Buffer(body);
// TODO Manage 'body' raw for kaldis api
stt.transcript(req.files.wav.data, config.gstreamer,
(err, httpResponse, body) => {
if (err) {
return res.status(400).send('Error while enhancing audio.' + err);
return res.status(500).send('Error while transcript the audio.' + err);
} else if(body.indexOf('No workers available') !== -1){
return res.status(500).send('No worker available for the moment.');
}
return res.status(200).json({message: 'transcript done', transcript: JSON.parse(body).hypotheses[0].utterance});
});
const json = JSON.parse(body)
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});
}
);
}
);
});
......
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