I have been experimenting with SpeechRecognition to incorporate microphone functionality into one of my projects.
However, when I check the Chrome Console, it displays the error message: Unexpected end of input
const speechRecognition =
window.webkitSpeechRecognition /*Chrome*/ ||
window.SpeechRecognition;/*Firefox...*/
function startListening() {
const recog = new speechRecognition
recog.start();
recog.onstart = console.log("Started Listening..");
recog.onresult = function (data) {
handleResults(data);
};
//'data' comes from 'onresult'
function handleResults(data) {
let text = data.result[0][0].transcript;
console.log(text);
}
// Function Call On Page Load
window.addEventListener('DOMContentLoaded', startListening());