Skip to content

Commit

Permalink
Merged the NLP system with the PATHWiSE interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
anistuhin committed Feb 4, 2025
1 parent bda72d6 commit 66213ee
Show file tree
Hide file tree
Showing 63 changed files with 4,319 additions and 2,484 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
web/build
nlp/best_model.pt
nlp/google_creds.js
nlp/pathnlp
231 changes: 105 additions & 126 deletions assets/articles.js
Original file line number Diff line number Diff line change
@@ -1,80 +1,7 @@
if (localStorage.getItem("auth") == null) {
localStorage.setItem("auth", "true");
}
var articleList = [];
var groups = [{
'name': 'Group 1',
'id': 'group-1',
'password': 'test1',
'articles': [{
'title': 'Cold Nose Article',
'filename': 'cold_nose_article'
},
{
'title': 'Exoplanet Article',
'filename': 'exoplanet_article'
},
{
'title': 'Osmosis Article',
'filename': 'osmosis_article'
}
]
},
{
'name': 'Group 2',
'id': 'group-2',
'password': 'test2',
'articles': [{
'title': 'Frogs Evaluation Article',
'filename': 'frogs_evolution_article'
},
{
'title': 'Soils & Nutrient Cycle',
'filename': 'table_readings_1'
},
{
'title': 'Earthworms Article',
'filename': 'table_readings_2'
}
]
}, {
'name': 'Group 3',
'id': 'group-3',
'password': 'test3',
'articles': [{
'title': 'Consume vs Consumed',
'filename': 'table_readings_3'
},
{
'title': 'An Alive Bug?',
'filename': 'table_readings_4'
},
{
'title': 'Nitrogen Cycle',
'filename': 'table_readings_5'
}
]
}, {
'name': 'Group 4',
'id': 'group-4',
'password': 'test4',
'articles': [{
'title': 'Carbon Cycle',
'filename': 'table_readings_6'
},
{
'title': 'Recycling the Dead',
'filename': 'table_readings_7'
},
{
'title': 'Gut Bacteria',
'filename': 'table_readings_8'
}
]
}
];

var articles = [{
var articleLibrary = [{
'title': 'Doctor with an eye for eyes',
'filename': 'doctor-with-an-eye-for-eyes'
},
Expand Down Expand Up @@ -113,59 +40,112 @@ var articles = [{
{
'title': 'The Camping Trip',
'filename': 'the-camping-trip'
},
{
'title': 'Cold Nose Article',
'filename': 'cold_nose_article',
'from': new Date('2025-01-31T10:00:00'),
'to': new Date('2025-01-31T16:30:00')
},
{
'title': 'Exoplanet Article',
'filename': 'exoplanet_article',
'from': new Date('2024-12-20T16:31:00'),
'to': new Date('2024-12-21T16:30:00')
},
{
'title': 'Osmosis Article',
'filename': 'osmosis_article',
'from': new Date('2024-12-22T16:31:00'),
'to': new Date('2024-12-23T16:30:00')
},
{
'title': 'Frogs Evaluation Article',
'filename': 'frogs_evolution_article'
},
{
'title': 'Soils & Nutrient Cycle',
'filename': 'table_readings_1'
},
{
'title': 'Earthworms Article',
'filename': 'table_readings_2'
},
{
'title': 'Consume vs Consumed',
'filename': 'table_readings_3'
},
{
'title': 'An Alive Bug?',
'filename': 'table_readings_4'
},
{
'title': 'Nitrogen Cycle',
'filename': 'table_readings_5'
},
{
'title': 'Carbon Cycle',
'filename': 'table_readings_6'
},
{
'title': 'Recycling the Dead',
'filename': 'table_readings_7'
},
{
'title': 'Gut Bacteria',
'filename': 'table_readings_8'
}
];

// var articles = [{
// 'title': 'Cold Nose Article',
// 'filename': 'cold_nose_article'
// },
// {
// 'title': 'Exoplanet Article',
// 'filename': 'exoplanet_article'
// },
// {
// 'title': 'Osmosis Article',
// 'filename': 'osmosis_article'
// },
// {
// 'title': 'Frogs Evaluation Article',
// 'filename': 'frogs_evolution_article'
// },
// {
// 'title': 'Soils & Nutrient Cycle',
// 'filename': 'table_readings_1'
// },
// {
// 'title': 'Earthworms Article',
// 'filename': 'table_readings_2'
// },
// {
// 'title': 'Consume vs Consumed',
// 'filename': 'table_readings_3'
// },
// {
// 'title': 'An Alive Bug?',
// 'filename': 'table_readings_4'
// },
// {
// 'title': 'Nitrogen Cycle',
// 'filename': 'table_readings_5'
// },
// {
// 'title': 'Carbon Cycle',
// 'filename': 'table_readings_6'
// },
// {
// 'title': 'Recycling the Dead',
// 'filename': 'table_readings_7'
// },
// {
// 'title': 'Gut Bacteria',
// 'filename': 'table_readings_8'
// }
// ];

var articleList = [];
var groups = [{
'name': 'Group 1',
'id': 'group-1',
'password': 'test1',
'articles': [articleLibrary[10], articleLibrary[11], articleLibrary[12]]
},
{
'name': 'Group 2',
'id': 'group-2',
'password': 'test2',
'articles': [articleLibrary[13], articleLibrary[14], articleLibrary[15]]
}, {
'name': 'Group 3',
'id': 'group-3',
'password': 'test3',
'articles': [articleLibrary[16], articleLibrary[17], articleLibrary[18]]
}, {
'name': 'Group 4',
'id': 'group-4',
'password': 'test4',
'articles': [articleLibrary[19], articleLibrary[20], articleLibrary[21]]
}
];
var articles = [
articleLibrary[0],
articleLibrary[1],
articleLibrary[2],
articleLibrary[3],
articleLibrary[4],
articleLibrary[5],
articleLibrary[6],
articleLibrary[7],
articleLibrary[8],
articleLibrary[9]
];
var articlesPrev = [
articleLibrary[10],
articleLibrary[11],
articleLibrary[12],
articleLibrary[13],
articleLibrary[14],
articleLibrary[15],
articleLibrary[16],
articleLibrary[17],
articleLibrary[18],
articleLibrary[19],
articleLibrary[20],
articleLibrary[21]
];
if (localStorage.getItem("auth") == "guest") {
articleList = articles;
} else {
Expand All @@ -175,7 +155,6 @@ if (localStorage.getItem("auth") == "guest") {
}
});
}

if (localStorage.getItem("currentArticle") === null) {
localStorage.setItem("currentArticle", articleList[0].filename);
localStorage.setItem("currentArticleTitle", articleList[0].title);
Expand Down
Binary file added assets/images/nlp/Listening.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/nlp/speaking.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/nlp/transitioning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions assets/main-working.js
Original file line number Diff line number Diff line change
Expand Up @@ -1207,10 +1207,9 @@
$.post(fetchUrl, { 'fetch': fetchData }, function(result, success) {
if (success == 'success') {
var response = JSON.parse(result);
if (response.status && $('.student-robot-facing').length) {
if (response.status) {
//$('#resume').removeClass('temporary-hidden');
$('#pins-data').text(response.pins);
recreateCanvas();
}
} else {
console.log('Something went wrong from fetching the latest data!');
Expand All @@ -1231,6 +1230,7 @@
);
});
$(".teacher-facing #article-menu p span").text(localStorage.getItem("currentArticleTitle"));
$(".student-robot-facing #article-menu p span").text(localStorage.getItem("currentArticleTitle"));
$("#assignment-title").text(localStorage.getItem("currentArticleTitle"));
window.pathArticleTitle = localStorage.getItem("currentArticleTitle");
$.each(emotionsList, function(i, v) {
Expand Down
48 changes: 27 additions & 21 deletions assets/robot-play.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(function($) {
var misty_IP = '192.168.0.111';
var misty_IP = '10.0.0.221';
var behaviors = {
"spooked": "SL 500\nFI eyes_terror.jpg\nFL true\nAU teethChatter.mp3\nTL 0 0 0 170 0 255 breathe 1220\nMH 0 10 0 90\nMT -75 0 500\nMAS 90 100 90 100\nMH 0 5 -2 100\nSL 100\nMAS 80 100 80 100\nMH 0 5 2 100\nMH 0 5 -2 100\nMH 0 5 2 100\nMAS 90 100 90 100\nMH 0 5 -2 100\nSL 100\nMAS 80 100 80 100",
"boredom": "SL 500\nFI eyes_boredom.jpg\nTL 0 0 0 47 0 255 breathe 3474\nMH -20 0 -5 100\nMAS 90 90 90 90",
Expand Down Expand Up @@ -112,30 +112,22 @@

$(document).ready(function() {
setTimeout(function() {
var fetchUrl = "/validate/",
fetchData = {};
fetchData.group = localStorage.getItem("auth").trim();
fetchData.article = localStorage.getItem("currentArticleTitle").trim();
$.post(fetchUrl, { 'fetch': fetchData }, function(result, success) {
if (success == 'success') {
var response = JSON.parse(result);
console.log(response);
if (response.status && $('.student-robot-facing').length) {
$('#pins-data').text(response.pins);
recreateCanvas();
}
} else {
console.log('Something went wrong from fetching the latest data!');
}
});
if ($('.student-robot-facing').length || $('.student-computer-facing').length) {
recreateCanvas();
}
}, 150);

$(document).on("click", '.cp', function() {
var $this = $(this);
setTimeout(function() {
var text = $this.attr('data-comment');
var emotion = emotionsList[$this.attr('data-emotion')];
sendToRobot(text, emotion);
var emotion = $this.attr('data-emotion');
var behavior = emotionsList[emotion];
if ($('.student-robot-facing').length) {
sendToRobot(text, behavior);
} else if ($('.student-computer-facing').length) {
playInComputer(text, emotion);
}
}, 150);
});
});
Expand Down Expand Up @@ -165,8 +157,8 @@
});
}

function sendToRobot(text, emotion) {
executeBehavior(emotion);
function sendToRobot(text, behavior) {
executeBehavior(behavior);
Promise.race([
fetch('http://' + misty_IP + '/api/tts/speak', {
method: 'POST',
Expand All @@ -177,4 +169,18 @@
.then(response => response.json())
.then(jsonData => console.log(jsonData));
}

function playInComputer(text, emotion) {
$(document).find('#selected-emotion > ul li[data-id="' + emotion + '"]').click();
var msg = new SpeechSynthesisUtterance();
var voices = window.speechSynthesis.getVoices();
msg.voice = voices[1];
msg.voiceURI = "native";
msg.volume = 1;
msg.rate = 0.9;
msg.pitch = 1.4;
msg.text = text;
msg.lang = "en-US";
speechSynthesis.speak(msg);
}
})(window.jQuery);
22 changes: 22 additions & 0 deletions assets/sec/certificate.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDrzCCApegAwIBAgIUFSyqpBBxC0jriQztv4XdUxxMUB8wDQYJKoZIhvcNAQEF
BQAwZjELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAklMMRAwDgYDVQQHDAdDaGljYWdv
MRQwEgYDVQQKDAtVSUMgTElUIExhYjEiMCAGCSqGSIb3DQEJARYTYW5pc3R1aGlu
QGdtYWlsLmNvbTAgFw0yNDEyMjAyMTM5NTBaGA8yMTI0MTEyNjIxMzk1MFowZjEL
MAkGA1UEBhMCVVMxCzAJBgNVBAgMAklMMRAwDgYDVQQHDAdDaGljYWdvMRQwEgYD
VQQKDAtVSUMgTElUIExhYjEiMCAGCSqGSIb3DQEJARYTYW5pc3R1aGluQGdtYWls
LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANdhFfwK8AjlcJcs
WnulK1eDE8RO7m2zzbBTsJF0G/NkarRyVd9RETQI9ctOslxGBAbEKMLQY3mb1JHT
24EriHBLlOMncLtM/tMQ7fmPY+PkLbafHS2ToEkZpERRd3PWawKj3W2NFN6foBID
4uwhqWtR8gdwUFPSuzwqqpAZ3LfPwKK16iHodW8qfVchadG29puHuj9CXryYPOR7
ECmJ+dAg0NKkZvxU9Ep3wxjdOzw/+Hq0kPiJkqdmcFYA3vZAo9zzTyFq5cO4yRGI
8hxpDHFEjgnY1PKFt36Rr1cwHqqMdbkbri3AJ3aIXWee5DFTh2/myq/vqx6VpRTU
RuEsprkCAwEAAaNTMFEwHQYDVR0OBBYEFFfW66xchxkiKC45WBcdjPFkdQtiMB8G
A1UdIwQYMBaAFFfW66xchxkiKC45WBcdjPFkdQtiMA8GA1UdEwEB/wQFMAMBAf8w
DQYJKoZIhvcNAQEFBQADggEBAA6p7ntDPqxYcXJsPxPxFx7e8toGI75gsXgkh7dD
qKtYcaDuBUwCCtuqbav6l5Em+qu3hO7p5pWCmHrgfcGpRVxZaKiGQs9nLzGpZSeJ
v4iiLaC2cEw88pyE4ui2gBT23TGEwAN2L+AmMnFQZczsQKxWrJzMcxpfOuQ2Khn+
G2hXuQiJTUEh/ELU4b5xGTYOHrWiMYPGTEABiOAHBmyNy3K9nLJT1WpyedTx6SUA
p0CybTdlIu6E2ftm2eEp3naYnaiTartboMLyxRDi0uLNNIRao1IWTQf2OsHck7le
8Fbo+5LzUE6pqVOyFbYAsiD1odARrZfmcMGXtZWAPvsD+04=
-----END CERTIFICATE-----
Loading

0 comments on commit 66213ee

Please sign in to comment.