Commit 37327664 authored by Tom JORQUERA's avatar Tom JORQUERA
Browse files

Merge branch 'issue-15' into 'master'

implement reco behavior

Closes #15

See merge request !21
parents 0b37d60f ed9d275d
......@@ -39,6 +39,16 @@ robotController = {
return res;
},
sendMessage: (author, authorAvatar, message) => {
robotController.chatService.sendMessage({
author,
authorAvatar,
message,
displayName: author,
published: new Date()
});
},
onAttendeePush: () => {},
onAttendeeRemove: () => {},
onAttendeeUpdate: () => {}
......
......@@ -5,6 +5,7 @@
/* global robot:true robotController robotLib MediaRecorder */
/* exported robot */
const room = arguments[0];
const config = arguments[1];
robotController.external.load(config);
......@@ -19,14 +20,63 @@ robot = {
mediaRecorder.start(interval);
return mediaRecorder;
},
processReco(reco) {
reco = JSON.parse(reco);
let formattedReco = '';
if (reco.keywords && reco.keywords.length > 0) {
formattedReco += '<h5>Mots-Clés</h5> ';
for (let i = 0; i < reco.keywords.length; i++) {
formattedReco += reco.keywords[i].key + ', ';
}
// Remove last ', '
formattedReco = formattedReco.substring(0, formattedReco.length - 2);
}
if (reco.wikiarticles && reco.wikiarticles.length > 0) {
formattedReco += '<h5>Wikipedia</h5>';
for (let i = 0; i < reco.wikiarticles.length && i < 5; i++) {
formattedReco += '<p><a href="' + encodeURI(reco.wikiarticles[i].link) + '" target="_blank">' + reco.wikiarticles[i].title + '</a>';
}
}
if (reco.soArticles && reco.soArticles.length > 0) {
formattedReco += '<h5>StackOverflow</h5>';
for (let i = 0; i < reco.soArticles.length && i < 5; i++) {
formattedReco += '<p><a href="' + encodeURI(reco.soArticles[i].link) + '" target="_blank">' + reco.soArticles[i].title + '</a>';
}
}
console.log(formattedReco);
if (formattedReco !== '') {
robotController.sendMessage(config.name, config.avatar, formattedReco);
}
},
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));
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);
};
robotLib.reco.start(room);
setInterval(
() => robotLib.reco.getOnlineReco(room)
.then(robot.processReco)
.catch(console.error),
8000);
}
};
......@@ -33,6 +33,10 @@ describe('client/robot', () => {
}
})
}),
reco: () => ({
start: () => {},
getOnlineReco: () => new Promise(() => {}, () => {})
}),
archive: () => ({})
};
......
......@@ -20,6 +20,7 @@
},
"client": {
"name": "hublot",
"avatar": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEoAAABECAYAAAAm2qMBAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4QYNDTU7dwT3OwAABUtJREFUeNrtnF1oHFUUx38zjUlabWKtELU3WLQPFrSOgopaRawmIZdqLVTtQ1R8sVqsH9SvQptKBaWF6oMiLYhUKiLYtMVOGqu0Kgnq260txQejEIZU0BRrqsaQZH2YO3Hczu7Ofszs1/xhyWaZPXvnN+fOPffcc8cgBlm2g5LCe38xcBtgAdcAi4HLgUuAi4BG/bVJ4BxwBhgFfgZ+ABQwpKQYT7cdpYyY4KwCHgDuB1pL9BNjwEFgv5LiUNTQogTVCTwF3Ec86gPeVlIciwKaEQGgp4HtQDPl0TiwUUmxu5TAjBJ2r2eAt6gcpYAnlRS7LNsBKAqYUSwky3Y6gAPAXCpTfwArlRRfF+NdRhGA5gH7gC6qQ33AWj2a5g3MKBDSzcB32r2NKgGV0q8blBTf5/tlswBImzQkqgiS11YTOG7ZznrvnErqUT5I+4DV1IY+UFI8Gva+ZeQBaUhH1LWkz5UUHWFgGSEhfQPcUmVdLayOKilW5IJlhIA0AHTUKCRPnygp1hTjUTuB56gPbVZSvFaIR3UCA9SXblVSfBsKlB4ym4AJ6lNGUEB6XhylD/iiTiGlgM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YuGnbN4i2jqHUeklJsT02UD5gjbhFYr0VlAnIpUXAaEnCgwKhdQHrgU7gggoG9SvuAsZ0NlhmhA0YUFKsBFpwH7K1R480lTZaXgqMkOMhPLFkMtMen9QO3AhcjVuRvAR39Wc+7nJUObwvBZwF7s703JZ/AccI0dMbvIyTAAAAAElFTkSuQmCC",
"gstreamerURL": "ws://localhost:8888",
"externalLibs": [
"https://cdnjs.cloudflare.com/ajax/libs/sockjs-client/1.1.4/sockjs.min.js",
......
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