JSFiddle - React, Tailwind, and code Playground
HTML
<button onclick="speakNow()">Speak now</button>
JavaScript
function speakNow() {
const message = new SpeechSynthesisUtterance("Hi! This is an example of the Speech Synthesis API");
message.lang = "en-US";
const voices = speechSynthesis.getVoices().filter(voice => voice.lang === "en-US");
message.voice = voices[0];
speechSynthesis.speak(message);
}