Skip to content

Instantly share code, notes, and snippets.

@macedo
Created January 27, 2021 18:52
Show Gist options
  • Save macedo/2fa0a9433650a75a7b74f0706e4d00d3 to your computer and use it in GitHub Desktop.
Save macedo/2fa0a9433650a75a7b74f0706e4d00d3 to your computer and use it in GitHub Desktop.
<script>
speechRecognition = new webkitSpeechRecognition();
speechRecognition.continuous = true;
speechRecognition.lang = 'pt-br';
speechRecognition.interimResults = true;
speechRecognition.start();
speechRecognition.onresult = function (event) {
if (typeof (event.results) == 'undefined') {
speechRecognition.stop();
return;
}
for (var i = event.resultIndex; i < event.results.length; ++i) {
if (event.results[i].isFinal) {
let speech_text = event.results[i][0].transcript
alert(speech_text);
}
}
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment