Skip to content

Instantly share code, notes, and snippets.

@sloev
Last active November 9, 2023 09:16
Show Gist options
  • Save sloev/1d3520da4ee0f91f835307b2c1d199de to your computer and use it in GitHub Desktop.
Save sloev/1d3520da4ee0f91f835307b2c1d199de to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<body>
<button id="button">play greeting</button>
<script>
const greeting = () => {
window.speechSynthesis.onvoiceschanged = function () {
window.speechSynthesis.cancel();
window.speechSynthesis.getVoices();
["This is the Central Scrutinizer. Joe has just worked himself into an imaginary frenzy",
"During the fade-out of his imaginary song. He begins to feel depressed now",
"He knows the end is near. He has realized at last, that imaginary guitar notes, and imaginary vocals, exist only in the imagination of the imaginer!",
"And. ultimately, who gives a fuck anyway? So. ",
"Excuse me. HaHa! Who gives a fuck anyway?",
"So he goes back to his ugly little room. And quietly dreams his last imaginary guitar solo.",
"lyric to Watermelon in Easter Hay by Frank Zappa"
].map(text=>{
var msg = new SpeechSynthesisUtterance(text)
msg.rate = 0.9;
msg.pitch = 0.1;
msg.lang = 'en';
msg.voice = window.speechSynthesis.getVoices().filter(function (voice) {
return voice.name == "Google UK English Female"
})[0];
window.speechSynthesis.speak(msg);
});
}
};
document.querySelector('button').addEventListener('click', () => {
greeting()
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment