Skip to content

Commit 446b57f

Browse files
committed
Add the recognise count
1 parent a8c051c commit 446b57f

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

index.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
<!-- Timestamp Display for Debugging -->
1313
<div id="timestampDisplay" class="timestamp-display">0.00s</div>
1414

15+
<!-- Recognition Counter Display -->
16+
<div id="recogniseCounter" class="recognise-counter">Recognize: 0 words</div>
17+
1518
<div class="outside-notes">
1619
<div class="floating-note">🎵</div>
1720
<div class="floating-note">🎶</div>
@@ -161,6 +164,28 @@ <h3>🎵 Audio Tracks</h3>
161164
// Audio MIME type constant (all songs are MP3)
162165
const AUDIO_MIME_TYPE = 'audio/mpeg';
163166

167+
// Function to count and update recognition words display
168+
function updateRecogniseCounter() {
169+
let recogniseCount = 0;
170+
171+
// Count all words with recognise: true in the lyrics data
172+
if (window.lyricsData && window.lyricsData.sentences) {
173+
window.lyricsData.sentences.forEach(sentence => {
174+
sentence.words.forEach(word => {
175+
if (word.recognise === true) {
176+
recogniseCount++;
177+
}
178+
});
179+
});
180+
}
181+
182+
// Update the counter display
183+
const counterElement = document.getElementById('recogniseCounter');
184+
if (counterElement) {
185+
counterElement.textContent = `0/${recogniseCount}`;
186+
}
187+
}
188+
164189
// Initialize when DOM is loaded
165190
document.addEventListener('DOMContentLoaded', function () {
166191
// Get references to audio elements
@@ -191,6 +216,9 @@ <h3>🎵 Audio Tracks</h3>
191216
timestampDisplay: document.getElementById('timestampDisplay')
192217
});
193218

219+
// Update recognition counter display
220+
updateRecogniseCounter();
221+
194222
// Reset when songs end
195223
song1.addEventListener('ended', () => {
196224
song1.currentTime = 0;

style.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@ body {
2727
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
2828
}
2929

30+
/* Recognition Counter Display */
31+
.recognise-counter {
32+
position: fixed;
33+
top: 20px;
34+
left: 20px;
35+
background: rgba(147, 51, 234, 0.9);
36+
color: white;
37+
font-size: 12pt;
38+
font-family: 'Courier New', monospace;
39+
padding: 8px 12px;
40+
border-radius: 6px;
41+
border: 1px solid #9333ea;
42+
z-index: 1000;
43+
box-shadow: 0 2px 8px rgba(147, 51, 234, 0.3);
44+
font-weight: bold;
45+
}
46+
3047
@keyframes gradientShift {
3148
0%, 100% { background-position: 0% 50%; }
3249
50% { background-position: 100% 50%; }

0 commit comments

Comments
 (0)