lokesh341 commited on
Commit
b338c76
·
verified ·
1 Parent(s): fd2f5b6

Update templates/dashboard.html

Browse files
Files changed (1) hide show
  1. templates/dashboard.html +18 -23
templates/dashboard.html CHANGED
@@ -1,11 +1,11 @@
1
  <!DOCTYPE html>
2
  <html lang="en">
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Dashboard - Biryani Hub</title>
7
  <style>
8
- /* General Body Styling */
9
  body {
10
  font-family: Arial, sans-serif;
11
  background-color: #f0f0f0;
@@ -13,7 +13,6 @@
13
  padding: 0;
14
  }
15
 
16
- /* Container for the dashboard content */
17
  .dashboard-container {
18
  max-width: 900px;
19
  margin: 50px auto;
@@ -24,21 +23,18 @@
24
  text-align: center;
25
  }
26
 
27
- /* Heading Style */
28
  h1 {
29
  font-size: 2.5rem;
30
  color: #333;
31
  margin-bottom: 20px;
32
  }
33
 
34
- /* Paragraph Style */
35
  p {
36
  font-size: 1.2rem;
37
  color: #666;
38
  margin-bottom: 30px;
39
  }
40
 
41
- /* Link Style */
42
  a {
43
  text-decoration: none;
44
  color: #4CAF50;
@@ -51,7 +47,6 @@
51
  color: #45a049;
52
  }
53
 
54
- /* Button for listening */
55
  #listen-btn {
56
  padding: 10px 20px;
57
  background-color: #4CAF50;
@@ -67,59 +62,59 @@
67
  }
68
  </style>
69
  </head>
 
70
  <body>
71
 
72
  <div class="dashboard-container">
73
  <h1>Welcome to the Dashboard</h1>
74
  <p>This is your user dashboard where you can access various features.</p>
75
  <a href="/menu">Go to Menu</a>
76
-
77
- <!-- Button for triggering voice recognition -->
78
  <button id="listen-btn">Say "Go to Menu"</button>
79
  </div>
80
 
81
  <script>
82
- // Speech Recognition and Speech Synthesis for voice interaction
83
-
84
- // Check for SpeechRecognition support
85
  const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
86
  const recognition = new SpeechRecognition();
87
  recognition.lang = 'en-US';
88
  recognition.interimResults = false;
89
  recognition.maxAlternatives = 1;
90
 
91
- // Function to speak the message
92
- function speak(text) {
93
  const msg = new SpeechSynthesisUtterance(text);
94
- msg.rate = 1; // Speed of speech
 
95
  window.speechSynthesis.speak(msg);
96
  }
97
 
98
- // Button for listening to user input
99
- const listenButton = document.getElementById("listen-btn");
100
-
101
- listenButton.addEventListener("click", () => {
102
- speak("Please say 'Go to Menu' to navigate to the menu.");
103
  recognition.start();
104
- });
105
 
106
- // Handle speech recognition result
107
  recognition.onresult = (event) => {
108
  const command = event.results[0][0].transcript.toLowerCase();
109
  console.log("User said:", command);
110
 
111
- // If user says "Go to Menu", navigate to the menu
112
  if (command.includes("go to menu")) {
113
  window.location.href = "/menu";
114
  }
115
  };
116
 
117
- // Handle errors in speech recognition
118
  recognition.onerror = (event) => {
119
  console.error("Speech recognition error:", event.error);
120
  speak("Sorry, I couldn't understand that. Please try again.");
121
  };
 
 
 
 
 
 
 
 
 
 
122
  </script>
123
 
124
  </body>
 
125
  </html>
 
1
  <!DOCTYPE html>
2
  <html lang="en">
3
+
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
  <title>Dashboard - Biryani Hub</title>
8
  <style>
 
9
  body {
10
  font-family: Arial, sans-serif;
11
  background-color: #f0f0f0;
 
13
  padding: 0;
14
  }
15
 
 
16
  .dashboard-container {
17
  max-width: 900px;
18
  margin: 50px auto;
 
23
  text-align: center;
24
  }
25
 
 
26
  h1 {
27
  font-size: 2.5rem;
28
  color: #333;
29
  margin-bottom: 20px;
30
  }
31
 
 
32
  p {
33
  font-size: 1.2rem;
34
  color: #666;
35
  margin-bottom: 30px;
36
  }
37
 
 
38
  a {
39
  text-decoration: none;
40
  color: #4CAF50;
 
47
  color: #45a049;
48
  }
49
 
 
50
  #listen-btn {
51
  padding: 10px 20px;
52
  background-color: #4CAF50;
 
62
  }
63
  </style>
64
  </head>
65
+
66
  <body>
67
 
68
  <div class="dashboard-container">
69
  <h1>Welcome to the Dashboard</h1>
70
  <p>This is your user dashboard where you can access various features.</p>
71
  <a href="/menu">Go to Menu</a>
 
 
72
  <button id="listen-btn">Say "Go to Menu"</button>
73
  </div>
74
 
75
  <script>
 
 
 
76
  const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
77
  const recognition = new SpeechRecognition();
78
  recognition.lang = 'en-US';
79
  recognition.interimResults = false;
80
  recognition.maxAlternatives = 1;
81
 
82
+ function speak(text, callback) {
 
83
  const msg = new SpeechSynthesisUtterance(text);
84
+ msg.rate = 1;
85
+ msg.onend = callback; // Call the function after speech ends
86
  window.speechSynthesis.speak(msg);
87
  }
88
 
89
+ function startListening() {
 
 
 
 
90
  recognition.start();
91
+ }
92
 
 
93
  recognition.onresult = (event) => {
94
  const command = event.results[0][0].transcript.toLowerCase();
95
  console.log("User said:", command);
96
 
 
97
  if (command.includes("go to menu")) {
98
  window.location.href = "/menu";
99
  }
100
  };
101
 
 
102
  recognition.onerror = (event) => {
103
  console.error("Speech recognition error:", event.error);
104
  speak("Sorry, I couldn't understand that. Please try again.");
105
  };
106
+
107
+ // Automatic speaking and listening on page load
108
+ window.onload = function () {
109
+ speak("Go to Menu", startListening);
110
+ };
111
+
112
+ // Button for manual listening (optional)
113
+ document.getElementById("listen-btn").addEventListener("click", () => {
114
+ speak("Please say 'Go to Menu' to navigate to the menu.", startListening);
115
+ });
116
  </script>
117
 
118
  </body>
119
+
120
  </html>