Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +35 -45
templates/index.html
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
<style>
|
9 |
body {
|
10 |
font-family: 'Roboto', sans-serif;
|
11 |
-
background: linear-gradient(135deg, #f4c542, #ff8f6a);
|
12 |
margin: 0;
|
13 |
display: flex;
|
14 |
justify-content: center;
|
@@ -26,7 +26,7 @@
|
|
26 |
h1 {
|
27 |
font-size: 30px;
|
28 |
font-weight: bold;
|
29 |
-
color: #ff6a00;
|
30 |
}
|
31 |
label {
|
32 |
font-size: 18px;
|
@@ -59,30 +59,24 @@
|
|
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
|
80 |
-
let
|
81 |
-
let isEmailCaptured = false;
|
82 |
|
83 |
if ('webkitSpeechRecognition' in window) {
|
84 |
recognition = new webkitSpeechRecognition();
|
85 |
-
recognition.continuous =
|
86 |
recognition.interimResults = false;
|
87 |
recognition.lang = 'en-US';
|
88 |
} else {
|
@@ -91,66 +85,62 @@
|
|
91 |
|
92 |
function speak(text, callback) {
|
93 |
const speech = new SpeechSynthesisUtterance(text);
|
94 |
-
speech.onend = callback;
|
95 |
window.speechSynthesis.speak(speech);
|
96 |
}
|
97 |
|
98 |
function startListeningForName() {
|
99 |
const status = document.getElementById('status');
|
100 |
-
const nameInput = document.getElementById('name');
|
101 |
status.textContent = "Listening for your name...";
|
102 |
recognition.start();
|
|
|
103 |
recognition.onresult = function(event) {
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
recognition.stop();
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
|
|
|
|
121 |
}
|
122 |
|
123 |
function startListeningForEmail() {
|
124 |
const status = document.getElementById('status');
|
125 |
-
const emailInput = document.getElementById('email');
|
126 |
status.textContent = "Listening for your email...";
|
127 |
recognition.start();
|
128 |
-
recognition.onresult = function(event) {
|
129 |
-
let transcript = event.results[0][0].transcript.trim();
|
130 |
-
|
131 |
-
// Replace "at" with "@" for email
|
132 |
-
transcript = transcript.replace(/\bat\b/g, '@').trim();
|
133 |
-
|
134 |
-
// Clean any spaces around the email
|
135 |
-
const cleanedEmail = transcript.replace(/\s+/g, '');
|
136 |
|
137 |
-
|
|
|
|
|
|
|
138 |
status.textContent = 'Registration complete.';
|
|
|
139 |
|
140 |
-
|
141 |
-
setTimeout(() => location.reload(), 20000); // Refresh after 20 seconds
|
142 |
-
isEmailCaptured = true; // Mark email as captured
|
143 |
};
|
144 |
}
|
145 |
|
146 |
function startProcess() {
|
147 |
speak("Welcome to Biryani Hub", function() {
|
148 |
-
speak("Tell me your name,
|
149 |
});
|
150 |
}
|
151 |
|
152 |
window.onload = function () {
|
153 |
-
setTimeout(startProcess, 4000);
|
154 |
};
|
155 |
</script>
|
156 |
</body>
|
|
|
8 |
<style>
|
9 |
body {
|
10 |
font-family: 'Roboto', sans-serif;
|
11 |
+
background: linear-gradient(135deg, #f4c542, #ff8f6a);
|
12 |
margin: 0;
|
13 |
display: flex;
|
14 |
justify-content: center;
|
|
|
26 |
h1 {
|
27 |
font-size: 30px;
|
28 |
font-weight: bold;
|
29 |
+
color: #ff6a00;
|
30 |
}
|
31 |
label {
|
32 |
font-size: 18px;
|
|
|
59 |
<div class="container">
|
60 |
<h1>Welcome to Biryani Hub</h1>
|
61 |
|
|
|
62 |
<label for="name">Your Name</label>
|
63 |
<input type="text" id="name" placeholder="Your name will appear here..." readonly>
|
64 |
+
|
|
|
65 |
<label for="email">Your Email</label>
|
66 |
<input type="text" id="email" placeholder="Your email will appear here..." readonly>
|
67 |
+
|
|
|
68 |
<p class="info" id="infoMessage">Listening will start automatically...</p>
|
|
|
|
|
69 |
<p class="status" id="status">Initializing...</p>
|
70 |
</div>
|
71 |
|
72 |
<script>
|
73 |
let recognition;
|
74 |
+
let nameCaptured = "";
|
75 |
+
let emailCaptured = "";
|
|
|
76 |
|
77 |
if ('webkitSpeechRecognition' in window) {
|
78 |
recognition = new webkitSpeechRecognition();
|
79 |
+
recognition.continuous = false;
|
80 |
recognition.interimResults = false;
|
81 |
recognition.lang = 'en-US';
|
82 |
} else {
|
|
|
85 |
|
86 |
function speak(text, callback) {
|
87 |
const speech = new SpeechSynthesisUtterance(text);
|
88 |
+
speech.onend = callback;
|
89 |
window.speechSynthesis.speak(speech);
|
90 |
}
|
91 |
|
92 |
function startListeningForName() {
|
93 |
const status = document.getElementById('status');
|
|
|
94 |
status.textContent = "Listening for your name...";
|
95 |
recognition.start();
|
96 |
+
|
97 |
recognition.onresult = function(event) {
|
98 |
+
nameCaptured = event.results[0][0].transcript.trim();
|
99 |
+
document.getElementById('name').value = nameCaptured;
|
100 |
+
recognition.stop();
|
101 |
+
confirmName();
|
102 |
+
};
|
103 |
+
}
|
104 |
|
105 |
+
function confirmName() {
|
106 |
+
speak("You said " + nameCaptured + ". Is it okay, or do you want to change it?", function() {
|
107 |
+
recognition.start();
|
108 |
+
recognition.onresult = function(event) {
|
109 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
110 |
recognition.stop();
|
111 |
+
if (confirmation === "ok" || confirmation === "okay" || confirmation === "yes") {
|
112 |
+
speak("Great! Now, tell me your email.", startListeningForEmail);
|
113 |
+
} else {
|
114 |
+
speak("Let's try again. Tell me your name.", startListeningForName);
|
115 |
+
}
|
116 |
+
};
|
117 |
+
});
|
118 |
}
|
119 |
|
120 |
function startListeningForEmail() {
|
121 |
const status = document.getElementById('status');
|
|
|
122 |
status.textContent = "Listening for your email...";
|
123 |
recognition.start();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
|
125 |
+
recognition.onresult = function(event) {
|
126 |
+
emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
127 |
+
document.getElementById('email').value = emailCaptured;
|
128 |
+
recognition.stop();
|
129 |
status.textContent = 'Registration complete.';
|
130 |
+
speak("Your registration is complete. Thank you for registering.");
|
131 |
|
132 |
+
setTimeout(() => location.reload(), 20000);
|
|
|
|
|
133 |
};
|
134 |
}
|
135 |
|
136 |
function startProcess() {
|
137 |
speak("Welcome to Biryani Hub", function() {
|
138 |
+
speak("Tell me your name, and I will confirm it with you.", startListeningForName);
|
139 |
});
|
140 |
}
|
141 |
|
142 |
window.onload = function () {
|
143 |
+
setTimeout(startProcess, 4000);
|
144 |
};
|
145 |
</script>
|
146 |
</body>
|