Skip to content

Instantly share code, notes, and snippets.

@ornicar
Created April 26, 2019 12:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ornicar/43f8ff810d92a8c6d82ed3242f7528d4 to your computer and use it in GitHub Desktop.
Save ornicar/43f8ff810d92a8c6d82ed3242f7528d4 to your computer and use it in GitHub Desktop.
<html>
<head>
<style>
body {
font-family: 'Noto Sans';
overflow: hidden;
}
input {
width: 100%;
}
</style>
</head>
<body>
<input autofocus />
<div class="last"></div>
<script>
window.onload = () => {
const last = document.querySelector('.last');
function say(txt) {
const voice = speechSynthesis.getVoices().filter(voice => voice.name == 'Google UK English Male')[0];
const msg = new SpeechSynthesisUtterance(txt);
msg.voice = voice;
window.speechSynthesis.speak(msg);
last.textContent = txt;
}
document.querySelector('input').onkeypress = function(e) {
if (e.keyCode == '13') {
var txt = e.target.value
.replace(/atm/, ' at the moment ')
.replace(/idk/, ' i don\'t know ')
.replace(/wtf/, ' what the fuck ')
.replace(/tysub /, ' thank you so much for the sub ')
.replace(/brb/, ' be right back ')
.replace(/gtg/, 'I\'ve got to go')
.replace(/asap/, ' as soon as possible ')
.replace(/\bty\b/, 'thank you')
.replace(/\bofc\b/g, ' of course ')
.replace(/\bikr\b/g, ' i know right ')
.replace(/\bnp\b/g, ' no problem ')
.replace(/\bpita\b/g, ' pain in the arse ')
.replace(/\bnvm\b/g, ' nevermind ')
.replace(/cba/, ' i can\'t be arsed ');
switch(txt) {
case 'dust':
txt = 'Another bug bites the dust!';
break;
case 'next':
txt = 'Let\s move on to the next bug.';
break;
case 'deploy':
txt = 'Deploying to lichess.dev';
break;
case 'deployed':
txt = 'lichess.dev has been updated.';
break;
case 'hello':
txt = 'Hello and welcome to the stream. I\'m coding lichess v2.';
break;
case 'account':
txt = 'You can create a new account on lichess.dev. No email confirmation required.';
break;
case 'brb':
txt = 'I will be right back.';
break;
case 'mic':
txt = 'Microphone check. 1 2 1 2';
break;
case 'setup':
txt = 'I run neo vim. in i3. in archlinux';
break;
case 'tournament':
txt = 'Please join the tournament! Link in the stream chat.';
break;
case 'song':
txt = 'The current song is displayed at the bottom of the screen.';
break;
case 'when':
txt = 'lichess v2 will be released when it\'s ready. I don\'t know when that will happen. Could be 2 weeks, or 2 months.';
bbreak;
}
if (txt) say(txt);
// else say('battle station operational');
e.target.value = '';
}
}
};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment