lokesh341 commited on
Commit
743226a
·
verified ·
1 Parent(s): 1d17343

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +30 -1
templates/index.html CHANGED
@@ -65,6 +65,9 @@
65
  <label for="email">Your Email</label>
66
  <input type="text" id="email" placeholder="Your email will appear here..." readonly>
67
 
 
 
 
68
  <p class="info" id="infoMessage">Listening will start automatically...</p>
69
  <p class="status" id="status">Initializing...</p>
70
  </div>
@@ -73,6 +76,7 @@
73
  let recognition;
74
  let nameCaptured = "";
75
  let emailCaptured = "";
 
76
 
77
  if ('webkitSpeechRecognition' in window) {
78
  recognition = new webkitSpeechRecognition();
@@ -129,6 +133,31 @@
129
  recognition.onspeechend = function() {
130
  recognition.stop();
131
  speak("You said " + emailCaptured + ". Is it correct?", function() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  recognition.start();
133
  recognition.onresult = function(event) {
134
  let confirmation = event.results[0][0].transcript.trim().toLowerCase();
@@ -137,7 +166,7 @@
137
  speak("Your registration is complete. Thank you for registering.");
138
  setTimeout(() => location.reload(), 20000);
139
  } else {
140
- speak("Let's try again. Tell me your email letter by letter.", startListeningForEmail);
141
  }
142
  };
143
  });
 
65
  <label for="email">Your Email</label>
66
  <input type="text" id="email" placeholder="Your email will appear here..." readonly>
67
 
68
+ <label for="mobile">Your Mobile Number</label>
69
+ <input type="text" id="mobile" placeholder="Your mobile number will appear here..." readonly>
70
+
71
  <p class="info" id="infoMessage">Listening will start automatically...</p>
72
  <p class="status" id="status">Initializing...</p>
73
  </div>
 
76
  let recognition;
77
  let nameCaptured = "";
78
  let emailCaptured = "";
79
+ let mobileCaptured = "";
80
 
81
  if ('webkitSpeechRecognition' in window) {
82
  recognition = new webkitSpeechRecognition();
 
133
  recognition.onspeechend = function() {
134
  recognition.stop();
135
  speak("You said " + emailCaptured + ". Is it correct?", function() {
136
+ recognition.start();
137
+ recognition.onresult = function(event) {
138
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
139
+ recognition.stop();
140
+ if (confirmation.includes("ok") || confirmation.includes("yes")) {
141
+ setTimeout(() => speak("Great! Now, tell me your mobile number.", startListeningForMobile), 500);
142
+ } else {
143
+ speak("Let's try again. Tell me your email letter by letter.", startListeningForEmail);
144
+ }
145
+ };
146
+ });
147
+ };
148
+ }
149
+
150
+ function startListeningForMobile() {
151
+ mobileCaptured = "";
152
+ recognition.start();
153
+ recognition.onresult = function(event) {
154
+ let transcript = event.results[event.results.length - 1][0].transcript.trim().replace(/\s+/g, "");
155
+ mobileCaptured += transcript;
156
+ document.getElementById('mobile').value = mobileCaptured;
157
+ };
158
+ recognition.onspeechend = function() {
159
+ recognition.stop();
160
+ speak("You said " + mobileCaptured + ". Is it correct?", function() {
161
  recognition.start();
162
  recognition.onresult = function(event) {
163
  let confirmation = event.results[0][0].transcript.trim().toLowerCase();
 
166
  speak("Your registration is complete. Thank you for registering.");
167
  setTimeout(() => location.reload(), 20000);
168
  } else {
169
+ speak("Let's try again. Tell me your mobile number.", startListeningForMobile);
170
  }
171
  };
172
  });