I have a questionnaire of 6 questions. These are presented through speechSynthesis. After each question, I need to wait for an oral response that I will process, before presenting the next question. My code is an attempt at it. Code DOES go through the callback. But, how to process the logic sequentially, 'state question', 'listen', 'state next question', 'listen'...
//..ToDo: Because we need verbal response for each question,
//.. we need to change the recognition.onResult call back
function processPromptedInteraction(event)
{
var speechToText = event.results[0][0].transcript;
if (speechToText.includes('yes'))
{ }
else if (speechToText.includes('no'))
{ }
else
{ }
}
var strQuestion = '';
for (i = 0; i < questions[i].length; i++)
{
recognition.onresult = processPromptedInteraction; //.. Callback function
strQuestion = questions[i].question;
say(strQuestion);
}