Last active
December 15, 2020 16:30
-
-
Save codyromano/14db6dacb63ada130af8dd2980770b69 to your computer and use it in GitHub Desktop.
Practice public speaking by counting how many filler words you use during presentations
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
/* | |
Using Google Chrome on your desktop (not mobile): | |
1. Copy all of this | |
2. Go to a *different* webpage (any webpage) | |
3. In the top bar, click "View" > "Developer" > "JavaScript Console" | |
A prompt will appear asking you to choose filler words and how long you want to speak. | |
*/ | |
(function countHowManyTimesIUsedFillerWordsDuringAMeeting(fillerWords, secondsToRecord) { | |
const speech = new (window.SpeechRecognition || window.webkitSpeechRecognition)(); | |
Object.assign(speech, { continous: true, interimResults: false }); | |
const findFillerWords = new RegExp(`(${fillerWords.toLowerCase().replace(/,/g, '|')})`, 'g'); | |
speech.addEventListener('result', ({ results }) => { | |
const transcript = (results ? Array.from(results) : []).reduce((allText, item) => { | |
return allText + (item[0] ? item[0].transcript.toLowerCase() : ''); | |
}, '') || ''; | |
const fillerWords = transcript.match(findFillerWords) || []; | |
console.log(` | |
I think you said: | |
"${transcript}" | |
For a grand total of ${fillerWords.length} filler words...${fillerWords.join(', ')} | |
`); | |
}); | |
speech.start(); | |
setTimeout(() => speech.stop(), parseInt(secondsToRecord, 10) * 1000); | |
}( | |
prompt('Which filler words are you trying to avoid?', 'um,so,like'), | |
prompt('For how many seconds do you want to speak?', 5), | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment