Skip to content

Instantly share code, notes, and snippets.

@kiichi
Last active March 16, 2020 21:35
Show Gist options
  • Save kiichi/ac4404cd0f5f85fccecf55dad4584bd9 to your computer and use it in GitHub Desktop.
Save kiichi/ac4404cd0f5f85fccecf55dad4584bd9 to your computer and use it in GitHub Desktop.
Text to Speech Using Chrome API (Speech Synthesis)
// This takes time... keep the voice reference somewhere before clicking on something
let voice_type = speechSynthesis.getVoices().find(function(voice) { return voice.name == 'Samantha'; });
// e.g. after click event
var msg = new SpeechSynthesisUtterance();
msg.voice = voice_type;
msg.text = "Awesome!";
msg.rate = 1.4;
msg.pitch = 3.0;
window.speechSynthesis.speak(msg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment