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