Spaces:
Runtime error
Runtime error
File size: 1,485 Bytes
0e1fb43 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
document.addEventListener('DOMContentLoaded', function() {
const synth = window.speechSynthesis;
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
recognition.continuous = false;
recognition.interimResults = false;
recognition.lang = 'en-US';
const speak = (text, callback) => {
const utterance = new SpeechSynthesisUtterance(text);
utterance.onend = callback;
synth.speak(utterance);
};
const startRecognition = (callback) => {
recognition.start();
recognition.onresult = (event) => {
const transcript = event.results[0][0].transcript;
callback(transcript);
recognition.stop();
};
};
const welcomeMessage = () => {
speak("Welcome to Biryani Hub. Tell me your name.", () => {
startRecognition((name) => {
document.getElementById('username').value = name;
askEmail();
});
});
};
const askEmail = () => {
speak("Please provide your email address.", () => {
startRecognition((email) => {
document.getElementById('email').value = email;
speak("Thank you. Your email has been registered.", () => {
setTimeout(() => {
location.reload();
}, 20000);
});
});
});
};
welcomeMessage();
}); |