File size: 4,177 Bytes
7101975
 
 
 
 
0770706
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a09353c
c4d6896
a09353c
 
 
 
 
 
 
c4d6896
a09353c
c4d6896
a09353c
 
0770706
7101975
 
0770706
 
 
 
 
a09353c
 
4e55c66
c4d6896
 
 
0770706
 
a09353c
 
 
 
c4d6896
 
 
 
 
 
 
 
 
 
 
 
 
 
a09353c
c4d6896
 
 
4e55c66
c4d6896
 
 
 
 
 
 
 
 
 
4e55c66
 
 
8f8bed9
c4d6896
 
 
 
 
 
 
 
 
a09353c
 
7101975
4e55c66
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!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>
        /* General Body Styling */
        body {
            font-family: Arial, sans-serif;
            background-color: #f0f0f0;
            margin: 0;
            padding: 0;
        }
        /* Container for the dashboard content */
        .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;
        }
        /* Heading Style */
        h1 {
            font-size: 2.5rem;
            color: #333;
            margin-bottom: 20px;
        }
        /* Paragraph Style */
        p {
            font-size: 1.2rem;
            color: #666;
            margin-bottom: 30px;
        }
        /* Link Style */
        a {
            text-decoration: none;
            color: #4CAF50;
            font-weight: bold;
            font-size: 1.2rem;
            transition: color 0.3s;
        }
        a:hover {
            color: #45a049;
        }
        /* Button for listening */
        #listen-btn, #logout-btn {
            padding: 10px 20px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 1.2rem;
            margin-top: 20px;
        }
        #listen-btn:hover, #logout-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 for triggering voice recognition -->
        <button id="listen-btn">Say "Go to Menu" or "Logout"</button>

        <!-- Logout Button -->
        <button id="logout-btn" onclick="logout()">Logout</button>
    </div>

    <script>
        // Check for SpeechRecognition support
        const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;

        if (!SpeechRecognition) {
            alert("Your browser does not support speech recognition. Please use Chrome.");
        } else {
            const recognition = new SpeechRecognition();
            recognition.lang = 'en-US';
            recognition.interimResults = false;
            recognition.maxAlternatives = 1;

            // Function to speak the message
            function speak(text) {
                const msg = new SpeechSynthesisUtterance(text);
                msg.rate = 1;  // Speed of speech
                window.speechSynthesis.speak(msg);
            }

            // Button for listening to user input
            const listenButton = document.getElementById("listen-btn");
            listenButton.addEventListener("click", () => {
                speak("Please say 'Go to Menu' to navigate to the menu or 'Logout' to log out.");
                recognition.start();
            });

            // Handle speech recognition result
            recognition.onresult = (event) => {
                const command = event.results[0][0].transcript.toLowerCase();
                console.log("User said:", command);
                // If user says "Go to Menu", navigate to the menu
                if (command.includes("go to menu")) {
                    window.location.href = "/menu";
                } 
                // If user says "Logout", log out
                else if (command.includes("logout")) {
                    window.location.href = "/login"; // Redirect to login page
                }
            };

            // Handle errors in speech recognition
            recognition.onerror = (event) => {
                console.error("Speech recognition error:", event.error);
                speak("Sorry, I couldn't understand that. Please try again.");
            };
        }
    </script>

</body>
</html>