Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +51 -44
templates/index.html
CHANGED
@@ -41,6 +41,7 @@
|
|
41 |
border: 1px solid #ccc;
|
42 |
border-radius: 5px;
|
43 |
margin-top: 8px;
|
|
|
44 |
}
|
45 |
.info {
|
46 |
margin-top: 20px;
|
@@ -76,14 +77,14 @@
|
|
76 |
|
77 |
<script>
|
78 |
let recognition;
|
79 |
-
let currentName = "";
|
80 |
-
let currentEmail = "";
|
81 |
let isCapturingName = true;
|
82 |
let isCapturingEmail = false;
|
83 |
|
84 |
if ('webkitSpeechRecognition' in window) {
|
85 |
recognition = new webkitSpeechRecognition();
|
86 |
-
recognition.continuous = false;
|
87 |
recognition.interimResults = false;
|
88 |
recognition.lang = 'en-US';
|
89 |
} else {
|
@@ -92,7 +93,7 @@
|
|
92 |
|
93 |
function speak(text, callback) {
|
94 |
const speech = new SpeechSynthesisUtterance(text);
|
95 |
-
speech.onend = callback;
|
96 |
window.speechSynthesis.speak(speech);
|
97 |
}
|
98 |
|
@@ -102,31 +103,33 @@
|
|
102 |
status.textContent = "Listening for your name...";
|
103 |
recognition.start();
|
104 |
recognition.onresult = function(event) {
|
105 |
-
|
106 |
|
107 |
-
if (transcript
|
108 |
-
recognition.stop();
|
109 |
isCapturingName = false;
|
110 |
isCapturingEmail = true;
|
111 |
-
status.textContent = "Your name is
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
});
|
119 |
|
120 |
-
return;
|
121 |
}
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
nameInput.value = currentName.trim(); // Display the updated name
|
126 |
-
};
|
127 |
-
|
128 |
-
recognition.onspeechend = function() {
|
129 |
-
recognition.stop(); // Stop after input ends
|
130 |
};
|
131 |
}
|
132 |
|
@@ -134,7 +137,6 @@
|
|
134 |
const status = document.getElementById('status');
|
135 |
const emailInput = document.getElementById('email');
|
136 |
|
137 |
-
// Reset recognition for email input
|
138 |
recognition = new webkitSpeechRecognition();
|
139 |
recognition.continuous = false;
|
140 |
recognition.interimResults = false;
|
@@ -143,43 +145,48 @@
|
|
143 |
status.textContent = "Listening for your email...";
|
144 |
recognition.start();
|
145 |
recognition.onresult = function(event) {
|
146 |
-
|
|
|
|
|
|
|
147 |
|
148 |
-
if (transcript
|
149 |
-
recognition.stop();
|
150 |
isCapturingEmail = false;
|
151 |
-
status.textContent =
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
});
|
159 |
|
160 |
-
return;
|
161 |
}
|
162 |
|
163 |
-
|
164 |
-
|
165 |
-
emailInput.value = currentEmail.trim();
|
166 |
-
};
|
167 |
-
|
168 |
-
recognition.onspeechend = function() {
|
169 |
-
recognition.stop(); // Stop after input ends
|
170 |
};
|
171 |
}
|
172 |
|
173 |
function startProcess() {
|
174 |
speak("Welcome to Biryani Hub", function() {
|
175 |
-
speak("Tell me your name, letter by letter, and say 'next' when you're done",
|
176 |
-
startListeningForName();
|
177 |
-
});
|
178 |
});
|
179 |
}
|
180 |
|
181 |
window.onload = function () {
|
182 |
-
setTimeout(startProcess, 4000);
|
183 |
};
|
184 |
</script>
|
185 |
</body>
|
|
|
41 |
border: 1px solid #ccc;
|
42 |
border-radius: 5px;
|
43 |
margin-top: 8px;
|
44 |
+
text-transform: uppercase;
|
45 |
}
|
46 |
.info {
|
47 |
margin-top: 20px;
|
|
|
77 |
|
78 |
<script>
|
79 |
let recognition;
|
80 |
+
let currentName = "";
|
81 |
+
let currentEmail = "";
|
82 |
let isCapturingName = true;
|
83 |
let isCapturingEmail = false;
|
84 |
|
85 |
if ('webkitSpeechRecognition' in window) {
|
86 |
recognition = new webkitSpeechRecognition();
|
87 |
+
recognition.continuous = false;
|
88 |
recognition.interimResults = false;
|
89 |
recognition.lang = 'en-US';
|
90 |
} else {
|
|
|
93 |
|
94 |
function speak(text, callback) {
|
95 |
const speech = new SpeechSynthesisUtterance(text);
|
96 |
+
speech.onend = callback;
|
97 |
window.speechSynthesis.speak(speech);
|
98 |
}
|
99 |
|
|
|
103 |
status.textContent = "Listening for your name...";
|
104 |
recognition.start();
|
105 |
recognition.onresult = function(event) {
|
106 |
+
let transcript = event.results[0][0].transcript.trim().toUpperCase().replace(/\s+/g, "");
|
107 |
|
108 |
+
if (transcript === "NEXT") {
|
109 |
+
recognition.stop();
|
110 |
isCapturingName = false;
|
111 |
isCapturingEmail = true;
|
112 |
+
status.textContent = "Your name is: " + currentName;
|
113 |
|
114 |
+
speak("Your name is " + currentName + ". If correct, say 'confirm'. If wrong, say 'edit'.", function() {
|
115 |
+
recognition.start();
|
116 |
+
recognition.onresult = function(event) {
|
117 |
+
let confirmTranscript = event.results[0][0].transcript.trim().toLowerCase();
|
118 |
+
if (confirmTranscript === "confirm") {
|
119 |
+
speak("Now, please tell me your email, letter by letter", startListeningForEmail);
|
120 |
+
} else if (confirmTranscript === "edit") {
|
121 |
+
currentName = "";
|
122 |
+
nameInput.value = "";
|
123 |
+
speak("Tell your name again.", startListeningForName);
|
124 |
+
}
|
125 |
+
};
|
126 |
});
|
127 |
|
128 |
+
return;
|
129 |
}
|
130 |
|
131 |
+
currentName += transcript;
|
132 |
+
nameInput.value = currentName;
|
|
|
|
|
|
|
|
|
|
|
133 |
};
|
134 |
}
|
135 |
|
|
|
137 |
const status = document.getElementById('status');
|
138 |
const emailInput = document.getElementById('email');
|
139 |
|
|
|
140 |
recognition = new webkitSpeechRecognition();
|
141 |
recognition.continuous = false;
|
142 |
recognition.interimResults = false;
|
|
|
145 |
status.textContent = "Listening for your email...";
|
146 |
recognition.start();
|
147 |
recognition.onresult = function(event) {
|
148 |
+
let transcript = event.results[0][0].transcript.trim().toUpperCase().replace(/\s+/g, "");
|
149 |
+
|
150 |
+
// Replace "AT" with "@", "DOT" with "."
|
151 |
+
transcript = transcript.replace(/\bAT\b/g, "@").replace(/\bDOT\b/g, ".");
|
152 |
|
153 |
+
if (transcript === "NEXT") {
|
154 |
+
recognition.stop();
|
155 |
isCapturingEmail = false;
|
156 |
+
status.textContent = "Your email is: " + currentEmail;
|
157 |
+
|
158 |
+
speak("Your email is " + currentEmail + ". If correct, say 'confirm'. If wrong, say 'edit'.", function() {
|
159 |
+
recognition.start();
|
160 |
+
recognition.onresult = function(event) {
|
161 |
+
let confirmTranscript = event.results[0][0].transcript.trim().toLowerCase();
|
162 |
+
if (confirmTranscript === "confirm") {
|
163 |
+
speak("Registration complete. Thank you!", function() {
|
164 |
+
setTimeout(() => location.reload(), 10000);
|
165 |
+
});
|
166 |
+
} else if (confirmTranscript === "edit") {
|
167 |
+
currentEmail = "";
|
168 |
+
emailInput.value = "";
|
169 |
+
speak("Tell your email again.", startListeningForEmail);
|
170 |
+
}
|
171 |
+
};
|
172 |
});
|
173 |
|
174 |
+
return;
|
175 |
}
|
176 |
|
177 |
+
currentEmail += transcript;
|
178 |
+
emailInput.value = currentEmail;
|
|
|
|
|
|
|
|
|
|
|
179 |
};
|
180 |
}
|
181 |
|
182 |
function startProcess() {
|
183 |
speak("Welcome to Biryani Hub", function() {
|
184 |
+
speak("Tell me your name, letter by letter, and say 'next' when you're done", startListeningForName);
|
|
|
|
|
185 |
});
|
186 |
}
|
187 |
|
188 |
window.onload = function () {
|
189 |
+
setTimeout(startProcess, 4000);
|
190 |
};
|
191 |
</script>
|
192 |
</body>
|