Commit 1a6859b3 authored by Yoann HOUPERT's avatar Yoann HOUPERT

read stream

parent e7df7352
...@@ -32,12 +32,18 @@ robot = { ...@@ -32,12 +32,18 @@ robot = {
previousReco: [], previousReco: [],
recordedParticipantsWS: undefined, recordedParticipantsWS: undefined,
participantsMediaRecorders: {}, participantsMediaRecorders: {},
participantsStream: {},
isDisconnected: false, isDisconnected: false,
intervalList: [], intervalList: [],
speakerId : {}, speakerId: {},
processAudio(stream, callback, interval) { processAudio(stream, callback, interval) {
const mediaRecorder = new MediaRecorder(stream); var options = {
video : false,
mimeType : 'audio/webm'
}
const mediaRecorder = new MediaRecorder(stream, options);
mediaRecorder.ondataavailable = callback; mediaRecorder.ondataavailable = callback;
mediaRecorder.start(interval); mediaRecorder.start(interval);
...@@ -92,18 +98,18 @@ robot = { ...@@ -92,18 +98,18 @@ robot = {
}, },
openSTTSocket() { openSTTSocket() {
if(robot.recordedParticipantsWS === undefined){ if (robot.recordedParticipantsWS === undefined) {
const ws = robotLib.stt.getTranscriptSocket(e => { const ws = robotLib.stt.getTranscriptSocket(e => {
console.log('> ' + e.text); console.log('> ' + e.text);
robotLib.reco.send( robotLib.reco.send(
{ {
from: robot.room, from: robot.room,
text: e.from + '\t' + e.until + '\t' + speakerId + '\t' + e.text text: e.from + '\t' + e.until + '\t' + robot.speakerId + '\t' + e.text
}); });
}); });
ws.addEventListener('error', e => { ws.addEventListener('error', e => {
// Try to open new connection on error // Try to open new connection on error
console.error('STT ws for ' + easyrtcid + ' error. Trying to reopen'); console.error('STT ws for ' + robot.speakerId + ' error. Trying to reopen');
console.error(e); console.error(e);
robot.openSTTSocket(); robot.openSTTSocket();
}); });
...@@ -120,13 +126,45 @@ robot = { ...@@ -120,13 +126,45 @@ robot = {
}); });
}, },
audioGenerator(easyrtcid, e) { activityVoiceDetection() {
speakerId = easyrtcid; const keyMap = Object.keys(robot.participantsStream)
robot.recordedParticipantsWS.send(e.data);
let selectedStream;
if (keyMap) {
for (let i = 0; i < keyMap.length; i++) {
console.log('easyrtcid keyList value', keyMap[i]);
selectedStream = robot.participantsStream[keyMap[i]].shift();
robot.speakerId = keyMap[i];
}
}
/*
var arrayBuffer;
var fileReader = new FileReader();
fileReader.onload = function() {
arrayBuffer = this.result;
var byteArray = new Int16Array(arrayBuffer);
for (var i = 0; i < byteArray.byteLength; i++) {
// do something with each byte in the array
}
};
fileReader.readAsArrayBuffer(blob);*/
return selectedStream;
}, },
audioGenerator(easyrtcid, e) {
robot.participantsStream[easyrtcid].push(e.data);
const selectedStream = robot.activityVoiceDetection();
robot.recordedParticipantsWS.send(selectedStream);
},
recordParticipant(easyrtcid) { recordParticipant(easyrtcid) {
if (robot.participantsStream[easyrtcid] === undefined) {
robot.participantsStream[easyrtcid] = [];
}
robot.openSTTSocket(); robot.openSTTSocket();
robot.getUserStream(easyrtcid); robot.getUserStream(easyrtcid);
}, },
...@@ -178,7 +216,7 @@ robot = { ...@@ -178,7 +216,7 @@ robot = {
}); });
}; };
robotController.onAttendeeRemove = (e, data) => { robotController.onAttendeeRemove = e => {
robot.checkDisconnect(); robot.checkDisconnect();
}; };
......
...@@ -13,8 +13,11 @@ ...@@ -13,8 +13,11 @@
"webdriver-stop": "./bin/webdriver-stop" "webdriver-stop": "./bin/webdriver-stop"
}, },
"dependencies": { "dependencies": {
"@ffmpeg-installer/ffmpeg": "^1.0.13",
"@ffprobe-installer/ffprobe": "^1.0.8",
"body-parser": "^1.18.2", "body-parser": "^1.18.2",
"express": "^4.16.2", "express": "^4.16.2",
"fluent-ffmpeg": "^2.1.2",
"mz": "2.6.0", "mz": "2.6.0",
"puppeteer": "0.12.0", "puppeteer": "0.12.0",
"sockjs-client": "1.1.4", "sockjs-client": "1.1.4",
......
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