lokesh341 commited on
Commit
73a9cb8
·
verified ·
1 Parent(s): 1ea5871

Update templates/menu_page.html

Browse files
Files changed (1) hide show
  1. templates/menu_page.html +50 -3
templates/menu_page.html CHANGED
@@ -10,6 +10,7 @@
10
  background-color: #f8f8f8;
11
  margin: 0;
12
  padding: 0;
 
13
  }
14
  .container {
15
  max-width: 1200px;
@@ -90,8 +91,8 @@
90
  <div class="container" id="welcome-container">
91
  <h1>Welcome to the Biryani Hub Menu</h1>
92
  <div class="menu-option">
93
- <button onclick="showMenu('veg')">Vegetarian Menu</button>
94
- <button onclick="showMenu('nonVeg')">Non-Vegetarian Menu</button>
95
  </div>
96
  </div>
97
 
@@ -132,7 +133,20 @@
132
 
133
  const cart = [];
134
 
135
- // Function to show the menu based on selected type
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  function showMenu(type) {
137
  // Hide the welcome screen and show the menu
138
  document.getElementById('welcome-container').style.display = 'none';
@@ -195,6 +209,39 @@
195
  alert("Your cart is empty. Please add items before placing the order.");
196
  }
197
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  </script>
199
 
200
  </body>
 
10
  background-color: #f8f8f8;
11
  margin: 0;
12
  padding: 0;
13
+ text-align: center;
14
  }
15
  .container {
16
  max-width: 1200px;
 
91
  <div class="container" id="welcome-container">
92
  <h1>Welcome to the Biryani Hub Menu</h1>
93
  <div class="menu-option">
94
+ <button id="veg-btn" onclick="showMenu('veg')">Vegetarian Menu</button>
95
+ <button id="non-veg-btn" onclick="showMenu('nonVeg')">Non-Vegetarian Menu</button>
96
  </div>
97
  </div>
98
 
 
133
 
134
  const cart = [];
135
 
136
+ // Speech Synthesis and Speech Recognition
137
+ const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
138
+ recognition.lang = 'en-US';
139
+ recognition.interimResults = false;
140
+ recognition.maxAlternatives = 1;
141
+
142
+ // Function to speak text
143
+ function speak(text, callback) {
144
+ const msg = new SpeechSynthesisUtterance(text);
145
+ msg.onend = callback;
146
+ window.speechSynthesis.speak(msg);
147
+ }
148
+
149
+ // Function to show the menu based on selected type (veg or non-veg)
150
  function showMenu(type) {
151
  // Hide the welcome screen and show the menu
152
  document.getElementById('welcome-container').style.display = 'none';
 
209
  alert("Your cart is empty. Please add items before placing the order.");
210
  }
211
  }
212
+
213
+ // Function to start voice recognition
214
+ function startVoiceRecognition() {
215
+ recognition.start();
216
+ }
217
+
218
+ // Speech recognition logic
219
+ recognition.onresult = (event) => {
220
+ const command = event.results[0][0].transcript.toLowerCase();
221
+ if (command.includes('vegetarian')) {
222
+ showMenu('veg');
223
+ speak("Here are the vegetarian items.", () => {});
224
+ } else if (command.includes('non-vegetarian')) {
225
+ showMenu('nonVeg');
226
+ speak("Here are the non-vegetarian items.", () => {});
227
+ } else {
228
+ speak("Please say vegetarian or non-vegetarian.", () => {
229
+ recognition.start();
230
+ });
231
+ }
232
+ };
233
+
234
+ recognition.onerror = (event) => {
235
+ console.error("Speech recognition error:", event.error);
236
+ speak("Sorry, I couldn't understand that. Please try again.", () => recognition.start());
237
+ };
238
+
239
+ // Welcome message and voice prompt when the page loads
240
+ window.onload = () => {
241
+ speak("Welcome to the Biryani Hub menu. Please say vegetarian or non-vegetarian to choose your menu.", () => {
242
+ startVoiceRecognition();
243
+ });
244
+ };
245
  </script>
246
 
247
  </body>