Created
April 10, 2020 15:31
-
-
Save alfredfrancis/005991853d6dd5fb324112f3e41e11c8 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
if (window.hasOwnProperty('webkitSpeechRecognition')) { | |
$(".mic-chat").css({ opacity: 1 }) | |
var SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; | |
var recognition = new SpeechRecognition(); | |
recognition.continuous = false; | |
recognition.interimResults = false; | |
recognition.lang = "en-IN"; | |
recognition.start(); | |
recognition.onresult = (e) => { | |
recognition.stop(); | |
$(".mic-chat").css({ opacity: .6 }) | |
console.log(e.results) | |
// set text | |
setTimeout(this.sendText(e.results[0][0].transcript), 1000); | |
}; | |
recognition.onerror = function (e) { | |
recognition.stop(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment