-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
105 lines (82 loc) · 2.99 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>UniCHAT</title>
<script defer src="http://localhost:8000/socket.io/socket.io.js"></script>
<script defer src="js/client.js"></script>
<link rel="stylesheet" href="css/style.css">
<script>
function changeLight(){
document.body.style.background = "linear-gradient(45deg,#ffffff, #555555)" ;
}
function changeDark(){
document.body.style.background = "linear-gradient(45deg,#010758, #490d61)" ;
}
</script>
</head>
<body>
<div class="header">
<div class="logo-div">
<img class="logo" src="logo.png" alt="logo">
</div>
<div class="heading">
<h1>UniCHAT</h1>
</div>
<div id="mySidebar" class="sidebar">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<ul>
<button class="dropbtn">Theme</button>
<div class="dropdown-content">
<a href="#" onclick="changeLight()">Light Theme</a>
<a href="#" onclick="changeDark()">Dark Theme</a>
</div>
</div>
</ul>
</div>
<div id="main">
<button class="openbtn" onclick="openNav()">☰ Settings</button>
</div>
</div>
<div class="container"></div>
<div class="send">
<form action="#" id="send-container">
<input type="text" name="messageInp" id="messageInp">
<button class="btn btn1" type="submit">Send</button>
</form>
<button class="btn btn2" id ='btn2'><img class="img1" src="mic.png" alt="listen" width="50px" height="50px"></button>
<button class="btn btn3" id ='btn3' disabled>Stop</button>
</div>
<script>
const startButton = document.getElementById('btn2');
const stopButton = document.getElementById('btn3');
const result = document.getElementById('messageInp');
let recognition;
startButton.addEventListener('click', () => {
recognition = new webkitSpeechRecognition();
recognition.onstart = () => {
console.log('Listening started...');
startButton.disabled = true;
stopButton.disabled = false;
};
recognition.onresult = event => {
const transcript = event.results[0][0].transcript;
result.value = transcript;
console.log(transcript)
};
recognition.onend = () => {
console.log('Listening stopped.');
startButton.disabled = false;
stopButton.disabled = true;
};
recognition.start();
});
stopButton.addEventListener('click', () => {
if (recognition) {
recognition.stop();
}
});
</script>
</body>
</html>