Commit 8ba31799 authored by Tom Jorquera's avatar Tom Jorquera
Browse files

client: robot now records already present participants on start

robot now checks for participants that have already joined the room and record
them on start.
parent dd9db325
......@@ -54,22 +54,27 @@ robot = {
}
},
recordParticipant(easyrtcid) {
const stream = robotController.getRemoteStream(easyrtcid);
const ws = robotLib.stt.getTranscriptSocket(e => {
console.log('> ' + e.text);
robotLib.reco.send(
{
from: room,
text: e.from + '\t' + e.until + '\t' + easyrtcid + '\t' + e.text
});
});
robot.processAudio(stream, e => ws.send(e.data), 100);
robot.recordedParticipants[easyrtcid] = ws;
},
start: () => {
robotLib.stt = robotLib.stt(config);
robotLib.reco = robotLib.reco(config);
robotLib.archive = robotLib.archive(config);
robotController.onAttendeePush = (e, data) => {
const stream = robotController.getRemoteStream(data.easyrtcid);
const ws = robotLib.stt.getTranscriptSocket(e => {
console.log('> ' + e.text);
robotLib.reco.send(
{
from: room,
text: e.from + '\t' + e.until + '\t' + data.easyrtcid + '\t' + e.text
});
});
robot.processAudio(stream, e => ws.send(e.data), 100);
robot.recordParticipant(data.easyrtcid);
};
robotLib.reco.start(room);
......@@ -78,5 +83,8 @@ robot = {
.then(robot.processReco)
.catch(console.error),
8000);
// Record current participants already present in the room
robotController.getParticipants().map(robot.recordParticipant);
}
};
......@@ -13,14 +13,16 @@ describe('client/robot', () => {
this.interval = interval;
}
};
global.MediaRecorder.instance = res;
global.MediaRecorder.instances[stream.id] = res;
return res;
};
global.MediaRecorder.instances = {};
global.robotController = {
external: {
load: () => {}
},
getParticipants: () => ['someid1', 'someid2'],
getRemoteStream: id => ({type: 'RemoteStream', id})
};
......@@ -73,12 +75,24 @@ describe('client/robot', () => {
expect(callbackCalled).toBe('somedata');
});
test('should start transcribing users already present on `start`', () => {
global.robot.start();
const e1 = {data: 'somedata1'};
global.MediaRecorder.instances.someid1.ondataavailable(e1);
expect(global.robotLib.sttDataSent[0]).toBe(e1.data);
const e2 = {data: 'somedata2'};
global.MediaRecorder.instances.someid2.ondataavailable(e2);
expect(global.robotLib.sttDataSent[1]).toBe(e2.data);
});
test('should start transcribing stream on user connection after `start`', () => {
global.robot.start();
global.robotController.onAttendeePush({}, {easyrtcid: 'testid'});
const e = {data: 'somedata'};
global.MediaRecorder.instance.ondataavailable(e);
global.MediaRecorder.instances.testid.ondataavailable(e);
expect(global.robotLib.sttDataSent[0]).toBe(e.data);
});
});
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