Last active
March 15, 2020 13:24
-
-
Save IpsumLorem16/44da5a57d85760f13c81ef5c30f5806b to your computer and use it in GitHub Desktop.
Test of the 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
//should speak in a british voice | |
// https://developers.google.com/web/updates/2014/01/Web-apps-that-talk-Introduction-to-the-Speech-Synthesis-API | |
var msg = new SpeechSynthesisUtterance(); | |
var voices = window.speechSynthesis.getVoices(); | |
msg.voice = voices[4]; // Note: some voices don't support altering params | |
msg.voiceURI = 'native'; | |
msg.volume = 1; // 0 to 1 | |
msg.rate = 1; // 0.1 to 10 | |
msg.pitch = 1; //0 to 2 | |
msg.text = ' This is a test'; | |
msg.lang = 'en-US'; | |
msg.onend = function(e) { | |
console.log('Finished in ' + event.elapsedTime + ' seconds.'); | |
}; | |
speechSynthesis.speak(msg); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment