Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +20 -19
templates/index.html
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
|
2 |
<!DOCTYPE html>
|
3 |
<html lang="en">
|
4 |
<head>
|
@@ -116,8 +115,8 @@
|
|
116 |
let recognition;
|
117 |
if ('webkitSpeechRecognition' in window) {
|
118 |
recognition = new webkitSpeechRecognition();
|
119 |
-
recognition.continuous =
|
120 |
-
recognition.interimResults = false;
|
121 |
recognition.lang = 'en-US';
|
122 |
} else {
|
123 |
alert("Speech Recognition API is not supported in this browser.");
|
@@ -129,8 +128,25 @@
|
|
129 |
window.speechSynthesis.speak(speech);
|
130 |
}
|
131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
function askLoginOrRegister() {
|
133 |
-
speak("
|
134 |
recognition.start();
|
135 |
recognition.onresult = function (event) {
|
136 |
let response = event.results[0][0].transcript.trim().toLowerCase();
|
@@ -160,21 +176,6 @@
|
|
160 |
document.getElementById('loginForm').style.display = 'block';
|
161 |
}
|
162 |
|
163 |
-
function listenForGreeting() {
|
164 |
-
speak("Please say 'Hi Biryani Hub' to proceed.", function () {
|
165 |
-
recognition.start();
|
166 |
-
recognition.onresult = function (event) {
|
167 |
-
let response = event.results[0][0].transcript.trim().toLowerCase();
|
168 |
-
recognition.stop();
|
169 |
-
if (response.includes("hi biryani hub")) {
|
170 |
-
askLoginOrRegister(); // Proceed to ask whether they are new or existing
|
171 |
-
} else {
|
172 |
-
speak("I didn't hear 'Hi Biryani Hub'. Please say it to proceed.", listenForGreeting);
|
173 |
-
}
|
174 |
-
};
|
175 |
-
});
|
176 |
-
}
|
177 |
-
|
178 |
// This will ask the user for the login or register information
|
179 |
function captureLoginDetails() {
|
180 |
speak("Please say your email for login.", function () {
|
|
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
<head>
|
|
|
115 |
let recognition;
|
116 |
if ('webkitSpeechRecognition' in window) {
|
117 |
recognition = new webkitSpeechRecognition();
|
118 |
+
recognition.continuous = false; // Listen once for the wake word
|
119 |
+
recognition.interimResults = false; // Do not return interim results
|
120 |
recognition.lang = 'en-US';
|
121 |
} else {
|
122 |
alert("Speech Recognition API is not supported in this browser.");
|
|
|
128 |
window.speechSynthesis.speak(speech);
|
129 |
}
|
130 |
|
131 |
+
// Function to listen for the wake word
|
132 |
+
function listenForGreeting() {
|
133 |
+
recognition.start();
|
134 |
+
recognition.onresult = function (event) {
|
135 |
+
let response = event.results[0][0].transcript.trim().toLowerCase();
|
136 |
+
recognition.stop();
|
137 |
+
if (response.includes("hi biryani hub")) {
|
138 |
+
speak("How can I assist you today?", function () {
|
139 |
+
askLoginOrRegister(); // Proceed to ask whether they are new or existing
|
140 |
+
});
|
141 |
+
} else {
|
142 |
+
speak("I didn't hear 'Hi Biryani Hub'. Please say it to proceed.", listenForGreeting);
|
143 |
+
}
|
144 |
+
};
|
145 |
+
}
|
146 |
+
|
147 |
+
// Function to ask whether the user is new or existing
|
148 |
function askLoginOrRegister() {
|
149 |
+
speak("Are you a new customer or an existing customer? Say 'new' to register or 'existing' to login.", function () {
|
150 |
recognition.start();
|
151 |
recognition.onresult = function (event) {
|
152 |
let response = event.results[0][0].transcript.trim().toLowerCase();
|
|
|
176 |
document.getElementById('loginForm').style.display = 'block';
|
177 |
}
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
// This will ask the user for the login or register information
|
180 |
function captureLoginDetails() {
|
181 |
speak("Please say your email for login.", function () {
|