Open janluke opened 4 years ago
Can you explain where this code is?
Sorry, I was very unclear. I'm referring to SpeechRecognitionEvent
when listening also for interim results. I opened this issue in May, so I don't remember if I looked into your code, but I'd say you probably just forget to initialize event.resultIndex
. I wrote this code in May (read the comment):
/**
* @param event: a SpeechRecognitionEvent
*/
function handleSpeechRecognitionEvent(checker, event) {
/* [event.resultIndex] is the index of the first element in [event.results] that has changed,
* which is [length - 1] most of the times given that user speaks a word at a time.
* event.resultIndex is always undefined when using the microsoft wrapper library; probably a bug.
* @TODO: just set [startIndex] to [event.resultIndex] when the bug is solved
*/
let lastIndex = event.results.length - 1;
let startIndex = (event.resultIndex !== undefined) ? event.resultIndex : lastIndex;
...
If the event is always about the last result, why not setting it to
length(event.results) - 1
?