Spaces:
Running
Running
Update templates/index.html
Browse files- templates/index.html +214 -73
templates/index.html
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
<head>
|
5 |
<meta charset="UTF-8">
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
-
<title>Biryani Hub
|
8 |
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
|
9 |
<style>
|
10 |
body {
|
@@ -18,11 +18,16 @@
|
|
18 |
text-align: center;
|
19 |
}
|
20 |
.container {
|
21 |
-
background-color: #
|
22 |
padding: 40px 50px;
|
23 |
border-radius: 10px;
|
24 |
-
width:
|
25 |
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
|
|
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
h1 {
|
28 |
font-size: 30px;
|
@@ -35,8 +40,9 @@
|
|
35 |
display: block;
|
36 |
text-align: left;
|
37 |
font-weight: bold;
|
|
|
38 |
}
|
39 |
-
input[type="text"]
|
40 |
width: 100%;
|
41 |
padding: 12px;
|
42 |
font-size: 16px;
|
@@ -44,8 +50,9 @@
|
|
44 |
border-radius: 8px;
|
45 |
margin-top: 8px;
|
46 |
box-sizing: border-box;
|
|
|
47 |
}
|
48 |
-
input:focus {
|
49 |
border-color: #ff6a00;
|
50 |
outline: none;
|
51 |
}
|
@@ -60,27 +67,97 @@
|
|
60 |
color: gray;
|
61 |
margin-top: 20px;
|
62 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
</style>
|
64 |
</head>
|
65 |
<body>
|
66 |
<div class="container">
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
</div>
|
78 |
|
79 |
<script>
|
80 |
let recognition;
|
|
|
81 |
let emailCaptured = "";
|
82 |
let mobileCaptured = "";
|
83 |
-
|
84 |
if ('webkitSpeechRecognition' in window) {
|
85 |
recognition = new webkitSpeechRecognition();
|
86 |
recognition.continuous = false;
|
@@ -89,87 +166,151 @@
|
|
89 |
} else {
|
90 |
alert("Speech Recognition API is not supported in this browser.");
|
91 |
}
|
92 |
-
|
93 |
function speak(text, callback) {
|
94 |
const speech = new SpeechSynthesisUtterance(text);
|
95 |
speech.onend = callback;
|
96 |
window.speechSynthesis.speak(speech);
|
97 |
}
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
function startListeningForEmail() {
|
100 |
recognition.start();
|
101 |
recognition.onresult = function(event) {
|
102 |
emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
103 |
document.getElementById('email').value = emailCaptured;
|
104 |
recognition.stop();
|
105 |
-
speak("You said " + emailCaptured + ". Is it correct?",
|
106 |
-
recognition.start();
|
107 |
-
recognition.onresult = function(event) {
|
108 |
-
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
109 |
-
recognition.stop();
|
110 |
-
if (confirmation.includes("ok") || confirmation.includes("Next")) {
|
111 |
-
setTimeout(() => speak("Great! Now, tell me your mobile number.", startListeningForMobile), 500);
|
112 |
-
} else {
|
113 |
-
speak("Let's try again. Tell me your email.", startListeningForEmail);
|
114 |
-
}
|
115 |
-
};
|
116 |
-
});
|
117 |
};
|
118 |
}
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
function startListeningForMobile() {
|
121 |
recognition.start();
|
122 |
recognition.onresult = function(event) {
|
123 |
mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
124 |
document.getElementById('mobile').value = mobileCaptured;
|
125 |
recognition.stop();
|
126 |
-
speak("You said " + mobileCaptured + ". Is it correct?",
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
email: emailCaptured,
|
141 |
-
mobile: mobileCaptured
|
142 |
-
})
|
143 |
-
}).then(response => response.json())
|
144 |
-
.then(data => {
|
145 |
-
if (data.success) {
|
146 |
-
speak("Login successful. Welcome!", function() {
|
147 |
-
window.location.href = "https://huggingface.co/spaces/Subbu1304/AIVoice4s"; // Redirects to menu page
|
148 |
-
});
|
149 |
-
} else {
|
150 |
-
speak(data.error || "Invalid credentials. Please try again.", function() {});
|
151 |
-
}
|
152 |
-
});
|
153 |
-
});
|
154 |
-
} else {
|
155 |
-
speak("Let's try again. Tell me your mobile number.", startListeningForMobile);
|
156 |
-
}
|
157 |
-
};
|
158 |
-
});
|
159 |
};
|
160 |
}
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
});
|
168 |
}
|
169 |
-
|
170 |
window.onload = function () {
|
171 |
-
|
172 |
};
|
173 |
</script>
|
174 |
</body>
|
175 |
-
</html>
|
|
|
4 |
<head>
|
5 |
<meta charset="UTF-8">
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<title>Biryani Hub - Register & Login</title>
|
8 |
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
|
9 |
<style>
|
10 |
body {
|
|
|
18 |
text-align: center;
|
19 |
}
|
20 |
.container {
|
21 |
+
background-color: #fff;
|
22 |
padding: 40px 50px;
|
23 |
border-radius: 10px;
|
24 |
+
width: 500px;
|
25 |
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
|
26 |
+
display: flex;
|
27 |
+
justify-content: space-between;
|
28 |
+
}
|
29 |
+
.form-container {
|
30 |
+
width: 48%;
|
31 |
}
|
32 |
h1 {
|
33 |
font-size: 30px;
|
|
|
40 |
display: block;
|
41 |
text-align: left;
|
42 |
font-weight: bold;
|
43 |
+
color: #333;
|
44 |
}
|
45 |
+
input[type="text"] {
|
46 |
width: 100%;
|
47 |
padding: 12px;
|
48 |
font-size: 16px;
|
|
|
50 |
border-radius: 8px;
|
51 |
margin-top: 8px;
|
52 |
box-sizing: border-box;
|
53 |
+
background-color: #f9f9f9;
|
54 |
}
|
55 |
+
input[type="text"]:focus {
|
56 |
border-color: #ff6a00;
|
57 |
outline: none;
|
58 |
}
|
|
|
67 |
color: gray;
|
68 |
margin-top: 20px;
|
69 |
}
|
70 |
+
.header {
|
71 |
+
font-size: 24px;
|
72 |
+
font-weight: bold;
|
73 |
+
color: #ff6a00;
|
74 |
+
margin-bottom: 20px;
|
75 |
+
}
|
76 |
+
.form-section {
|
77 |
+
padding: 20px;
|
78 |
+
background-color: #f9f9f9;
|
79 |
+
border-radius: 10px;
|
80 |
+
}
|
81 |
+
#confirmation {
|
82 |
+
display: none;
|
83 |
+
margin-top: 20px;
|
84 |
+
background-color: #f9f9f9;
|
85 |
+
padding: 20px;
|
86 |
+
border-radius: 10px;
|
87 |
+
}
|
88 |
+
#confirmation h2 {
|
89 |
+
font-size: 20px;
|
90 |
+
font-weight: bold;
|
91 |
+
}
|
92 |
+
.confirm-details {
|
93 |
+
margin: 10px 0;
|
94 |
+
}
|
95 |
+
.confirm-button {
|
96 |
+
padding: 10px 20px;
|
97 |
+
background-color: #ff6a00;
|
98 |
+
color: white;
|
99 |
+
border: none;
|
100 |
+
border-radius: 5px;
|
101 |
+
cursor: pointer;
|
102 |
+
}
|
103 |
+
.confirm-button:hover {
|
104 |
+
background-color: #e65e00;
|
105 |
+
}
|
106 |
</style>
|
107 |
</head>
|
108 |
<body>
|
109 |
<div class="container">
|
110 |
+
<!-- Register Section -->
|
111 |
+
<div class="form-container" id="registrationForm">
|
112 |
+
<h1>Welcome to Biryani Hub 🍽 🍗</h1>
|
113 |
+
<div class="form-section">
|
114 |
+
<h2 class="header">Register</h2>
|
115 |
+
<label for="name">Your Name</label>
|
116 |
+
<input type="text" id="name" placeholder="Your name will appear here..." readonly>
|
117 |
+
|
118 |
+
<label for="email">Your Email</label>
|
119 |
+
<input type="text" id="email" placeholder="Your email will appear here..." readonly>
|
120 |
+
|
121 |
+
<label for="mobile">Your Mobile Number</label>
|
122 |
+
<input type="text" id="mobile" placeholder="Your mobile number will appear here..." readonly>
|
123 |
+
|
124 |
+
<p class="info" id="infoMessage">Listening 🗣🎙️...</p>
|
125 |
+
<p class="status" id="status">🔊...</p>
|
126 |
+
</div>
|
127 |
+
</div>
|
128 |
+
|
129 |
+
<!-- Login Section -->
|
130 |
+
<div class="form-container" id="loginForm" style="display: none;">
|
131 |
+
<h1>Welcome to Biryani Hub 🍽 🍗</h1>
|
132 |
+
<div class="form-section">
|
133 |
+
<h2 class="header">Login</h2>
|
134 |
+
<label for="loginEmail">Your Email</label>
|
135 |
+
<input type="text" id="loginEmail" placeholder="Your email will appear here..." readonly>
|
136 |
+
|
137 |
+
<label for="loginMobile">Your Mobile Number</label>
|
138 |
+
<input type="text" id="loginMobile" placeholder="Your mobile number will appear here..." readonly>
|
139 |
+
|
140 |
+
<p class="info" id="infoMessageLogin">Listening 🗣🎙️...</p>
|
141 |
+
<p class="status" id="statusLogin">🔊...</p>
|
142 |
+
</div>
|
143 |
+
</div>
|
144 |
+
</div>
|
145 |
+
|
146 |
+
<!-- Confirmation Section -->
|
147 |
+
<div id="confirmation">
|
148 |
+
<h2>Confirm Your Details:</h2>
|
149 |
+
<p class="confirm-details"><strong>Name:</strong> <span id="confirmName"></span></p>
|
150 |
+
<p class="confirm-details"><strong>Email:</strong> <span id="confirmEmail"></span></p>
|
151 |
+
<p class="confirm-details"><strong>Phone:</strong> <span id="confirmPhone"></span></p>
|
152 |
+
<button class="confirm-button" onclick="autoSubmit()">Confirm</button>
|
153 |
</div>
|
154 |
|
155 |
<script>
|
156 |
let recognition;
|
157 |
+
let nameCaptured = "";
|
158 |
let emailCaptured = "";
|
159 |
let mobileCaptured = "";
|
160 |
+
|
161 |
if ('webkitSpeechRecognition' in window) {
|
162 |
recognition = new webkitSpeechRecognition();
|
163 |
recognition.continuous = false;
|
|
|
166 |
} else {
|
167 |
alert("Speech Recognition API is not supported in this browser.");
|
168 |
}
|
169 |
+
|
170 |
function speak(text, callback) {
|
171 |
const speech = new SpeechSynthesisUtterance(text);
|
172 |
speech.onend = callback;
|
173 |
window.speechSynthesis.speak(speech);
|
174 |
}
|
175 |
+
|
176 |
+
// Ask the user if they want to register or login
|
177 |
+
function askLoginOrRegister() {
|
178 |
+
speak("Are you a new customer or an existing customer? Say 'new' for registration or 'existing' for login.", function() {
|
179 |
+
recognition.start();
|
180 |
+
recognition.onresult = function(event) {
|
181 |
+
let response = event.results[0][0].transcript.trim().toLowerCase();
|
182 |
+
recognition.stop();
|
183 |
+
if (response.includes("new")) {
|
184 |
+
showRegistrationForm();
|
185 |
+
} else if (response.includes("existing")) {
|
186 |
+
showLoginForm();
|
187 |
+
} else {
|
188 |
+
speak("Sorry, I didn't understand. Please say 'new' for registration or 'existing' for login.", askLoginOrRegister);
|
189 |
+
}
|
190 |
+
};
|
191 |
+
});
|
192 |
+
}
|
193 |
+
|
194 |
+
function showRegistrationForm() {
|
195 |
+
document.getElementById('registrationForm').style.display = 'block';
|
196 |
+
document.getElementById('loginForm').style.display = 'none';
|
197 |
+
speak("Please tell me your name to begin the registration.", startListeningForName);
|
198 |
+
}
|
199 |
+
|
200 |
+
function showLoginForm() {
|
201 |
+
document.getElementById('loginForm').style.display = 'block';
|
202 |
+
document.getElementById('registrationForm').style.display = 'none';
|
203 |
+
speak("Please tell me your email to begin the login process.", startListeningForLoginEmail);
|
204 |
+
}
|
205 |
+
|
206 |
+
// Capture the name for registration
|
207 |
+
function startListeningForName() {
|
208 |
+
recognition.start();
|
209 |
+
recognition.onresult = function(event) {
|
210 |
+
nameCaptured = event.results[0][0].transcript.trim();
|
211 |
+
document.getElementById('name').value = nameCaptured;
|
212 |
+
recognition.stop();
|
213 |
+
speak("You said " + nameCaptured + ". Is it correct?", confirmName);
|
214 |
+
};
|
215 |
+
}
|
216 |
+
|
217 |
+
function confirmName() {
|
218 |
+
recognition.start();
|
219 |
+
recognition.onresult = function(event) {
|
220 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
221 |
+
recognition.stop();
|
222 |
+
if (confirmation.includes("ok")) {
|
223 |
+
speak("Great! Now, tell me your email.", startListeningForEmail);
|
224 |
+
} else {
|
225 |
+
speak("Let's try again. Tell me your name.", startListeningForName);
|
226 |
+
}
|
227 |
+
};
|
228 |
+
}
|
229 |
+
|
230 |
+
// Capture email for registration
|
231 |
function startListeningForEmail() {
|
232 |
recognition.start();
|
233 |
recognition.onresult = function(event) {
|
234 |
emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
235 |
document.getElementById('email').value = emailCaptured;
|
236 |
recognition.stop();
|
237 |
+
speak("You said " + emailCaptured + ". Is it correct?", confirmEmail);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
};
|
239 |
}
|
240 |
+
|
241 |
+
function confirmEmail() {
|
242 |
+
recognition.start();
|
243 |
+
recognition.onresult = function(event) {
|
244 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
245 |
+
recognition.stop();
|
246 |
+
if (confirmation.includes("ok")) {
|
247 |
+
speak("Great! Now, tell me your mobile number.", startListeningForMobile);
|
248 |
+
} else {
|
249 |
+
speak("Let's try again. Tell me your email.", startListeningForEmail);
|
250 |
+
}
|
251 |
+
};
|
252 |
+
}
|
253 |
+
|
254 |
+
// Capture mobile number for registration
|
255 |
function startListeningForMobile() {
|
256 |
recognition.start();
|
257 |
recognition.onresult = function(event) {
|
258 |
mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
259 |
document.getElementById('mobile').value = mobileCaptured;
|
260 |
recognition.stop();
|
261 |
+
speak("You said " + mobileCaptured + ". Is it correct?", confirmMobile);
|
262 |
+
};
|
263 |
+
}
|
264 |
+
|
265 |
+
function confirmMobile() {
|
266 |
+
recognition.start();
|
267 |
+
recognition.onresult = function(event) {
|
268 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
269 |
+
recognition.stop();
|
270 |
+
if (confirmation.includes("ok")) {
|
271 |
+
autoConfirm();
|
272 |
+
} else {
|
273 |
+
speak("Let's try again. Tell me your mobile number.", startListeningForMobile);
|
274 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
};
|
276 |
}
|
277 |
+
|
278 |
+
// Confirm details and submit automatically
|
279 |
+
function autoConfirm() {
|
280 |
+
document.getElementById('confirmName').textContent = document.getElementById('name').value;
|
281 |
+
document.getElementById('confirmEmail').textContent = document.getElementById('email').value;
|
282 |
+
document.getElementById('confirmPhone').textContent = document.getElementById('mobile').value;
|
283 |
+
document.getElementById('confirmation').style.display = 'block';
|
284 |
+
setTimeout(autoSubmit, 3000);
|
285 |
+
}
|
286 |
+
|
287 |
+
// Submit details to backend
|
288 |
+
function autoSubmit() {
|
289 |
+
var name = document.getElementById('name').value;
|
290 |
+
var email = document.getElementById('email').value;
|
291 |
+
var phone = document.getElementById('mobile').value;
|
292 |
+
fetch('/submit', {
|
293 |
+
method: 'POST',
|
294 |
+
headers: { 'Content-Type': 'application/json' },
|
295 |
+
body: JSON.stringify({ name: name, email: email, phone: phone })
|
296 |
+
})
|
297 |
+
.then(response => response.json())
|
298 |
+
.then(data => {
|
299 |
+
if (data.success) {
|
300 |
+
document.getElementById('status').textContent = 'Your details were submitted successfully!';
|
301 |
+
document.getElementById('confirmation').style.display = 'none';
|
302 |
+
speak("Your registration is complete. Thank you for registering.");
|
303 |
+
setTimeout(() => location.reload(), 5000);
|
304 |
+
} else {
|
305 |
+
document.getElementById('status').textContent = 'There was an error submitting your details.';
|
306 |
+
speak("There was an error submitting your details. Please try again.");
|
307 |
+
}
|
308 |
});
|
309 |
}
|
310 |
+
|
311 |
window.onload = function () {
|
312 |
+
askLoginOrRegister();
|
313 |
};
|
314 |
</script>
|
315 |
</body>
|
316 |
+
</html>
|