Skip to content

Instantly share code, notes, and snippets.

@mvilrokx
Created January 21, 2015 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvilrokx/b4504ef1af4ba0e097da to your computer and use it in GitHub Desktop.
Save mvilrokx/b4504ef1af4ba0e097da to your computer and use it in GitHub Desktop.
Calling the HTML5 Speech Synthesis API
if ($("#speech").is(':checked')) {
window.speechSynthesis.cancel(); // Cancel if already talking
var msg = new SpeechSynthesisUtterance(event.target.innerText); // Grab the text from the element that was clicked ...
window.speechSynthesis.speak(msg); // ... and speak it.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment