Compare commits
2 Commits
05bb11382d
...
e73bcc134b
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e73bcc134b | ||
![]() |
42a704a460 |
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -5,7 +5,7 @@
|
|||||||
"type": "chrome",
|
"type": "chrome",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Launch Chrome",
|
"name": "Launch Chrome",
|
||||||
"url": "http://localhost:8000",
|
"url": "https://localhost:8000",
|
||||||
"webRoot": "${workspaceFolder}/client"
|
"webRoot": "${workspaceFolder}/client"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ var SpeechRecognitionEvent = SpeechRecognitionEvent || webkitSpeechRecognitionEv
|
|||||||
// #region state management
|
// #region state management
|
||||||
var state = '';
|
var state = '';
|
||||||
var question = 0;
|
var question = 0;
|
||||||
var rePrompt = false;
|
// currently disabled feature
|
||||||
|
// var rePrompt = false;
|
||||||
var partTwo = false;
|
var partTwo = false;
|
||||||
var questionThreeCount = 0;
|
var questionThreeCount = 0;
|
||||||
var strike = 0;
|
var strike = 0;
|
||||||
@ -20,20 +21,25 @@ const QUESTION_TWO = 'Nennen Sie mir bitte so viel Dinge wie möglich, die man i
|
|||||||
const QUESTION_THREE = 'Ich werde Ihnen jetzt eine Zahlenreihe nennen, die Sie mir dann bitte in umgekehrter Reihenfolge wiederholen sollen. Wenn ich beispielsweise, vier - fünf sage, dann sagen Sie bitte, fünf - vier.';
|
const QUESTION_THREE = 'Ich werde Ihnen jetzt eine Zahlenreihe nennen, die Sie mir dann bitte in umgekehrter Reihenfolge wiederholen sollen. Wenn ich beispielsweise, vier - fünf sage, dann sagen Sie bitte, fünf - vier.';
|
||||||
const QUESTION_FOUR = 'Wir kommen nun zur vierten Frage. Bitte zählen Sie von 76 an rückwärts. Nennen Sie die Zahlen abwechselnd als ganze Zahlen und als einzelne Ziffern. Zum Beispiel:';
|
const QUESTION_FOUR = 'Wir kommen nun zur vierten Frage. Bitte zählen Sie von 76 an rückwärts. Nennen Sie die Zahlen abwechselnd als ganze Zahlen und als einzelne Ziffern. Zum Beispiel:';
|
||||||
const QUESTION_FOUR_PT2 = ['34', '3, 3', '32', '3, 1'];
|
const QUESTION_FOUR_PT2 = ['34', '3, 3', '32', '3, 1'];
|
||||||
|
const QUESTION_FIVE = 'Ganz am Anfang dieses Tests habe ich Ihnen 10 Worte genannt. Können Sie sich noch an diese Worte erinnern?';
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
|
const FINISH = 'Sie sind jetzt fertig mit dem Test, Vielen Dank.';
|
||||||
|
|
||||||
// #region intents
|
// #region intents
|
||||||
const WELCOME_INTENT = 'Default Welcome Intent';
|
const WELCOME_INTENT = 'Default Welcome Intent';
|
||||||
const WELCOME_FOLLOWUP_YES = 'Default Welcome Intent - yes';
|
const WELCOME_FOLLOWUP_YES = 'Default Welcome Intent - yes';
|
||||||
const WELCOME_FOLLOWUP_NO = 'Default Welcome Intent - no';
|
const WELCOME_FOLLOWUP_NO = 'Default Welcome Intent - no';
|
||||||
const MORE_TIME = 'Add Time Intent';
|
// currently disabled feature
|
||||||
const MORE_TIME_YES = 'Add Time Intent - yes';
|
// const MORE_TIME = 'Add Time Intent';
|
||||||
const MORE_TIME_NO = 'Add Time Intent - no';
|
// const MORE_TIME_YES = 'Add Time Intent - yes';
|
||||||
|
// const MORE_TIME_NO = 'Add Time Intent - no';
|
||||||
const QUIT_INTENT = 'Quit Intent';
|
const QUIT_INTENT = 'Quit Intent';
|
||||||
const FALLBACK_INTENT = 'Default Fallback Intent';
|
const FALLBACK_INTENT = 'Default Fallback Intent';
|
||||||
const HELP_INTENT = 'Help Intent';
|
const HELP_INTENT = 'Help Intent';
|
||||||
const CHOOSE_QUESTION = 'Frage_Starten';
|
const CHOOSE_QUESTION = 'Frage_Starten';
|
||||||
const NEXT_QUESTION = 'Nächste Frage';
|
// disabled feature
|
||||||
|
// const NEXT_QUESTION = 'Nächste Frage';
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region questions and expected results
|
// #region questions and expected results
|
||||||
@ -93,7 +99,7 @@ var questionNumDisplay = document.querySelector('.quest');
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// websocket to communicate with the server
|
// websocket to communicate with the server
|
||||||
var ws = new WebSocket('ws://' + window.location.host + window.location.pathname + 'ws');
|
var ws = new WebSocket('wss://' + window.location.host + window.location.pathname + 'ws');
|
||||||
|
|
||||||
// #region speech recognition initialization
|
// #region speech recognition initialization
|
||||||
var recognition = new SpeechRecognition();
|
var recognition = new SpeechRecognition();
|
||||||
@ -102,7 +108,7 @@ recognition.lang = 'de-DE';
|
|||||||
recognition.maxAlternatives = 1;
|
recognition.maxAlternatives = 1;
|
||||||
recognition.continuous = true;
|
recognition.continuous = true;
|
||||||
var answerQuery = '';
|
var answerQuery = '';
|
||||||
var skipRecording = false;
|
var proceedWithRecording = false;
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region speech synthesis initialization
|
// #region speech synthesis initialization
|
||||||
@ -125,23 +131,11 @@ window.speechSynthesis.onvoiceschanged = function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
speechsynth.onend = function (event) {
|
speechsynth.onend = function (event) {
|
||||||
switch (question) {
|
if (proceedWithRecording) {
|
||||||
case 1:
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!skipRecording) {
|
|
||||||
recognition.start();
|
recognition.start();
|
||||||
console.log('reocgnition started. Question: ' + question);
|
console.log('reocgnition started. Question: ' + question);
|
||||||
}
|
}
|
||||||
skipRecording = false;
|
proceedWithRecording = false;
|
||||||
diagnosticPara.textContent = '';
|
diagnosticPara.textContent = '';
|
||||||
console.log('global speech end');
|
console.log('global speech end');
|
||||||
};
|
};
|
||||||
@ -156,7 +150,6 @@ ws.onopen = function () {
|
|||||||
ws.onmessage = function (payload) {
|
ws.onmessage = function (payload) {
|
||||||
var dialogflowResult = JSON.parse(payload.data);
|
var dialogflowResult = JSON.parse(payload.data);
|
||||||
checkIntent(dialogflowResult);
|
checkIntent(dialogflowResult);
|
||||||
// document.querySelector('h1').innerHTML = dialogflowResult.intent.displayName;
|
|
||||||
};
|
};
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
@ -165,48 +158,52 @@ function checkIntent (result) {
|
|||||||
switch (result.intent.displayName) {
|
switch (result.intent.displayName) {
|
||||||
case QUIT_INTENT:
|
case QUIT_INTENT:
|
||||||
state = 'quit';
|
state = 'quit';
|
||||||
if (timerId !== undefined) {
|
stopRecognitionFallback();
|
||||||
clearTimeout(timerId);
|
|
||||||
}
|
|
||||||
skipRecording = true;
|
|
||||||
speak('Beende die Durchführung.');
|
speak('Beende die Durchführung.');
|
||||||
break;
|
break;
|
||||||
case WELCOME_INTENT:
|
case WELCOME_INTENT:
|
||||||
state = 'detect';
|
state = 'detect';
|
||||||
|
proceedWithRecording = true;
|
||||||
speak(result.fulfillmentText);
|
speak(result.fulfillmentText);
|
||||||
break;
|
break;
|
||||||
case WELCOME_FOLLOWUP_YES:
|
case WELCOME_FOLLOWUP_YES:
|
||||||
startQuestion(1);
|
startQuestion(1);
|
||||||
break;
|
break;
|
||||||
case WELCOME_FOLLOWUP_NO:
|
case WELCOME_FOLLOWUP_NO:
|
||||||
skipRecording = true;
|
speak('Alles klar. Danke fürs Benutzen.');
|
||||||
speak('Okay, Danke fürs Benutzen.');
|
|
||||||
break;
|
break;
|
||||||
case MORE_TIME:
|
/// /// /// currently disabled feature
|
||||||
state = 'detect';
|
// case MORE_TIME:
|
||||||
speak('Brauchen Sie noch etwas Zeit?');
|
// state = 'detect';
|
||||||
break;
|
// proceedWithRecording = true;
|
||||||
case MORE_TIME_YES:
|
// speak('Brauchen Sie noch etwas Zeit?');
|
||||||
rePrompt = true;
|
// break;
|
||||||
state = 'answer';
|
// case MORE_TIME_YES:
|
||||||
speak('Alles klar');
|
// rePrompt = true;
|
||||||
break;
|
// state = 'answer';
|
||||||
case MORE_TIME_NO:
|
// proceedWithRecording = true;
|
||||||
skipRecording = true;
|
// speak('Alles klar');
|
||||||
state = 'answer';
|
// break;
|
||||||
speak('Verstanden');
|
// case MORE_TIME_NO:
|
||||||
|
// state = 'answer';
|
||||||
|
// speak('Verstanden');
|
||||||
|
// recognition.stop();
|
||||||
|
// ws.send(answerQuery);
|
||||||
|
// break;
|
||||||
|
// case CHOOSE_QUESTION:
|
||||||
|
// question = result.parameters.fields.num.numberValue;
|
||||||
|
// state = 'answer';
|
||||||
|
// handleQuestion();
|
||||||
|
// break;
|
||||||
|
/// /// ///
|
||||||
|
case HELP_INTENT:
|
||||||
|
stopRecognitionFallback();
|
||||||
recognition.stop();
|
recognition.stop();
|
||||||
ws.send(answerQuery);
|
startQuestion(question);
|
||||||
break;
|
|
||||||
case CHOOSE_QUESTION:
|
|
||||||
question = result.parameters.fields.num.numberValue;
|
|
||||||
state = 'answer';
|
|
||||||
handleQuestion();
|
|
||||||
break;
|
break;
|
||||||
case FALLBACK_INTENT:
|
case FALLBACK_INTENT:
|
||||||
// if (state === 'answer') {
|
// fallback what should happen if no intent is detected
|
||||||
// handleAnswer(result.queryText)
|
// this is handled in the processSpeech() function
|
||||||
// }
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -217,6 +214,7 @@ function checkIntent (result) {
|
|||||||
function startQuestion (number) {
|
function startQuestion (number) {
|
||||||
question = number;
|
question = number;
|
||||||
state = 'answer';
|
state = 'answer';
|
||||||
|
answerQuery = '';
|
||||||
questionNumDisplay.textContent = 'Question: ' + question;
|
questionNumDisplay.textContent = 'Question: ' + question;
|
||||||
handleQuestion();
|
handleQuestion();
|
||||||
}
|
}
|
||||||
@ -224,9 +222,7 @@ function startQuestion (number) {
|
|||||||
function handleQuestion () {
|
function handleQuestion () {
|
||||||
switch (question) {
|
switch (question) {
|
||||||
case 1:
|
case 1:
|
||||||
skipRecording = true;
|
readQuestionOne(QUESTION_ONE);
|
||||||
speak(QUESTION_ONE);
|
|
||||||
readQuestionOne();
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
readQuestionTwo();
|
readQuestionTwo();
|
||||||
@ -238,11 +234,14 @@ function handleQuestion () {
|
|||||||
readQuestionFour();
|
readQuestionFour();
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
|
proceedWithRecording = true;
|
||||||
|
speak(QUESTION_FIVE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function readQuestionOne () {
|
function readQuestionOne (questionText) {
|
||||||
|
speak(questionText);
|
||||||
for (let i = 0; i < QUESTION_ONE_QUESTIONS.length; i++) {
|
for (let i = 0; i < QUESTION_ONE_QUESTIONS.length; i++) {
|
||||||
let utterance = new SpeechSynthesisUtterance();
|
let utterance = new SpeechSynthesisUtterance();
|
||||||
utterance.voice = voices[2];
|
utterance.voice = voices[2];
|
||||||
@ -280,7 +279,6 @@ function readQuestionTwo () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function readQuestionThree () {
|
function readQuestionThree () {
|
||||||
skipRecording = true;
|
|
||||||
speak('Dankeschön, weiter geht es mit der nächsten Frage.');
|
speak('Dankeschön, weiter geht es mit der nächsten Frage.');
|
||||||
let utterance = new SpeechSynthesisUtterance();
|
let utterance = new SpeechSynthesisUtterance();
|
||||||
utterance.voice = voices[2];
|
utterance.voice = voices[2];
|
||||||
@ -288,13 +286,13 @@ function readQuestionThree () {
|
|||||||
utterance.rate = 0.88;
|
utterance.rate = 0.88;
|
||||||
window.speechSynthesis.speak(utterance);
|
window.speechSynthesis.speak(utterance);
|
||||||
utterance.onend = function (event) {
|
utterance.onend = function (event) {
|
||||||
|
proceedWithRecording = true;
|
||||||
speak(QUESTION_THREE_QUESTIONS_PT1[questionThreeCount]);
|
speak(QUESTION_THREE_QUESTIONS_PT1[questionThreeCount]);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function readQuestionFour () {
|
function readQuestionFour () {
|
||||||
// skipRecording = true;
|
speak(QUESTION_FOUR);
|
||||||
// speak(QUESTION_FOUR);
|
|
||||||
for (let i = 0; i < QUESTION_FOUR_PT2.length; i++) {
|
for (let i = 0; i < QUESTION_FOUR_PT2.length; i++) {
|
||||||
let utterance = new SpeechSynthesisUtterance();
|
let utterance = new SpeechSynthesisUtterance();
|
||||||
utterance.voice = voices[2];
|
utterance.voice = voices[2];
|
||||||
@ -302,7 +300,7 @@ function readQuestionFour () {
|
|||||||
utterance.text = QUESTION_FOUR_PT2[i];
|
utterance.text = QUESTION_FOUR_PT2[i];
|
||||||
window.speechSynthesis.speak(utterance);
|
window.speechSynthesis.speak(utterance);
|
||||||
}
|
}
|
||||||
// speak('Sie haben hierfür 1 Minute Zeit.');
|
speak('Sie haben hierfür 1 Minute Zeit.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAnswer (query) {
|
function handleAnswer (query) {
|
||||||
@ -317,37 +315,33 @@ function handleAnswer (query) {
|
|||||||
handleAnswerToThirdQuestion(query);
|
handleAnswerToThirdQuestion(query);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
|
// not possible with the current state of web speech api
|
||||||
|
// handleAnswerToFourthQuestion(query);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
|
handleAnswerToFifthQuestion(query);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAnswerToFirstQuestion (answer) {
|
function handleAnswerToFirstQuestion (answer) {
|
||||||
var tokens = answer.split(new RegExp(separators.join('|'), 'g'));
|
deconstructAndCalculateAnswer(answer);
|
||||||
questionPoints[question] += calculatePoints(tokens, QUESTION_ONE_ANSWERS);
|
|
||||||
if (partTwo) {
|
if (partTwo) {
|
||||||
partTwo = false;
|
partTwo = false;
|
||||||
console.log('question 1 points: ' + questionPoints[question]);
|
|
||||||
skipRecording = true;
|
|
||||||
speak('Vielen Dank, nun geht es weiter mit der nächsten Frage');
|
speak('Vielen Dank, nun geht es weiter mit der nächsten Frage');
|
||||||
startQuestion(2);
|
startQuestion(2);
|
||||||
// state = 'detect'
|
|
||||||
} else {
|
} else {
|
||||||
rePrompt = false;
|
// currently disabled feature
|
||||||
skipRecording = true;
|
// rePrompt = false;
|
||||||
speak(QUESTION_ONE_PT2);
|
speak(QUESTION_ONE_PT2);
|
||||||
readQuestionOne(QUESTION_ONE);
|
readQuestionOne(QUESTION_ONE_PT2);
|
||||||
partTwo = true;
|
partTwo = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAnswerToSecondQuestion (answer) {
|
function handleAnswerToSecondQuestion (answer) {
|
||||||
var tokens = answer.split(new RegExp(separators.join('|'), 'g'));
|
deconstructAndCalculateAnswer(answer);
|
||||||
questionPoints[question] = calculatePoints(tokens, QUESTION_TWO_ANSWERS);
|
|
||||||
console.log('question 2 points: ' + questionPoints[question]);
|
|
||||||
startQuestion(3);
|
startQuestion(3);
|
||||||
// state = 'detect'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAnswerToThirdQuestion (query) {
|
function handleAnswerToThirdQuestion (query) {
|
||||||
@ -376,41 +370,58 @@ function handleAnswerToThirdQuestion (query) {
|
|||||||
if (strike === 2 || questionThreeCount === 5) {
|
if (strike === 2 || questionThreeCount === 5) {
|
||||||
speechsynth.rate = 0.88;
|
speechsynth.rate = 0.88;
|
||||||
console.log('question 3 points: ' + questionPoints[question]);
|
console.log('question 3 points: ' + questionPoints[question]);
|
||||||
skipRecording = true;
|
|
||||||
speak('weiter geht es mit der Nächsten Frage');
|
speak('weiter geht es mit der Nächsten Frage');
|
||||||
startQuestion(4);
|
// Question 4 is not possible to take, because of technical limitation
|
||||||
|
// startQuestion(4);
|
||||||
|
|
||||||
|
startQuestion(5);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
proceedWithRecording = true;
|
||||||
speak(questionArray[questionThreeCount]);
|
speak(questionArray[questionThreeCount]);
|
||||||
|
|
||||||
console.log('count: ' + questionThreeCount + ', strike: ' + strike + ', points: ' + questionPoints[question]);
|
console.log('count: ' + questionThreeCount + ', strike: ' + strike + ', points: ' + questionPoints[question]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// not possible with the current state of web speech api
|
||||||
|
// function handleAnswerToFourthQuestion (answer) {
|
||||||
|
// // In order to evaluate the answer, the recognizer has to distinguish between the number 77 spoken "seventy seven" and 7-7 spoken "seven seven", which it doesnt
|
||||||
|
// startQuestion(5);
|
||||||
|
// }
|
||||||
|
|
||||||
|
function handleAnswerToFifthQuestion (answer) {
|
||||||
|
deconstructAndCalculateAnswer(answer);
|
||||||
|
speak(FINISH);
|
||||||
|
}
|
||||||
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
|
// NOT SUPPORTED
|
||||||
// function recognizeSpeech () {
|
// function recognizeSpeech () {
|
||||||
// if (state === 'answer') {
|
|
||||||
// var arr;
|
// var arr;
|
||||||
// switch (question) {
|
// switch (question) {
|
||||||
// case 1:
|
// case 1:
|
||||||
// arr = QUESTION_ONE_QUESTIONS;
|
// arr = QUESTION_ONE_QUESTIONS;
|
||||||
// break;
|
// break;
|
||||||
// case 2:
|
// case 2:
|
||||||
// // arr = QUESTION_TWO_QUESTIONS;
|
// arr = QUESTION_TWO_QUESTIONS;
|
||||||
// break;
|
// break;
|
||||||
// case 3:
|
// case 3:
|
||||||
// arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
// arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||||
// break;
|
// break;
|
||||||
// case 4:
|
// case 4:
|
||||||
|
// arr = ['eins', 'zwei', 'drei', 'vier', 'fünf', 'sechs', 'sieben', 'acht', 'neun'];
|
||||||
// break;
|
// break;
|
||||||
// case 5:
|
// case 5:
|
||||||
// break;
|
// break;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// // var grammar = '#JSGF V1.0; grammar colors; public <color> = ' + arr.join(' | ') + ' ;';
|
// var grammar = '#JSGF V1.0; grammar arr; public <arr> = ' + arr.join(' | ') + ' ;';
|
||||||
// // var speechRecognitionList = new SpeechGrammarList();
|
// var speechRecognitionList = new SpeechGrammarList();
|
||||||
// // speechRecognitionList.addFromString(grammar, 1);
|
// speechRecognitionList.addFromString(grammar, 1);
|
||||||
// // recognition.grammars = speechRecognitionList;
|
// recognition.grammars = speechRecognitionList;
|
||||||
|
|
||||||
|
// recognition.start();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// #region speech recognition event
|
// #region speech recognition event
|
||||||
@ -506,18 +517,16 @@ function processSpeech (speechResult) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state === 'answer') {
|
if (state === 'answer') {
|
||||||
if (timerId != undefined) {
|
stopRecognitionFallback();
|
||||||
clearTimeout(timerId);
|
|
||||||
}
|
|
||||||
answerQuery += speechResult;
|
answerQuery += speechResult;
|
||||||
timerId = window.setTimeout(
|
timerId = window.setTimeout(
|
||||||
function () {
|
function () {
|
||||||
|
// currently disabled
|
||||||
// if (!rePrompt) {
|
// if (!rePrompt) {
|
||||||
// ws.send('ich brauche noch etwas Zeit')
|
// ws.send('ich brauche noch etwas Zeit')
|
||||||
// } else {
|
// } else {
|
||||||
console.log('recording end. Evaluate: ' + answerQuery);
|
console.log('recording end. Evaluate: ' + answerQuery);
|
||||||
handleAnswer(answerQuery);
|
handleAnswer(answerQuery);
|
||||||
answerQuery = '';
|
|
||||||
diagnosticPara.textContent = '';
|
diagnosticPara.textContent = '';
|
||||||
// }
|
// }
|
||||||
recognition.stop();
|
recognition.stop();
|
||||||
@ -539,14 +548,7 @@ function startDemenzScreening () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testSpeechOut () {
|
function testSpeechOut () {
|
||||||
readQuestionFour();
|
question = 4;
|
||||||
|
|
||||||
// speechsynth.text = 'test 123';
|
|
||||||
// speechsynth.volume = 1;
|
|
||||||
// speechsynth.rate = 1;
|
|
||||||
// console.log(speechsynth);
|
|
||||||
// window.speechSynthesis.speak(speechsynth);
|
|
||||||
// console.log(window.speechSynthesis);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function speak (sentence) {
|
function speak (sentence) {
|
||||||
@ -554,6 +556,29 @@ function speak (sentence) {
|
|||||||
window.speechSynthesis.speak(speechsynth);
|
window.speechSynthesis.speak(speechsynth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stopRecognitionFallback () {
|
||||||
|
if (timerId != undefined) {
|
||||||
|
clearTimeout(timerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function deconstructAndCalculateAnswer (answer) {
|
||||||
|
let questionAnswers;
|
||||||
|
switch (question) {
|
||||||
|
case 1:
|
||||||
|
questionAnswers = QUESTION_ONE_ANSWERS;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
questionAnswers = QUESTION_TWO_ANSWERS;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
questionAnswers = QUESTION_ONE_ANSWERS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
var tokens = answer.split(new RegExp(separators.join('|'), 'g'));
|
||||||
|
questionPoints[question] += calculatePoints(tokens, questionAnswers);
|
||||||
|
}
|
||||||
|
|
||||||
function calculatePoints (tokens, d) {
|
function calculatePoints (tokens, d) {
|
||||||
let points = 0;
|
let points = 0;
|
||||||
let dict = {};
|
let dict = {};
|
||||||
|
23
server/cert.pem
Normal file
23
server/cert.pem
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIID1zCCAr8CFFQdsOqUqVpXkNcENXj66TeS6crHMA0GCSqGSIb3DQEBCwUAMIGn
|
||||||
|
MQswCQYDVQQGEwJERTEQMA4GA1UECAwHQkFWQVJJQTESMBAGA1UEBwwJTlVSRU1C
|
||||||
|
RVJHMQwwCgY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LFpZCm0C8w
|
||||||
|
uWq4Uc+PzuJ/QTM6Yz4TJJzni/XzZT1lyxz07XQDlvJj1ex8ifyDPXqGcwaGrZ/Z
|
||||||
|
b+iBvTF1KbaYSZ6RB8jr2BH8HWk3gdGtndThnKxaDv5101LUoVYZR3TqsTxLpAoG
|
||||||
|
dTNwZtGRD5jg9r0icjsUV1yH2ZieouJZECi7Oia2cZ6iIJqio2ARuPEP/H3vbwFM
|
||||||
|
Juy1ZC1b1X7dRGZigTQqBE7By38yXg4Y++BU
|
||||||
|
-----END CERTIFICATE-----
|
27
server/key.pem
Normal file
27
server/key.pem
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIIEogIBAAKCAQEA56EWGyHlMUIuMn8YgSafG+a6tMq42o0lD1bYdxepXtzwrAkj
|
||||||
|
4o+3WBMzA8fhlo1giF2V20gl0lAsB4qj4BBW9RjwFjdxegRIu9bGbmHwYzUgUuGv
|
||||||
|
UJVNgfxXsIfwFh7umlh5cR2vVR1KfO8doYpXP0VfFdlIILl41G5tvKXkvgB61LE2
|
||||||
|
D8jkBwX71OLSw5qEJP3gGmvhOdxoOf56KY6tDHvPMLiTrK4W6cZXIcw0IPuHt9VT
|
||||||
|
VfApk8Amq+QWTup3szdoGfnDANZrbip+SsRneXPgGSvf6uv3+RefBrZNqCLadUjp
|
||||||
|
jRyqlCxjnvHhUtDzn/dy5DvYw2rY5ylqtgGPPQIDAQABAoIBAHr9tw47JkbMnFkl
|
||||||
|
0W4qgsu+7R64kgVCcw49D/3Uq5N6f7TpuYtAwpravvjf9rIJaduezca8/ZA6D9cF
|
||||||
|
T9TW+EV2s20ojXG7up87AOx1xr325K39tih0zs4ZnrpWxC4KyKleF0Xv/DyWrAnA
|
||||||
|
shwnqAIppL6mPD1cHoO2C0DjWZ1lAzG3pjs5ipEa6Z5csWsHJlv8i12da1Zjhr+4
|
||||||
|
GoBTyUcQFzegf/RlyJC/5yEyydoD82XD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ClVpkOefMM+1mj5U+xdq/mM+LNPQvALENsbE=
|
||||||
|
-----END RSA PRIVATE KEY-----
|
@ -3,7 +3,9 @@ const dialogflow = require('dialogflow');
|
|||||||
|
|
||||||
// server and websocket
|
// server and websocket
|
||||||
const WebSocket = require('ws');
|
const WebSocket = require('ws');
|
||||||
|
var fs = require('fs');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
|
const https = require('https');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
|
|
||||||
@ -20,7 +22,11 @@ app.use(express.static(__dirname + '/../client'));
|
|||||||
|
|
||||||
app.use('/', router);
|
app.use('/', router);
|
||||||
|
|
||||||
var server = http.createServer(app);
|
// var server = http.createServer(app);
|
||||||
|
var server = https.createServer({
|
||||||
|
key: fs.readFileSync('key.pem'),
|
||||||
|
cert: fs.readFileSync('cert.pem')
|
||||||
|
}, app);
|
||||||
|
|
||||||
server.listen(process.env.port || webSocketsServerPort, function () {
|
server.listen(process.env.port || webSocketsServerPort, function () {
|
||||||
console.log((new Date()) + ' Server is listening on port ' +
|
console.log((new Date()) + ' Server is listening on port ' +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user