Commit 74db6c7e authored by Yoann HOUPERT's avatar Yoann HOUPERT

add summary process

parent b0d4ba4e
Pipeline #14097 failed with stage
MODELS_PATH=./models/current_model/hublot_model/
MODEL_PATH_OFFLINE=./models/current_model/
MODELS_PATH=../models/current_model/hublot_model/
MODEL_PATH_OFFLINE=../models/current_model/
OFFLINE_PORT=8888
YAML=/opt/models/gmm_hmm3.yaml
NB_WORKERS=2
......
......@@ -27,7 +27,7 @@ const loader = require('./lib/loader.js')('./client');
const controllerFactory = require('./lib/controller.js');
const proxy = require('./lib/proxy.js')(config.proxy);
const resumeGenerator = require('./lib/resume.js')(config.offline)
const resumeGenerator = require('./lib/resume.js')(config.offline, config.resume)
require('dotenv').config()
......
......@@ -70,5 +70,13 @@
"api":{
"upload": "upload"
}
},
"resume": {
"host": "83.212.204.91",
"hostName": "datascience.open-paas.org",
"port": 80,
"api": "abs_summ/api",
"query": "&enc=utf-8&nkeys=100&lang=fr",
"resumeFolder": "resume"
}
}
}
\ No newline at end of file
......@@ -23,6 +23,7 @@ const SockJS = require('sockjs-client');
const stomp = require('webstomp-client');
const WebSocket = require('ws');
const XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
const fs = require('fs');
const Asd = require('./asd');
......@@ -97,7 +98,7 @@ module.exports = config => {
connectionToClient.send(xmlHttp.responseText);
} catch (err) {
console.error('proxy: recoRecoWS error', err);
console.error('It is probably already close',);
console.error('It is probably already close');
}
} else {
......@@ -162,7 +163,7 @@ module.exports = config => {
let thisUserStream;
if (!config.asd)
transcriptor = kaldiWS(userId, socket)
else{
else {
transcriptor = asd
thisUserStream = transcriptor.streamConnect()
}
......
......@@ -20,6 +20,7 @@
const fs = require('fs');
const uuidv1 = require('uuid/v1');
const request = require('request');
const util = require('util');
const ffmpegInstaller = require('@ffmpeg-installer/ffmpeg');
const ffprobeInstaller = require('@ffprobe-installer/ffprobe');
......@@ -34,18 +35,43 @@ const interalServerCode = 500;
module.exports = ffmpeg;
module.exports = config => {
module.exports = (config, resumeConfig) => {
let timestamp = undefined;
let userConf = 0;
function offlineTranscription(enhancementlCallback) {
let port = config.port;
if (process.env.OFFLINE_PORT !== undefined) {
port = process.env.OFFLINE_PORT;
function parserTranscription(transcription){
var lines = transcription.split('\n');
let json = {
entries: []
}
for(var i = 0;i < lines.length;i++){
var data = lines[i].split(' ');
const speaker = data[1]
const from = data[2]
const until = data[3]
let text = ""
for(var j = 4;j < data.length;j++){
text = text+data[j]+' '
}
const jsonData = {
from,
until,
speaker,
text
}
json.entries.push(jsonData)
}
return json;
}
const url = 'http://' + config.host + ':' + port + '/' + config.api.upload;
function offlineTranscription(enhancementlCallback) {
const url = 'http://' + config.host + ':' + config.port + '/' + config.api.upload;
const uiid = uuidv1();
let myUuidString = uiid.toString();
......@@ -70,6 +96,23 @@ module.exports = config => {
request.post(options, enhancementlCallback);
}
function resume(json){
const url = 'http://' + resumeConfig.hostName + '/' + resumeConfig.api+'?id=test'+resumeConfig.query;
const options = {
uri: url ,
method: 'POST',
json
};
request(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
fs.writeFile(resumeConfig.resumeFolder+'/resume.txt' , util.inspect(body), 'utf-8')
}
console.log(body)
});
}
function resumeGenerator() {
let nbFile = 0;
let cmd = ffmpeg()
......@@ -92,8 +135,10 @@ module.exports = config => {
result = {module: 'Offline transcription', error: 'Error during audio transcription'}
}
const transcription = json.transcript.transcription;
console.log(transcription)
console.log('current transcription ', json.transcript.transcription)
const jsonTranscript = parserTranscription(json.transcript.transcription)
resume(jsonTranscript)
})
})
}
......@@ -109,6 +154,9 @@ module.exports = config => {
if (!fs.existsSync(config.folder.audioMerged)) {
fs.mkdirSync(config.folder.audioMerged);
}
if (!fs.existsSync(resumeConfig.resumeFolder)) {
fs.mkdirSync(resumeConfig.resumeFolder);
}
},
generateStream: () => {
if (timestamp === undefined) {
......
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