syncalong.align¶
The core alignment algorithm: a Needleman–Wunsch-style dynamic-programming matcher that maps lyric words onto transcript words while preserving order.
align ¶
Align lyrics to a Whisper transcript with dynamic-programming alignment.
The algorithm is a variant of the Needleman–Wunsch / Smith–Waterman family: both the lyric word sequence and the transcript word sequence are in temporal order, so we find a monotonic mapping that maximises the total fuzzy-match score between paired words.
Complexity is O(N·M) where N = lyric words, M = transcript words. For a typical song (< 600 words each) this takes a few milliseconds.
align_lyrics_to_transcript ¶
align_lyrics_to_transcript(lyric_lines: list[LyricLine], transcript: list[WordTimestamp], *, threshold: float = 55.0) -> list[tuple[LyricLine, float | None]]
Align parsed lyrics to a word-level transcript.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lyric_lines
|
list[LyricLine]
|
Parsed lyrics (from
:func: |
required |
transcript
|
list[WordTimestamp]
|
Word timestamps (from
:func: |
required |
threshold
|
float
|
Minimum fuzzy score (0–100) to accept a match. |
55.0
|
Returns:
| Type | Description |
|---|---|
list[tuple[LyricLine, float | None]]
|
One |
list[tuple[LyricLine, float | None]]
|
timestamp (seconds) is the start time of the first matched word in the |
list[tuple[LyricLine, float | None]]
|
line, or |