Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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