-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
60 lines (48 loc) · 1.61 KB
/
Copy pathindex.html
File metadata and controls
60 lines (48 loc) · 1.61 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Auto Pronounce Word</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" />
</head>
<body class="bg-light">
<div class="container py-5 text-center">
<h2 class="mb-4">🔊 Pronounce a Word</h2>
<div class="mb-3">
<input
type="text"
id="wordInput"
class="form-control form-control-lg text-center"
placeholder="Enter a word"
onkeydown="if (event.key === 'Enter') playPronunciation()"
/>
</div>
<button onclick="playPronunciation()" class="btn btn-primary btn-lg w-100 mb-3">
🔈 Pronounce
</button>
<p id="status" class="fs-5"></p>
<a href="quiz.html" class="btn btn-success btn-lg w-100 mt-4">🧠 Go to Quiz</a>
</div>
<script>
async function playPronunciation() {
const input = document.getElementById("wordInput");
const word = input.value.trim().toLowerCase();
if (!word) return alert("Please enter a word!");
const status = document.getElementById("status");
status.textContent = "🔍 Checking cache...";
const audioPath = `audio/${word}.mp3`;
const audio = new Audio(audioPath);
audio.onerror = () => {
status.textContent = "❌ Incorrect: Audio not found.";
};
audio.oncanplaythrough = () => {
audio.play();
status.textContent = "✅ Correct: Playing audio!";
};
audio.load();
input.value = "";
}
</script>
</body>
</html>