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

add enhancement rest call

parent 0a76971a
......@@ -19,12 +19,14 @@
*/
const app = require('express')();
const bodyParser = require('body-parser');
const config = require('./config.json');
const routes = require('./lib/webserver/routes');
console.log('starting routes linstt-poc-socgen...');
app.use(bodyParser.raw({type: 'audio/wav', limit: '200mb'}));
app.use('/', routes.routesFactory(config.orchestrator));
app.listen(config.api, () => {
console.log('App listening on port 3000');
......
{
"api": 3000,
"orchestrator": {
"gstreamerURL": "ws://localhost:3001/kaldi",
"speechEnhancementURL": "ws://localhost:3002/enhancement"
"gstreamerURL": {
"url": "ws://localhost:3001/kaldi"
},
"speechEnhancement": {
"url" : "http://172.17.0.2:5000/upload",
"config" : "-n",
"debug" : false
}
}
}
\ No newline at end of file
......@@ -17,12 +17,27 @@
* 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 request = require('request');
const enhancement = audio => {
console.log('transcript of the audio');
console.log('Do stuff' + audio);
function enhancementlCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log('Upload successful!');
return body;
}
return 'some text';
const enhancement = (wavFile, speechEnhancement) => {
const formData = {
wavfile: wavFile,
msg: speechEnhancement.config
};
// TODO until no docker-compose use debug mode
if (speechEnhancement.debug) {
return request.post({url: speechEnhancement.url, form: formData}, enhancementlCallback);
}
return wavFile;
};
module.exports = {
......
......@@ -25,12 +25,11 @@ const routesFactory = config => {
const stt = require('../speech-to-text');
routes.post('/api/transcript', (req, res) => {
console.log(config);
// TODO manage first call to config.speechEnhancementURL
enhancer.enhancement();
const wavEnhancement = enhancer.enhancement(req.body, config.speechEnhancement);
// TODO manage first call to config.gstreamerURL
stt.transcript();
stt.transcript(wavEnhancement);
res.status(200).json({message: 'transcript call'});
});
......
......@@ -12,7 +12,7 @@
"dependencies": {
"body-parser": "^1.18.2",
"express": "^4.16.2",
"xmlhttprequest": "1.8.0"
"request": "^2.83.0"
},
"devDependencies": {
"jest": "20.0.0",
......
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