lokesh341 commited on
Commit
afdd70e
·
verified ·
1 Parent(s): 575c837

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +4 -2
templates/index.html CHANGED
@@ -92,6 +92,7 @@
92
  <script>
93
  let recognition;
94
  let isListening = false;
 
95
 
96
  // Initialize speech recognition
97
  if ('webkitSpeechRecognition' in window) {
@@ -130,13 +131,14 @@
130
  const transcript = event.results[event.resultIndex][0].transcript.trim();
131
  console.log('Recognized Text:', transcript); // Debugging line
132
  if (event.results[event.resultIndex].isFinal) {
133
- if (!nameInput.value) {
134
  // If name is empty, fill it with the recognized text
135
  nameInput.value = transcript;
136
  status.textContent = 'Listening for your email...';
 
137
  recognition.stop(); // Stop listening for name
138
  recognition.start(); // Start listening for email
139
- } else if (nameInput.value && !emailInput.value) {
140
  // If email is empty, fill it with the recognized text
141
  emailInput.value = transcript;
142
  status.textContent = 'Registration complete.';
 
92
  <script>
93
  let recognition;
94
  let isListening = false;
95
+ let isNameCaptured = false;
96
 
97
  // Initialize speech recognition
98
  if ('webkitSpeechRecognition' in window) {
 
131
  const transcript = event.results[event.resultIndex][0].transcript.trim();
132
  console.log('Recognized Text:', transcript); // Debugging line
133
  if (event.results[event.resultIndex].isFinal) {
134
+ if (!isNameCaptured) {
135
  // If name is empty, fill it with the recognized text
136
  nameInput.value = transcript;
137
  status.textContent = 'Listening for your email...';
138
+ isNameCaptured = true; // Mark name as captured
139
  recognition.stop(); // Stop listening for name
140
  recognition.start(); // Start listening for email
141
+ } else if (isNameCaptured && !emailInput.value) {
142
  // If email is empty, fill it with the recognized text
143
  emailInput.value = transcript;
144
  status.textContent = 'Registration complete.';