Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Why does a SpeechSynthesisUtterance sometimes not fire an 'end' event in Chromium-based browsers?
// https://stackoverflow.com/questions/54861046/why-does-a-speechsynthesisutterance-sometimes-not-fire-an-end-event-in-chromiu#
const button = document.createElement('button');
const arr = [];
button.innerHTML = 'click';
document.body.appendChild(button);
button.onclick = () => {
console.log('start script');
// button.disabled = true;
const utt = new SpeechSynthesisUtterance('e');
utt.addEventListener('end', () => {
arr.push('end event triggered at ' + new Date().getTime());
console.log(arr[arr.length-1], arr.length);
});
// just for debugging completeness, no errors seem to be thrown though
utt.addEventListener('error', (err) => {
console.log('err', err)
});
speechSynthesis.speak(utt);
setTimeout(() => {
console.log('finished?');
}, 1500);
};
@guest271314

This comment has been minimized.

Copy link
Owner Author

commented Mar 8, 2019

@Kaiido Cannot reproduce at 72.0.3626.121. Is the issue console printing the same message on the same line?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.