Created
January 27, 2021 18:52
-
-
Save macedo/2fa0a9433650a75a7b74f0706e4d00d3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<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