-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmock.html
47 lines (36 loc) · 1.52 KB
/
mock.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Audio Recorder</title>
</head>
<body>
<button id="startButton">Start Listening</button>
<button id="stopButton" style="display: none;">Stop Listening</button>
<div id="output"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js"></script>
<script>
var socket = io.connect('http://127.0.0.1:5000');
document.getElementById('startButton').addEventListener('click', function() {
socket.emit('listen', {data: 'Start listening for audio'});
document.getElementById('startButton').style.display = 'none';
document.getElementById('stopButton').style.display = 'inline';
});
document.getElementById('stopButton').addEventListener('click', function() {
socket.emit('exit', {data: 'Stop listening for audio'});
document.getElementById('stopButton').style.display = 'none';
document.getElementById('startButton').style.display = 'inline';
});
socket.on('message', function(message) {
console.log('Message from server:', message);
});
socket.on('prediction', function(pred) {
document.getElementById('output').innerHTML = pred;
});
socket.on('disconnect', function() {
console.log('Disconnected from server');
});
</script>
</body>
</html>