Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +16 -11
templates/index.html
CHANGED
@@ -78,8 +78,8 @@
|
|
78 |
let recognition;
|
79 |
let currentName = ""; // Store the name as it's being formed
|
80 |
let currentEmail = ""; // Store the email as it's being formed
|
81 |
-
let
|
82 |
-
let
|
83 |
|
84 |
if ('webkitSpeechRecognition' in window) {
|
85 |
recognition = new webkitSpeechRecognition();
|
@@ -106,10 +106,13 @@
|
|
106 |
|
107 |
if (transcript === "next") {
|
108 |
recognition.stop(); // Stop recognition immediately
|
109 |
-
|
|
|
110 |
status.textContent = "Your name is captured. Now listening for your email...";
|
111 |
-
speak("Now, please tell me your email, letter by letter",
|
112 |
-
|
|
|
|
|
113 |
}
|
114 |
|
115 |
// Append spoken letters to the name
|
@@ -121,9 +124,9 @@
|
|
121 |
function startListeningForEmail() {
|
122 |
const status = document.getElementById('status');
|
123 |
const emailInput = document.getElementById('email');
|
124 |
-
|
125 |
-
|
126 |
-
recognition = new webkitSpeechRecognition();
|
127 |
recognition.continuous = false;
|
128 |
recognition.interimResults = false;
|
129 |
recognition.lang = 'en-US';
|
@@ -135,7 +138,7 @@
|
|
135 |
|
136 |
if (transcript === "next") {
|
137 |
recognition.stop(); // Stop recognition for email
|
138 |
-
|
139 |
status.textContent = 'Registration complete.';
|
140 |
speak("Registration complete. Thank you!", function() {
|
141 |
setTimeout(() => location.reload(), 10000); // Refresh after 10 sec
|
@@ -144,14 +147,16 @@
|
|
144 |
}
|
145 |
|
146 |
// Append spoken letters to the email
|
147 |
-
currentEmail += transcript;
|
148 |
emailInput.value = currentEmail.trim();
|
149 |
};
|
150 |
}
|
151 |
|
152 |
function startProcess() {
|
153 |
speak("Welcome to Biryani Hub", function() {
|
154 |
-
speak("Tell me your name, letter by letter, and say 'next' when you're done",
|
|
|
|
|
155 |
});
|
156 |
}
|
157 |
|
|
|
78 |
let recognition;
|
79 |
let currentName = ""; // Store the name as it's being formed
|
80 |
let currentEmail = ""; // Store the email as it's being formed
|
81 |
+
let isCapturingName = true;
|
82 |
+
let isCapturingEmail = false;
|
83 |
|
84 |
if ('webkitSpeechRecognition' in window) {
|
85 |
recognition = new webkitSpeechRecognition();
|
|
|
106 |
|
107 |
if (transcript === "next") {
|
108 |
recognition.stop(); // Stop recognition immediately
|
109 |
+
isCapturingName = false;
|
110 |
+
isCapturingEmail = true;
|
111 |
status.textContent = "Your name is captured. Now listening for your email...";
|
112 |
+
speak("Now, please tell me your email, letter by letter", function() {
|
113 |
+
startListeningForEmail(); // Start email capture
|
114 |
+
});
|
115 |
+
return; // Exit function to prevent "next" from being added to the name
|
116 |
}
|
117 |
|
118 |
// Append spoken letters to the name
|
|
|
124 |
function startListeningForEmail() {
|
125 |
const status = document.getElementById('status');
|
126 |
const emailInput = document.getElementById('email');
|
127 |
+
|
128 |
+
// Reinitialize recognition
|
129 |
+
recognition = new webkitSpeechRecognition();
|
130 |
recognition.continuous = false;
|
131 |
recognition.interimResults = false;
|
132 |
recognition.lang = 'en-US';
|
|
|
138 |
|
139 |
if (transcript === "next") {
|
140 |
recognition.stop(); // Stop recognition for email
|
141 |
+
isCapturingEmail = false;
|
142 |
status.textContent = 'Registration complete.';
|
143 |
speak("Registration complete. Thank you!", function() {
|
144 |
setTimeout(() => location.reload(), 10000); // Refresh after 10 sec
|
|
|
147 |
}
|
148 |
|
149 |
// Append spoken letters to the email
|
150 |
+
currentEmail += transcript + " ";
|
151 |
emailInput.value = currentEmail.trim();
|
152 |
};
|
153 |
}
|
154 |
|
155 |
function startProcess() {
|
156 |
speak("Welcome to Biryani Hub", function() {
|
157 |
+
speak("Tell me your name, letter by letter, and say 'next' when you're done", function() {
|
158 |
+
startListeningForName();
|
159 |
+
});
|
160 |
});
|
161 |
}
|
162 |
|