Repository navigation
Expand file tree
/
Copy pathecho.html
More file actions
69 lines (66 loc) · 2.1 KB
/
Copy pathecho.html
File metadata and controls
69 lines (66 loc) · 2.1 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Mic Echo App</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f8f9fa;
}
#toggleBtn {
font-size:40px;
text-transform: uppercase;
width:50%;
height:20%;
font-weight:bold;
}
</style>
</head>
<body>
<button id="toggleBtn" class="btn btn-primary btn-lg">Echo</button>
<script>
let audioContext;
let micStream;
let source;
let isPlaying = false;
const button = document.getElementById('toggleBtn');
button.addEventListener('click', async () => {
if (!isPlaying) {
try {
audioContext = new (window.AudioContext || window.webkitAudioContext)();
micStream = await navigator.mediaDevices.getUserMedia({ audio: true });
source = audioContext.createMediaStreamSource(micStream);
source.connect(audioContext.destination); // Echo to output
isPlaying = true;
button.textContent = "Stop";
button.classList.remove("btn-primary");
button.classList.add("btn-danger");
} catch (err) {
console.error("Error accessing microphone", err);
}
} else {
source.disconnect();
micStream.getTracks().forEach(track => track.stop());
audioContext.close();
isPlaying = false;
button.textContent = "Echo";
button.classList.remove("btn-danger");
button.classList.add("btn-primary");
}
});
</script>
</body>
<footer style="text-align: center; font-size: 0.9em; margin-top: 2em; padding: 1em 0; color: #555;">
<p>
<a href="https://tools.itabu.xyz/" style="margin-right: 1em;">Home</a>
<a href="terms.html" target="_blank" style="margin-right: 1em;">Terms of Service</a>
<a href="privacy.html" target="_blank">Privacy Policy</a>
</p>
<p style="margin-top: 0.5em;">© 2025 i-Tabu Tool</p>
</footer>
</html>