Update templates/menu_page.html
Browse files- templates/menu_page.html +35 -2
templates/menu_page.html
CHANGED
@@ -73,10 +73,43 @@
|
|
73 |
});
|
74 |
}
|
75 |
|
76 |
-
//
|
77 |
-
|
|
|
|
|
|
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
</script>
|
80 |
</body>
|
81 |
</html>
|
82 |
|
|
|
|
73 |
});
|
74 |
}
|
75 |
|
76 |
+
// Function to ask user whether they want Veg or Non-Veg items
|
77 |
+
function askForMenuChoice() {
|
78 |
+
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
|
79 |
+
recognition.lang = 'en-US';
|
80 |
+
recognition.interimResults = false;
|
81 |
|
82 |
+
recognition.onresult = (event) => {
|
83 |
+
const command = event.results[0][0].transcript.toLowerCase();
|
84 |
+
if (command.includes('veg')) {
|
85 |
+
showMenu('veg');
|
86 |
+
speak('Here are the Veg items.');
|
87 |
+
} else if (command.includes('non-veg')) {
|
88 |
+
showMenu('non-veg');
|
89 |
+
speak('Here are the Non-Veg items.');
|
90 |
+
} else {
|
91 |
+
speak('Please say Veg or Non-Veg to choose the menu.');
|
92 |
+
recognition.start();
|
93 |
+
}
|
94 |
+
};
|
95 |
+
|
96 |
+
recognition.onerror = () => { speak('Sorry, I could not understand. Please try again.'); };
|
97 |
+
|
98 |
+
speak('Would you like to see the Veg or Non-Veg menu?', () => {
|
99 |
+
recognition.start();
|
100 |
+
});
|
101 |
+
}
|
102 |
+
|
103 |
+
// Speech synthesis function
|
104 |
+
function speak(text, callback) {
|
105 |
+
const msg = new SpeechSynthesisUtterance(text);
|
106 |
+
msg.onend = callback;
|
107 |
+
window.speechSynthesis.speak(msg);
|
108 |
+
}
|
109 |
+
|
110 |
+
window.onload = askForMenuChoice; // Automatically ask for menu choice when page loads
|
111 |
</script>
|
112 |
</body>
|
113 |
</html>
|
114 |
|
115 |
+
|