voicemenuspe / templates /dashboard.html
lokesh341's picture
Update templates/dashboard.html
b338c76 verified
raw
history blame
3.26 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard - Biryani Hub</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
}
.dashboard-container {
max-width: 900px;
margin: 50px auto;
padding: 20px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 8px;
text-align: center;
}
h1 {
font-size: 2.5rem;
color: #333;
margin-bottom: 20px;
}
p {
font-size: 1.2rem;
color: #666;
margin-bottom: 30px;
}
a {
text-decoration: none;
color: #4CAF50;
font-weight: bold;
font-size: 1.2rem;
transition: color 0.3s;
}
a:hover {
color: #45a049;
}
#listen-btn {
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 1.2rem;
}
#listen-btn:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="dashboard-container">
<h1>Welcome to the Dashboard</h1>
<p>This is your user dashboard where you can access various features.</p>
<a href="/menu">Go to Menu</a>
<button id="listen-btn">Say "Go to Menu"</button>
</div>
<script>
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
const recognition = new SpeechRecognition();
recognition.lang = 'en-US';
recognition.interimResults = false;
recognition.maxAlternatives = 1;
function speak(text, callback) {
const msg = new SpeechSynthesisUtterance(text);
msg.rate = 1;
msg.onend = callback; // Call the function after speech ends
window.speechSynthesis.speak(msg);
}
function startListening() {
recognition.start();
}
recognition.onresult = (event) => {
const command = event.results[0][0].transcript.toLowerCase();
console.log("User said:", command);
if (command.includes("go to menu")) {
window.location.href = "/menu";
}
};
recognition.onerror = (event) => {
console.error("Speech recognition error:", event.error);
speak("Sorry, I couldn't understand that. Please try again.");
};
// Automatic speaking and listening on page load
window.onload = function () {
speak("Go to Menu", startListening);
};
// Button for manual listening (optional)
document.getElementById("listen-btn").addEventListener("click", () => {
speak("Please say 'Go to Menu' to navigate to the menu.", startListening);
});
</script>
</body>
</html>