Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +40 -40
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;
|
@@ -79,65 +79,65 @@
|
|
79 |
let isListening = false;
|
80 |
let isNameCaptured = false;
|
81 |
|
82 |
-
// Initialize speech recognition
|
83 |
if ('webkitSpeechRecognition' in window) {
|
84 |
recognition = new webkitSpeechRecognition();
|
85 |
-
recognition.continuous =
|
86 |
-
recognition.interimResults =
|
87 |
recognition.lang = 'en-US';
|
88 |
} else {
|
89 |
alert("Speech Recognition API is not supported in this browser.");
|
90 |
}
|
91 |
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
const speech = new SpeechSynthesisUtterance(welcomeMsg);
|
96 |
window.speechSynthesis.speak(speech);
|
97 |
}
|
98 |
|
99 |
-
|
100 |
-
function startListening() {
|
101 |
const status = document.getElementById('status');
|
102 |
const nameInput = document.getElementById('name');
|
103 |
-
const emailInput = document.getElementById('email');
|
104 |
|
105 |
-
status.textContent =
|
106 |
-
recognition.start();
|
107 |
|
108 |
-
// Handle recognition results
|
109 |
recognition.onresult = function(event) {
|
110 |
-
const transcript = event.results[
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
status.textContent = 'Tell me your email...';
|
117 |
-
isNameCaptured = true; // Mark name as captured
|
118 |
-
recognition.stop(); // Stop listening for name
|
119 |
-
recognition.start(); // Start listening for email
|
120 |
-
} else if (isNameCaptured && !emailInput.value) {
|
121 |
-
// If email is empty, fill it with the recognized text
|
122 |
-
emailInput.value = transcript;
|
123 |
-
status.textContent = 'Registration complete.';
|
124 |
-
|
125 |
-
// After registration is complete, refresh page automatically after 15 seconds
|
126 |
-
setTimeout(() => location.reload(), 15000); // Refresh after 15 seconds
|
127 |
-
}
|
128 |
-
}
|
129 |
};
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
-
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
};
|
135 |
}
|
136 |
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
138 |
window.onload = function () {
|
139 |
-
|
140 |
-
setTimeout(startListening, 5000); // Start listening after the welcome message
|
141 |
};
|
142 |
</script>
|
143 |
</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;
|
|
|
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 |
+
const transcript = event.results[0][0].transcript.trim();
|
123 |
+
emailInput.value = transcript;
|
124 |
+
recognition.stop();
|
125 |
+
|
126 |
+
status.textContent = "Registration complete.";
|
127 |
+
|
128 |
+
// Refresh after 15 seconds
|
129 |
+
setTimeout(() => location.reload(), 15000);
|
130 |
};
|
131 |
}
|
132 |
|
133 |
+
function startProcess() {
|
134 |
+
speak("Welcome to Biryani Hub", function() {
|
135 |
+
speak("Tell me your name", startListeningForName);
|
136 |
+
});
|
137 |
+
}
|
138 |
+
|
139 |
window.onload = function () {
|
140 |
+
setTimeout(startProcess, 1000); // Start process after 1 second
|
|
|
141 |
};
|
142 |
</script>
|
143 |
</body>
|