JSFiddle - React, Tailwind, and code Playground

by juberti

HTML

<button onclick="speak('hi')">
Hi
</button>

JavaScript

function speak(text) {
	var msg = new SpeechSynthesisUtterance();
  var voice = null;// findVoice('Google US English');
  if (voice != null) {
    msg.voice = voice;
  }
	msg.text = text;
	window.speechSynthesis.speak(msg);
  msg.onstart = event => {
    console.log(timestamp() + 'Synthesis started');
  };
  msg.onend = event => {    
    console.log(timestamp() + 'Synthesis finished');
    startRecognition();
  };
}