Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +18 -10
templates/index.html
CHANGED
@@ -76,7 +76,7 @@
|
|
76 |
|
77 |
if ('webkitSpeechRecognition' in window) {
|
78 |
recognition = new webkitSpeechRecognition();
|
79 |
-
recognition.continuous =
|
80 |
recognition.interimResults = false;
|
81 |
recognition.lang = 'en-US';
|
82 |
} else {
|
@@ -90,17 +90,21 @@
|
|
90 |
}
|
91 |
|
92 |
function startListeningForName() {
|
|
|
93 |
recognition.start();
|
94 |
recognition.onresult = function(event) {
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
97 |
recognition.stop();
|
98 |
setTimeout(confirmName, 500);
|
99 |
};
|
100 |
}
|
101 |
|
102 |
function confirmName() {
|
103 |
-
speak("You said " + nameCaptured + ". Is it okay, or do you want to change it?", function() {
|
104 |
recognition.start();
|
105 |
recognition.onresult = function(event) {
|
106 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
@@ -108,19 +112,23 @@
|
|
108 |
if (confirmation.includes("ok") || confirmation.includes("yes")) {
|
109 |
setTimeout(() => speak("Great! Now, tell me your email.", startListeningForEmail), 500);
|
110 |
} else {
|
111 |
-
setTimeout(() => speak("Let's try again. Tell me your name.", startListeningForName), 500);
|
112 |
}
|
113 |
};
|
114 |
});
|
115 |
}
|
116 |
|
117 |
function startListeningForEmail() {
|
|
|
118 |
recognition.start();
|
119 |
recognition.onresult = function(event) {
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
122 |
recognition.stop();
|
123 |
-
speak("You said " + emailCaptured + ". Is it correct?", function() {
|
124 |
recognition.start();
|
125 |
recognition.onresult = function(event) {
|
126 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
@@ -129,7 +137,7 @@
|
|
129 |
speak("Your registration is complete. Thank you for registering.");
|
130 |
setTimeout(() => location.reload(), 20000);
|
131 |
} else {
|
132 |
-
speak("Let's try again. Tell me your email.", startListeningForEmail);
|
133 |
}
|
134 |
};
|
135 |
});
|
@@ -138,7 +146,7 @@
|
|
138 |
|
139 |
function startProcess() {
|
140 |
speak("Welcome to Biryani Hub", function() {
|
141 |
-
speak("Tell me your name, and I will confirm it with you.", function() {
|
142 |
setTimeout(startListeningForName, 500);
|
143 |
});
|
144 |
});
|
|
|
76 |
|
77 |
if ('webkitSpeechRecognition' in window) {
|
78 |
recognition = new webkitSpeechRecognition();
|
79 |
+
recognition.continuous = true;
|
80 |
recognition.interimResults = false;
|
81 |
recognition.lang = 'en-US';
|
82 |
} else {
|
|
|
90 |
}
|
91 |
|
92 |
function startListeningForName() {
|
93 |
+
nameCaptured = "";
|
94 |
recognition.start();
|
95 |
recognition.onresult = function(event) {
|
96 |
+
let transcript = event.results[event.results.length - 1][0].transcript.trim();
|
97 |
+
nameCaptured += transcript + " ";
|
98 |
+
document.getElementById('name').value = nameCaptured.trim();
|
99 |
+
};
|
100 |
+
recognition.onspeechend = function() {
|
101 |
recognition.stop();
|
102 |
setTimeout(confirmName, 500);
|
103 |
};
|
104 |
}
|
105 |
|
106 |
function confirmName() {
|
107 |
+
speak("You said " + nameCaptured.trim().split('').join(' ') + ". Is it okay, or do you want to change it?", function() {
|
108 |
recognition.start();
|
109 |
recognition.onresult = function(event) {
|
110 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
|
|
112 |
if (confirmation.includes("ok") || confirmation.includes("yes")) {
|
113 |
setTimeout(() => speak("Great! Now, tell me your email.", startListeningForEmail), 500);
|
114 |
} else {
|
115 |
+
setTimeout(() => speak("Let's try again. Tell me your name, letter by letter.", startListeningForName), 500);
|
116 |
}
|
117 |
};
|
118 |
});
|
119 |
}
|
120 |
|
121 |
function startListeningForEmail() {
|
122 |
+
emailCaptured = "";
|
123 |
recognition.start();
|
124 |
recognition.onresult = function(event) {
|
125 |
+
let transcript = event.results[event.results.length - 1][0].transcript.trim();
|
126 |
+
emailCaptured += transcript + " ";
|
127 |
+
document.getElementById('email').value = emailCaptured.trim();
|
128 |
+
};
|
129 |
+
recognition.onspeechend = function() {
|
130 |
recognition.stop();
|
131 |
+
speak("You said " + emailCaptured.trim() + ". Is it correct?", function() {
|
132 |
recognition.start();
|
133 |
recognition.onresult = function(event) {
|
134 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
|
|
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 |
});
|
|
|
146 |
|
147 |
function startProcess() {
|
148 |
speak("Welcome to Biryani Hub", function() {
|
149 |
+
speak("Tell me your name letter by letter, and I will confirm it with you.", function() {
|
150 |
setTimeout(startListeningForName, 500);
|
151 |
});
|
152 |
});
|