Skip to content

Instantly share code, notes, and snippets.

@fitsum
Last active April 26, 2024 05:18
Show Gist options
  • Save fitsum/044198807412ca88ce7fe1a5d7d6d25c to your computer and use it in GitHub Desktop.
Save fitsum/044198807412ca88ce7fe1a5d7d6d25c to your computer and use it in GitHub Desktop.
speaks english voices in given browsers
speakEnglish = () => { voices = speechSynthesis.getVoices(); voices.filter(voice => voice.lang === "en-US" ).forEach(voice => {
const utterance = new SpeechSynthesisUtterance("What's poppin, bitches?")
utterance.voice = voice;
// default volume !== 1
utterance.volume = 1;
speechSynthesis.speak(utterance);
// next line causes function not to fire on first invocation 🤷🏾‍♂️
utterance.addEventListener('start',()=>{console.log('voice name:', voice.name)})
}) }
speakEnglish()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment