geethareddy commited on
Commit
2968c0c
·
verified ·
1 Parent(s): 839c2c5

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +12 -8
templates/index.html CHANGED
@@ -71,7 +71,7 @@
71
  if ('webkitSpeechRecognition' in window) {
72
  recognition = new webkitSpeechRecognition();
73
  recognition.continuous = false;
74
- recognition.interimResults = false;
75
  recognition.lang = 'en-US';
76
  } else {
77
  alert("Speech Recognition API is not supported in this browser.");
@@ -86,11 +86,13 @@
86
  function startListeningForName() {
87
  document.getElementById('status').textContent = "Listening for your name...";
88
  recognition.start();
89
-
90
  recognition.onresult = function(event) {
91
- const transcript = event.results[0][0].transcript.trim();
92
- document.getElementById('name').value = transcript;
93
- recognition.stop();
 
 
94
  speak("Please provide your email address", startListeningForEmail);
95
  };
96
  }
@@ -98,12 +100,14 @@
98
  function startListeningForEmail() {
99
  document.getElementById('status').textContent = "Listening for your email...";
100
  recognition.start();
101
-
102
  recognition.onresult = function(event) {
103
  let transcript = event.results[0][0].transcript.trim();
104
  transcript = transcript.replace(/\bat\b/g, '@').replace(/\bdot\b/g, '.');
105
- document.getElementById('email').value = transcript;
106
- recognition.stop();
 
 
107
  speak("Registration complete. You can proceed with your order.");
108
  };
109
  }
 
71
  if ('webkitSpeechRecognition' in window) {
72
  recognition = new webkitSpeechRecognition();
73
  recognition.continuous = false;
74
+ recognition.interimResults = true;
75
  recognition.lang = 'en-US';
76
  } else {
77
  alert("Speech Recognition API is not supported in this browser.");
 
86
  function startListeningForName() {
87
  document.getElementById('status').textContent = "Listening for your name...";
88
  recognition.start();
89
+ let finalText = "";
90
  recognition.onresult = function(event) {
91
+ let transcript = event.results[0][0].transcript.trim();
92
+ finalText += transcript.replace(/\s+/g, "");
93
+ document.getElementById('name').value = finalText;
94
+ };
95
+ recognition.onend = function() {
96
  speak("Please provide your email address", startListeningForEmail);
97
  };
98
  }
 
100
  function startListeningForEmail() {
101
  document.getElementById('status').textContent = "Listening for your email...";
102
  recognition.start();
103
+ let finalText = "";
104
  recognition.onresult = function(event) {
105
  let transcript = event.results[0][0].transcript.trim();
106
  transcript = transcript.replace(/\bat\b/g, '@').replace(/\bdot\b/g, '.');
107
+ finalText += transcript.replace(/\s+/g, "");
108
+ document.getElementById('email').value = finalText;
109
+ };
110
+ recognition.onend = function() {
111
  speak("Registration complete. You can proceed with your order.");
112
  };
113
  }