Spaces:
Runtime error
Runtime error
Update templates/index.html
Browse files- templates/index.html +13 -0
templates/index.html
CHANGED
|
@@ -6,6 +6,8 @@
|
|
| 6 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"></link>
|
| 7 |
<script>
|
| 8 |
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
|
|
|
| 9 |
const synth = window.speechSynthesis;
|
| 10 |
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
|
| 11 |
recognition.continuous = false;
|
|
@@ -13,23 +15,31 @@
|
|
| 13 |
recognition.lang = 'en-US';
|
| 14 |
|
| 15 |
const speak = (text, callback) => {
|
|
|
|
| 16 |
const utterance = new SpeechSynthesisUtterance(text);
|
| 17 |
utterance.onend = callback;
|
| 18 |
synth.speak(utterance);
|
| 19 |
};
|
| 20 |
|
| 21 |
const startRecognition = (callback) => {
|
|
|
|
| 22 |
recognition.start();
|
| 23 |
recognition.onresult = (event) => {
|
| 24 |
const transcript = event.results[0][0].transcript;
|
|
|
|
| 25 |
callback(transcript);
|
| 26 |
recognition.stop();
|
| 27 |
};
|
|
|
|
|
|
|
|
|
|
| 28 |
};
|
| 29 |
|
| 30 |
const welcomeMessage = () => {
|
|
|
|
| 31 |
speak("Welcome to Biryani Hub. Tell me your name.", () => {
|
| 32 |
startRecognition((name) => {
|
|
|
|
| 33 |
document.getElementById('username').value = name;
|
| 34 |
askEmail();
|
| 35 |
});
|
|
@@ -37,10 +47,13 @@
|
|
| 37 |
};
|
| 38 |
|
| 39 |
const askEmail = () => {
|
|
|
|
| 40 |
speak("Please provide your email address.", () => {
|
| 41 |
startRecognition((email) => {
|
|
|
|
| 42 |
document.getElementById('email').value = email;
|
| 43 |
speak("Thank you. Your email has been registered.", () => {
|
|
|
|
| 44 |
setTimeout(() => {
|
| 45 |
location.reload();
|
| 46 |
}, 20000);
|
|
|
|
| 6 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"></link>
|
| 7 |
<script>
|
| 8 |
document.addEventListener('DOMContentLoaded', function() {
|
| 9 |
+
console.log("Page loaded. Initializing voice interaction...");
|
| 10 |
+
|
| 11 |
const synth = window.speechSynthesis;
|
| 12 |
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
|
| 13 |
recognition.continuous = false;
|
|
|
|
| 15 |
recognition.lang = 'en-US';
|
| 16 |
|
| 17 |
const speak = (text, callback) => {
|
| 18 |
+
console.log("Speaking:", text);
|
| 19 |
const utterance = new SpeechSynthesisUtterance(text);
|
| 20 |
utterance.onend = callback;
|
| 21 |
synth.speak(utterance);
|
| 22 |
};
|
| 23 |
|
| 24 |
const startRecognition = (callback) => {
|
| 25 |
+
console.log("Starting speech recognition...");
|
| 26 |
recognition.start();
|
| 27 |
recognition.onresult = (event) => {
|
| 28 |
const transcript = event.results[0][0].transcript;
|
| 29 |
+
console.log("Recognized speech:", transcript);
|
| 30 |
callback(transcript);
|
| 31 |
recognition.stop();
|
| 32 |
};
|
| 33 |
+
recognition.onerror = (event) => {
|
| 34 |
+
console.error("Speech recognition error:", event.error);
|
| 35 |
+
};
|
| 36 |
};
|
| 37 |
|
| 38 |
const welcomeMessage = () => {
|
| 39 |
+
console.log("Starting welcome message...");
|
| 40 |
speak("Welcome to Biryani Hub. Tell me your name.", () => {
|
| 41 |
startRecognition((name) => {
|
| 42 |
+
console.log("Name recognized:", name);
|
| 43 |
document.getElementById('username').value = name;
|
| 44 |
askEmail();
|
| 45 |
});
|
|
|
|
| 47 |
};
|
| 48 |
|
| 49 |
const askEmail = () => {
|
| 50 |
+
console.log("Asking for email...");
|
| 51 |
speak("Please provide your email address.", () => {
|
| 52 |
startRecognition((email) => {
|
| 53 |
+
console.log("Email recognized:", email);
|
| 54 |
document.getElementById('email').value = email;
|
| 55 |
speak("Thank you. Your email has been registered.", () => {
|
| 56 |
+
console.log("Registration complete. Reloading page in 20 seconds...");
|
| 57 |
setTimeout(() => {
|
| 58 |
location.reload();
|
| 59 |
}, 20000);
|