Created
January 21, 2015 21:58
-
-
Save mvilrokx/b4504ef1af4ba0e097da to your computer and use it in GitHub Desktop.
Calling the HTML5 Speech Synthesis API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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