lokesh341 commited on
Commit
d0995d3
·
verified ·
1 Parent(s): 01a053e

Update templates/menu_page.html

Browse files
Files changed (1) hide show
  1. templates/menu_page.html +34 -7
templates/menu_page.html CHANGED
@@ -19,10 +19,6 @@
19
  <body>
20
  <div class="menu-container">
21
  <h1>Welcome to the Menu</h1>
22
- <div class="menu-option">
23
- <button onclick="showMenu('veg')">Veg Items</button>
24
- <button onclick="showMenu('non-veg')">Non-Veg Items</button>
25
- </div>
26
  <div id="menu-items"></div>
27
  </div>
28
 
@@ -77,10 +73,41 @@
77
  });
78
  }
79
 
80
- // Initially load Veg items automatically
81
- showMenu('veg');
 
 
 
82
 
83
- // Optional: Speech synthesis or interaction to ask user to choose Veg or Non-Veg
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  </script>
85
  </body>
86
  </html>
 
19
  <body>
20
  <div class="menu-container">
21
  <h1>Welcome to the Menu</h1>
 
 
 
 
22
  <div id="menu-items"></div>
23
  </div>
24
 
 
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>