Skip to content

Commit 348c1a4

Browse files
committed
wip
1 parent 24bf31d commit 348c1a4

1 file changed

Lines changed: 25 additions & 18 deletions

File tree

lyrics-engine.js

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,51 +22,51 @@ class LyricsEngine {
2222
},
2323
{
2424
words: [
25-
{ text: "How", duration: 0.49, recognise: true },
26-
{ text: "I", duration: 0.46, recognise: true },
27-
{ text: "wonder", duration: 1.32, recognise: true },
28-
{ text: "what", duration: 0.69, recognise: true },
29-
{ text: "you", duration: 0.46, recognise: true },
25+
{ text: "How", duration: 0.49, recognise: false },
26+
{ text: "I", duration: 0.46, recognise: false },
27+
{ text: "wonder", duration: 1.32, recognise: false },
28+
{ text: "what", duration: 0.69, recognise: false },
29+
{ text: "you", duration: 0.46, recognise: false },
3030
{ text: "are", duration: 1.5, recognise: true }
3131
]
3232
},
3333
{
3434
words: [
3535
{ text: "", duration: 0.5, recognise: false },
36-
{ text: "Up", duration: 0.75, recognise: true },
37-
{ text: "above", duration: 1.2, recognise: true },
36+
{ text: "Up", duration: 0.75, recognise: false },
37+
{ text: "above", duration: 1.2, recognise: false },
3838
{ text: "the", duration: 0.6, recognise: true },
39-
{ text: "world", duration: 0.6, recognise: true },
40-
{ text: "so", duration: 0.7, recognise: true },
39+
{ text: "world", duration: 0.6, recognise: false },
40+
{ text: "so", duration: 0.7, recognise: false },
4141
{ text: "high", duration: 1.8, recognise: false }
4242
]
4343
},
4444
{
4545
words: [
46-
{ text: "Like", duration: 0.6, recognise: true },
46+
{ text: "Like", duration: 0.6, recognise: false },
4747
{ text: "a", duration: 0.7, recognise: false },
4848
{ text: "diamond", duration: 1.3, recognise: true },
49-
{ text: "in", duration: 0.4, recognise: true },
49+
{ text: "in", duration: 0.4, recognise: false },
5050
{ text: "the", duration: 0.8, recognise: true },
51-
{ text: "sky", duration: 2.0, recognise: true }
51+
{ text: "sky", duration: 2.0, recognise: false }
5252
]
5353
},
5454
{
5555
words: [
5656
{ text: "Twinkle", duration: 1.2, recognise: false },
5757
{ text: "twinkle", duration: 1.1, recognise: false },
58-
{ text: "little", duration: 1.5, recognise: true },
58+
{ text: "little", duration: 1.5, recognise: false },
5959
{ text: "star", duration: 2.0, recognise: false }
6060
]
6161
},
6262
{
6363
words: [
64-
{ text: "How", duration: 0.49, recognise: true },
65-
{ text: "I", duration: 0.46, recognise: true },
64+
{ text: "How", duration: 0.49, recognise: false },
65+
{ text: "I", duration: 0.46, recognise: false },
6666
{ text: "wonder", duration: 1.32, recognise: true },
67-
{ text: "what", duration: 0.69, recognise: true },
68-
{ text: "you", duration: 0.46, recognise: true },
69-
{ text: "are", duration: 3.0, recognise: true }
67+
{ text: "what", duration: 0.69, recognise: false },
68+
{ text: "you", duration: 0.46, recognise: false },
69+
{ text: "are", duration: 3.0, recognise: false }
7070
]
7171
}
7272
]
@@ -117,6 +117,13 @@ class LyricsEngine {
117117
let cumulativeTime = 0; // Track cumulative duration to calculate word start times
118118

119119
sentence.words.forEach(word => {
120+
// Skip empty words - don't display or highlight them
121+
if (!word.text || word.text.length === 0) {
122+
// Still update cumulative time for proper timing
123+
cumulativeTime += word.duration;
124+
return; // Skip to next word
125+
}
126+
120127
// Calculate word start time from cumulative duration of previous words
121128
const wordStartTime = cumulativeTime;
122129

0 commit comments

Comments
 (0)