Commit 6988fe0d authored by Damien LAINÉ's avatar Damien LAINÉ

Merge branch 'multiplexe_webSocket' of...

Merge branch 'multiplexe_webSocket' of ssh://ci.linagora.com:7999/yhoupert/hublot into local_multiplex
parents 3183da51 568d4111
Pipeline #13987 failed with stage
......@@ -144,6 +144,9 @@ robot = {
start: (room, clientConfig) => {
robot.room = room;
robot.clientConfig = clientConfig;
robotLib.reco = robotLib.reco(robot.clientConfig);
robotLib.archive = robotLib.archive(robot.clientConfig);
robot.socket = io.connect(robot.clientConfig.gstreamerURL, {
transports: ['websocket']
})
......@@ -156,11 +159,35 @@ robot = {
robot.socket.on('error', (e) => {
console.log(e)
})
robot.socket.on('resume_data', (data) => {
//send data to hublin
robot.socket.on('resume_data', (event) => {
const hyp = JSON.parse(event.data);
if (hyp.status === 0) {
if (hyp.result !== undefined && hyp.result.final) {
const transcription = ((hyp.result.hypotheses)[0]).transcript;
let start;
let end;
if (hyp['segment-start'] && hyp['segment-length']) {
start = JSON.parse(hyp['segment-start']);
end = parseFloat(hyp['segment-start']) + parseFloat(hyp['segment-length']);
} else {
const time = new Date().getTime() / 1000;
start = time;
end = time + 1;
}
robotLib.reco.send({
from: robot.room,
text: start +'\t'+ end+ '\t'+ easyrtcid + '\t' + transcription
});
}
}
robotLib.reco.send({
from: robot.room,
text: start +'\t'+ end+ '\t'+ 'undefined' + '\t' + event
});
})
robotLib.reco = robotLib.reco(robot.clientConfig);
robotLib.archive = robotLib.archive(robot.clientConfig);
robotController.onAttendeePush = (e, data) => {
robotController.getMyId().then(rtcid => {
......
......@@ -55,35 +55,6 @@ module.exports = config => {
return stompCapsule;
}
function kaldiWS(connectionToClient, resume) {
const connectionToKaldi = new WebSocket(config.services.kaldi);
connectionToKaldi.on('open', () => {
const streamData = resume.generateStream();
connectionToClient.on('message', message => {
connectionToKaldi.send(message, {
binary: true
});
streamData.wstream.write(message);
});
connectionToKaldi.on('message', message => {
try {
connectionToClient.send(message);
} catch (err) {
// Sometimes, the client will close the connection unexpectedly
// (e.g. when stopping). This is expected
}
});
connectionToClient.on('close', () => connectionToKaldi.close());
connectionToKaldi.on('close', () => {
resume.endStream(streamData)
connectionToClient.close()
});
});
}
function recoChatWS(connectionToClient, stompClient) {
connectionToClient.on('message', message => {
try {
......@@ -145,6 +116,28 @@ module.exports = config => {
});
}
function kaldiWSInit(socket) {
const connectionToKaldi = new WebSocket(config.services.kaldi);
connectionToKaldi.on('open', () => {
connectionToKaldi.on('message', message => {
try {
console.log('resume ?')
console.log(message)
socket.emit('resume_data', message);
} catch (err) {
// Sometimes, the client will close the connection unexpectedly
// (e.g. when stopping). This is expected
}
});
connectionToKaldi.on('close', () => {
connectionToClient.close()
});
});
return connectionToKaldi;
}
return {
create: (resume) => {
resume.createFolder()
......@@ -165,14 +158,18 @@ module.exports = config => {
asd = {} //disconnect and kill asd sockets
})
socket.on('new_user', (userId) => {
const connectionToKaldi = kaldiWSInit()
//create ASD stream //port 8882 - connexion de data
userAudioEvents.push('audio_from_' + userId)
//asd.on("resume_data", soket.emit('resume_data'))
//register custom event for user
socket.on('audio_from_' + userId, (data) => {
console.log("DATA RECEIVED FOR USER : ", asd)
//console.log(data)
//asd.send(data)
connectionToKaldi.send(data, {
binary: true
});
})
})
});
......@@ -205,4 +202,3 @@ module.exports = config => {
}
};
};
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