lokesh341 commited on
Commit
d9ec8d8
·
verified ·
1 Parent(s): 96e9e1d

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +15 -11
templates/index.html CHANGED
@@ -76,12 +76,13 @@
76
 
77
  <script>
78
  let recognition;
 
79
  let isNameCaptured = false;
80
  let isEmailCaptured = 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 {
@@ -102,16 +103,19 @@
102
  recognition.onresult = function(event) {
103
  const transcript = event.results[0][0].transcript.trim();
104
 
105
- // Remove all spaces from the name
106
- const cleanedName = transcript.replace(/\s+/g, '');
 
 
 
 
107
 
108
- if (!isNameCaptured) {
109
- // If name is not yet captured, capture name first
110
- nameInput.value = cleanedName; // Set the cleaned name without spaces
111
- status.textContent = 'Listening for your email...'; // Prompt for email
112
- recognition.stop(); // Stop listening for name
113
- isNameCaptured = true; // Mark name as captured
114
- recognition.start(); // Start listening for email
115
  }
116
  };
117
  }
@@ -141,7 +145,7 @@
141
 
142
  function startProcess() {
143
  speak("Welcome to Biryani Hub", function() {
144
- speak("Tell me your name", startListeningForName);
145
  });
146
  }
147
 
 
76
 
77
  <script>
78
  let recognition;
79
+ let currentName = ""; // Variable to store the name as it's being formed
80
  let isNameCaptured = false;
81
  let isEmailCaptured = false;
82
 
83
  if ('webkitSpeechRecognition' in window) {
84
  recognition = new webkitSpeechRecognition();
85
+ recognition.continuous = true; // Keep listening
86
  recognition.interimResults = false;
87
  recognition.lang = 'en-US';
88
  } else {
 
103
  recognition.onresult = function(event) {
104
  const transcript = event.results[0][0].transcript.trim();
105
 
106
+ // Capture the individual letter spoken
107
+ currentName += transcript; // Append the current letter to the name
108
+ nameInput.value = currentName; // Display the updated name input
109
+
110
+ // Optionally, speak out the name as it's being typed
111
+ speak(transcript, null); // Say the captured letter
112
 
113
+ // If a space or "next" word is detected, stop and move to email
114
+ if (transcript.toLowerCase() === "next") {
115
+ recognition.stop();
116
+ isNameCaptured = true;
117
+ status.textContent = "Listening for your email...";
118
+ speak("Tell me your email", startListeningForEmail);
 
119
  }
120
  };
121
  }
 
145
 
146
  function startProcess() {
147
  speak("Welcome to Biryani Hub", function() {
148
+ speak("Tell me your name, letter by letter, and say 'next' when you're done", startListeningForName);
149
  });
150
  }
151