|
12 | 12 | <!-- Timestamp Display for Debugging --> |
13 | 13 | <div id="timestampDisplay" class="timestamp-display">0.00s</div> |
14 | 14 |
|
| 15 | + <!-- Recognition Counter Display --> |
| 16 | + <div id="recogniseCounter" class="recognise-counter">Recognize: 0 words</div> |
| 17 | + |
15 | 18 | <div class="outside-notes"> |
16 | 19 | <div class="floating-note">🎵</div> |
17 | 20 | <div class="floating-note">🎶</div> |
@@ -161,6 +164,28 @@ <h3>🎵 Audio Tracks</h3> |
161 | 164 | // Audio MIME type constant (all songs are MP3) |
162 | 165 | const AUDIO_MIME_TYPE = 'audio/mpeg'; |
163 | 166 |
|
| 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 | + |
164 | 189 | // Initialize when DOM is loaded |
165 | 190 | document.addEventListener('DOMContentLoaded', function () { |
166 | 191 | // Get references to audio elements |
@@ -191,6 +216,9 @@ <h3>🎵 Audio Tracks</h3> |
191 | 216 | timestampDisplay: document.getElementById('timestampDisplay') |
192 | 217 | }); |
193 | 218 |
|
| 219 | + // Update recognition counter display |
| 220 | + updateRecogniseCounter(); |
| 221 | + |
194 | 222 | // Reset when songs end |
195 | 223 | song1.addEventListener('ended', () => { |
196 | 224 | song1.currentTime = 0; |
|
0 commit comments