lokesh341 commited on
Commit
335f801
·
verified ·
1 Parent(s): 37abee5

Update dashboard.html

Browse files
Files changed (1) hide show
  1. dashboard.html +9 -23
dashboard.html CHANGED
@@ -45,19 +45,6 @@
45
  a:hover {
46
  color: #45a049;
47
  }
48
- /* Button for listening */
49
- #listen-btn {
50
- padding: 10px 20px;
51
- background-color: #4CAF50;
52
- color: white;
53
- border: none;
54
- border-radius: 5px;
55
- cursor: pointer;
56
- font-size: 1.2rem;
57
- }
58
- #listen-btn:hover {
59
- background-color: #45a049;
60
- }
61
  </style>
62
  </head>
63
  <body>
@@ -66,9 +53,6 @@
66
  <h1>Welcome to the Dashboard</h1>
67
  <p>This is your user dashboard where you can access various features.</p>
68
  <a href="/menu">Go to Menu</a>
69
-
70
- <!-- Button for triggering voice recognition -->
71
- <button id="listen-btn">Say "Go to Menu"</button>
72
  </div>
73
 
74
  <script>
@@ -79,18 +63,18 @@
79
  recognition.lang = 'en-US';
80
  recognition.interimResults = false;
81
  recognition.maxAlternatives = 1;
 
82
  // Function to speak the message
83
  function speak(text) {
84
  const msg = new SpeechSynthesisUtterance(text);
85
  msg.rate = 1; // Speed of speech
86
  window.speechSynthesis.speak(msg);
87
  }
88
- // Button for listening to user input
89
- const listenButton = document.getElementById("listen-btn");
90
- listenButton.addEventListener("click", () => {
91
- speak("Please say 'Go to Menu' to navigate to the menu.");
92
- recognition.start();
93
- });
94
  // Handle speech recognition result
95
  recognition.onresult = (event) => {
96
  const command = event.results[0][0].transcript.toLowerCase();
@@ -100,12 +84,14 @@
100
  window.location.href = "/menu";
101
  }
102
  };
 
103
  // Handle errors in speech recognition
104
  recognition.onerror = (event) => {
105
  console.error("Speech recognition error:", event.error);
106
  speak("Sorry, I couldn't understand that. Please try again.");
 
107
  };
108
  </script>
109
 
110
  </body>
111
- </html>
 
45
  a:hover {
46
  color: #45a049;
47
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  </style>
49
  </head>
50
  <body>
 
53
  <h1>Welcome to the Dashboard</h1>
54
  <p>This is your user dashboard where you can access various features.</p>
55
  <a href="/menu">Go to Menu</a>
 
 
 
56
  </div>
57
 
58
  <script>
 
63
  recognition.lang = 'en-US';
64
  recognition.interimResults = false;
65
  recognition.maxAlternatives = 1;
66
+
67
  // Function to speak the message
68
  function speak(text) {
69
  const msg = new SpeechSynthesisUtterance(text);
70
  msg.rate = 1; // Speed of speech
71
  window.speechSynthesis.speak(msg);
72
  }
73
+
74
+ // Automatically prompt the user to say "Go to Menu"
75
+ speak("Please say 'Go to Menu' to navigate to the menu.");
76
+ recognition.start();
77
+
 
78
  // Handle speech recognition result
79
  recognition.onresult = (event) => {
80
  const command = event.results[0][0].transcript.toLowerCase();
 
84
  window.location.href = "/menu";
85
  }
86
  };
87
+
88
  // Handle errors in speech recognition
89
  recognition.onerror = (event) => {
90
  console.error("Speech recognition error:", event.error);
91
  speak("Sorry, I couldn't understand that. Please try again.");
92
+ recognition.start(); // Restart listening
93
  };
94
  </script>
95
 
96
  </body>
97
+ </html>