Spaces:
Sleeping
Sleeping
File size: 1,191 Bytes
b38ab69 e0313d1 b38ab69 f5c4e30 b38ab69 e0313d1 b38ab69 e0313d1 f5c4e30 e0313d1 b38ab69 e0313d1 b38ab69 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
window.onload = function () {
window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
if (!window.SpeechRecognition) {
alert("Your browser does not support Speech Recognition. Please use Chrome.");
return;
}
const recognition = new SpeechRecognition();
recognition.continuous = true;
recognition.lang = "en-US";
function startListening() {
recognition.start();
let statusElement = document.getElementById("status");
if (statusElement) {
statusElement.innerText = "Listening for 'Hi Biriyani Hub'...";
}
}
recognition.onresult = function (event) {
let transcript = event.results[event.results.length - 1][0].transcript.toLowerCase();
console.log("You said:", transcript);
if (transcript.includes("hi biriyani hub")) {
console.log("Wake word detected! Redirecting to landing page...");
window.location.href = "/landing"; // Redirects to landing page
}
};
recognition.onerror = function (event) {
console.error("Speech recognition error:", event.error);
};
startListening();
};
|