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