Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: prevent lyric snaps from overlapping adjacent lines (#9255)
Adam Eivyd46f11f4bd5e
diff --git a/server/services/musicVideo/lyricAlignCore.js b/server/services/musicVideo/lyricAlignCore.jsindex 16b3119791..c68654a7d0 100644--- a/server/services/musicVideo/lyricAlignCore.js+++ b/server/services/musicVideo/lyricAlignCore.js@@ -703,25 +703,37 @@ function dpAlignWords(lyricWords, recognised) {/** Snap generated line starts and all words by one delta; authored sides stay fixed. */export function snapLineStarts(lines, onsets, originals = []) {- return lines.map((line, index) => {+ const snapped = [];+ for (const [index, line] of lines.entries()) {+ snapped.push(line);const original = originals[index] || {};- if (line.matched < 0.5 || !line.words?.length) return line;+ if (line.matched < 0.5 || !line.words?.length) continue;const first = line.words[0].startSec;const onset = onsets.filter((t) => t >= first - 0.35 && t <= first + 0.25).sort((a, b) => Math.abs(a - first) - Math.abs(b - first))[0];- if (onset == null) return line;+ if (onset == null) continue;const delta = onset - first;- // A snap is optional evidence, never permission to move karaoke words- // outside the line window the director explicitly set.- if (original.startSec != null && first + delta < original.startSec) return line;- if (original.endSec != null && line.words.at(-1).endSec + delta > original.endSec) return line;- return {+ const wordEnd = line.words.at(-1).endSec + delta;+ // A snap is optional evidence, never permission to cross an authored+ // boundary or overlap the adjacent lyric. Use the already-snapped previous+ // line so two individually permissible shifts cannot collide.+ if (original.startSec != null && onset < original.startSec) continue;+ if (original.endSec != null && wordEnd > original.endSec) continue;+ const previous = snapped[index - 1];+ const following = lines[index + 1];+ const previousEnd = Math.max(previous?.words?.at(-1)?.endSec ?? -Infinity, previous?.endSec ?? -Infinity);+ const followingStart = Math.min(following?.words?.[0]?.startSec ?? Infinity, following?.startSec ?? Infinity);+ const endSec = original.endSec ?? (line.endSec == null ? null : round3(line.endSec + delta));+ if (Math.min(original.startSec ?? onset, onset) < previousEnd) continue;+ if (Math.max(endSec ?? wordEnd, wordEnd) > followingStart) continue;+ snapped[index] = {...line,startSec: original.startSec ?? round3(onset),- endSec: original.endSec ?? (line.endSec == null ? null : round3(line.endSec + delta)),+ endSec,words: line.words.map((word) => ({ ...word, startSec: round3(word.startSec + delta), endSec: round3(word.endSec + delta) })),};- });+ }+ return snapped;}/** Read the ffmpeg-decoded WAV without assuming a fixed-size RIFF header. */diff --git a/server/services/musicVideo/lyricAlignCore.test.js b/server/services/musicVideo/lyricAlignCore.test.jsindex ef3bfa88d6..fc528c75b6 100644--- a/server/services/musicVideo/lyricAlignCore.test.js+++ b/server/services/musicVideo/lyricAlignCore.test.js@@ -72,6 +72,16 @@ describe('phrase lyric matching', () => {expect(fallback.matched).toBeUndefined();});+ it('prevents positive and negative snaps from overlapping neighboring lines', () => {+ const cues = [{ text: 'hello morning' }, { text: 'quiet evening' }];+ const adjacent = alignDirectorWords(cues, [...words('hello morning', 1), ...words('quiet evening', 1.65)], { phraseAnchored: true });+ expect(snapLineStarts(adjacent, [1.2, 1.5], cues)).toEqual(adjacent);+ const separated = alignDirectorWords(cues, [...words('hello morning', 1), ...words('quiet evening', 1.9)], { phraseAnchored: true });+ const snapped = snapLineStarts(separated, [1.2, 1.7], cues);+ expect(snapped[0]).toMatchObject({ startSec: 1.2, endSec: 1.8 });+ expect(snapped[1]).toEqual(separated[1]);+ });+it('preserves low-confidence prior times and words, while snapping confident words together and honoring authored sides', () => {const cues = [{ text: 'hello morning', startSec: null, endSec: null },