JSFiddle - React, Tailwind, and code Playground
JavaScript
//speechSynthesis.cancel()
var u = new SpeechSynthesisUtterance();
var voices = speechSynthesis.getVoices();
u.voice = voices[0];
console.log(voices);
u.text = 'Hello World';
u.onstart = function (event) {
console.log('Started');
};
u.onend = function (event) {
console.log('Ended');
};
u.onpause = function(event) {
console.log('Paused');
};
u.onresume = function(event) {
console.log('Resumed');
};
setInterval(function(){if(window.speechSynthesis.paused)
console.log("Now it's paused");},100);
setTimeout(function(){speechSynthesis.speak(u);},2000);
setTimeout(function(){speechSynthesis.pause();},3000);
setTimeout(function(){speechSynthesis.resume();},6000);
console.log(u);