Last active
August 9, 2019 17:38
-
-
Save jojijacobk/588eb95d771f323dfee163c326b1c003 to your computer and use it in GitHub Desktop.
To simulate speech from browser using all the voices installed in your computer
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
// To simulate speech from browser using all the voices installed in your computer | |
Array.from(window.speechSynthesis.getVoices()).forEach(voice => { | |
console.log(voice); | |
const msg = new SpeechSynthesisUtterance(); | |
msg.voice = voice; // 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 = 2; // 0 to 2 | |
msg.text = 'Hello World'; | |
msg.lang = 'en-US'; | |
msg.onend = function onend(event) { | |
console.log(`Finished in ${event.elapsedTime} seconds.`); | |
}; | |
window.speechSynthesis.speak(msg); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment