Spaces:
Runtime error
Runtime error
Update templates/index.html
Browse files- templates/index.html +114 -62
templates/index.html
CHANGED
@@ -4,96 +4,148 @@
|
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<title>Biryani Hub Registration</title>
|
7 |
-
<link
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
</head>
|
9 |
<body>
|
10 |
<div class="container">
|
11 |
-
<h1>Biryani Hub</h1>
|
|
|
|
|
|
|
|
|
12 |
|
13 |
-
|
14 |
-
<
|
|
|
15 |
|
16 |
-
|
17 |
-
<
|
18 |
|
19 |
-
|
20 |
-
<
|
21 |
</div>
|
22 |
|
23 |
<script>
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
31 |
}
|
32 |
|
33 |
-
|
34 |
-
const
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
return new Promise(resolve => {
|
39 |
-
mediaRecorder.ondataavailable = event => {
|
40 |
-
audioChunks.push(event.data);
|
41 |
-
};
|
42 |
-
|
43 |
-
mediaRecorder.onstop = () => {
|
44 |
-
const audioBlob = new Blob(audioChunks, { type: 'audio/wav' });
|
45 |
-
resolve(audioBlob);
|
46 |
-
};
|
47 |
-
|
48 |
-
mediaRecorder.start();
|
49 |
-
setTimeout(() => mediaRecorder.stop(), 5000); // ✅ Record for 5 seconds
|
50 |
-
});
|
51 |
}
|
52 |
|
53 |
-
|
54 |
-
const
|
55 |
-
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
body: formData
|
60 |
-
});
|
61 |
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
}
|
65 |
|
66 |
-
|
67 |
const status = document.getElementById('status');
|
68 |
-
const nameInput = document.getElementById('name');
|
69 |
const emailInput = document.getElementById('email');
|
70 |
|
71 |
-
status.textContent =
|
72 |
-
|
73 |
|
74 |
-
|
75 |
-
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
const nameText = await transcribeAudio(nameAudio);
|
80 |
-
nameInput.value = nameText;
|
81 |
|
82 |
-
|
83 |
-
|
84 |
|
85 |
-
|
86 |
-
const emailAudio = await recordAudio();
|
87 |
-
const emailText = await transcribeAudio(emailAudio);
|
88 |
-
emailInput.value = emailText;
|
89 |
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
-
|
|
|
|
|
|
|
94 |
}
|
95 |
|
96 |
-
window.onload =
|
|
|
|
|
97 |
</script>
|
98 |
</body>
|
99 |
</html>
|
|
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<title>Biryani Hub Registration</title>
|
7 |
+
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
|
8 |
+
<style>
|
9 |
+
body {
|
10 |
+
font-family: 'Roboto', sans-serif;
|
11 |
+
background: linear-gradient(135deg, #f4c542, #ff8f6a); /* Light gradient background */
|
12 |
+
margin: 0;
|
13 |
+
display: flex;
|
14 |
+
justify-content: center;
|
15 |
+
align-items: center;
|
16 |
+
height: 100vh;
|
17 |
+
text-align: center;
|
18 |
+
}
|
19 |
+
.container {
|
20 |
+
background:lightblue;
|
21 |
+
padding: 40px 50px;
|
22 |
+
border-radius: 10px;
|
23 |
+
width: 400px;
|
24 |
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
|
25 |
+
}
|
26 |
+
h1 {
|
27 |
+
font-size: 30px;
|
28 |
+
font-weight: bold;
|
29 |
+
color: #ff6a00; /* Bright orange for title */
|
30 |
+
}
|
31 |
+
label {
|
32 |
+
font-size: 18px;
|
33 |
+
margin-top: 20px;
|
34 |
+
display: block;
|
35 |
+
text-align: left;
|
36 |
+
}
|
37 |
+
input[type="text"] {
|
38 |
+
width: 100%;
|
39 |
+
padding: 10px;
|
40 |
+
font-size: 16px;
|
41 |
+
border: 1px solid #ccc;
|
42 |
+
border-radius: 5px;
|
43 |
+
margin-top: 8px;
|
44 |
+
}
|
45 |
+
.info {
|
46 |
+
margin-top: 20px;
|
47 |
+
font-size: 16px;
|
48 |
+
color: #ff6a00;
|
49 |
+
font-weight: bold;
|
50 |
+
}
|
51 |
+
.status {
|
52 |
+
font-size: 14px;
|
53 |
+
color: gray;
|
54 |
+
margin-top: 20px;
|
55 |
+
}
|
56 |
+
</style>
|
57 |
</head>
|
58 |
<body>
|
59 |
<div class="container">
|
60 |
+
<h1>Welcome to Biryani Hub</h1>
|
61 |
+
|
62 |
+
<!-- Name Input Field -->
|
63 |
+
<label for="name">Your Name</label>
|
64 |
+
<input type="text" id="name" placeholder="Your name will appear here..." readonly>
|
65 |
|
66 |
+
<!-- Email Input Field -->
|
67 |
+
<label for="email">Your Email</label>
|
68 |
+
<input type="text" id="email" placeholder="Your email will appear here..." readonly>
|
69 |
|
70 |
+
<!-- Info Message for Listening -->
|
71 |
+
<p class="info" id="infoMessage">Listening will start automatically...</p>
|
72 |
|
73 |
+
<!-- Status Message -->
|
74 |
+
<p class="status" id="status">Initializing...</p>
|
75 |
</div>
|
76 |
|
77 |
<script>
|
78 |
+
let recognition;
|
79 |
+
let isListening = false;
|
80 |
+
let isNameCaptured = false;
|
81 |
+
|
82 |
+
if ('webkitSpeechRecognition' in window) {
|
83 |
+
recognition = new webkitSpeechRecognition();
|
84 |
+
recognition.continuous = false; // Stop after capturing each input
|
85 |
+
recognition.interimResults = false;
|
86 |
+
recognition.lang = 'en-US';
|
87 |
+
} else {
|
88 |
+
alert("Speech Recognition API is not supported in this browser.");
|
89 |
}
|
90 |
|
91 |
+
function speak(text, callback) {
|
92 |
+
const speech = new SpeechSynthesisUtterance(text);
|
93 |
+
speech.onend = callback; // Once the speech ends, call the next function
|
94 |
+
window.speechSynthesis.speak(speech);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
}
|
96 |
|
97 |
+
function startListeningForName() {
|
98 |
+
const status = document.getElementById('status');
|
99 |
+
const nameInput = document.getElementById('name');
|
100 |
|
101 |
+
status.textContent = "Listening for your name...";
|
102 |
+
recognition.start();
|
|
|
|
|
103 |
|
104 |
+
recognition.onresult = function(event) {
|
105 |
+
const transcript = event.results[0][0].transcript.trim();
|
106 |
+
nameInput.value = transcript;
|
107 |
+
recognition.stop();
|
108 |
+
|
109 |
+
// Now, prompt for email
|
110 |
+
speak("Tell me your email", startListeningForEmail);
|
111 |
+
};
|
112 |
}
|
113 |
|
114 |
+
function startListeningForEmail() {
|
115 |
const status = document.getElementById('status');
|
|
|
116 |
const emailInput = document.getElementById('email');
|
117 |
|
118 |
+
status.textContent = "Listening for your email...";
|
119 |
+
recognition.start();
|
120 |
|
121 |
+
recognition.onresult = function(event) {
|
122 |
+
let transcript = event.results[0][0].transcript.trim();
|
123 |
|
124 |
+
// Replace spoken variations of "at" with "@" for emails
|
125 |
+
transcript = transcript.replace(/\bat\b/g, '@').trim();
|
|
|
|
|
126 |
|
127 |
+
// Remove unwanted spaces from the email input
|
128 |
+
emailInput.value = transcript;
|
129 |
|
130 |
+
recognition.stop();
|
|
|
|
|
|
|
131 |
|
132 |
+
status.textContent = "Registration complete .";
|
133 |
+
speak("Registration complete Go To The Next step and take the order what you want.");
|
134 |
+
|
135 |
+
// Refresh after 20 seconds
|
136 |
+
setTimeout(() => location.reload(), 20000);
|
137 |
+
};
|
138 |
+
}
|
139 |
|
140 |
+
function startProcess() {
|
141 |
+
speak("Welcome to Biryani Hub", function() {
|
142 |
+
speak("Tell me your name", startListeningForName);
|
143 |
+
});
|
144 |
}
|
145 |
|
146 |
+
window.onload = function () {
|
147 |
+
setTimeout(startProcess, 4000); // Start process after 4 second
|
148 |
+
};
|
149 |
</script>
|
150 |
</body>
|
151 |
</html>
|