Skip to content

Instantly share code, notes, and snippets.

@Orbis25
Last active December 5, 2019 19:47
Show Gist options
  • Save Orbis25/c996c5ea2e19021a6d79a16481621758 to your computer and use it in GitHub Desktop.
Save Orbis25/c996c5ea2e19021a6d79a16481621758 to your computer and use it in GitHub Desktop.
Text to spech example usin api from javaScript (speaknowjs)
const synth = window.speechSynthesis;
const readText = (
text = "FELICIDADES"
) => {
voices = synth.getVoices();
event.preventDefault();
let utterThis = new SpeechSynthesisUtterance(text);
var selectedOption = "Google español de Estados Unidos";
for (i = 0; i < voices.length; i++) {
if (voices[i].name === selectedOption) {
utterThis.voice = voices[i];
}
}
synth.speak(utterThis);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment