syncalong.lyrics¶
Parse a plain-text lyrics file (or in-memory text) into structured
LyricLine objects, and build a Whisper
decoding prompt from the lyrics.
lyrics ¶
Parse a plain-text lyrics file into structured lines.
LyricLine
dataclass
¶
A single line from the lyrics file.
Attributes:
| Name | Type | Description |
|---|---|---|
index |
int
|
0-based line position in the file. |
raw |
str
|
Original text as it appeared. |
words |
list[str]
|
Normalized, split tokens used for matching. |
is_blank |
bool
|
|
lyrics_prompt ¶
Build a Whisper initial_prompt from the original lyric text.
Feeding the known lyrics to the decoder biases transcription toward the correct words. Whisper keeps only a limited number of prompt tokens (and keeps the last ones), so just the beginning of the song is passed, truncated at a word boundary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lines
|
list[LyricLine]
|
Parsed lyric lines. |
required |
max_chars
|
int
|
Maximum prompt length in characters. |
600
|
Returns:
| Type | Description |
|---|---|
str
|
The prompt text (possibly truncated at a word boundary). |
Source code in src/syncalong/lyrics.py
parse_lyrics_text ¶
Parse raw lyrics text into structured lines.
Blank lines are preserved (they represent instrumental breaks) but carry
no words to match. Section headers like [Chorus] or (Bridge) are
treated as blank lines so spacing is preserved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The full lyrics as one string, lines separated by newlines. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
One |
list[LyricLine]
|
class: |
Source code in src/syncalong/lyrics.py
parse_lyrics ¶
Read a lyrics text file and parse it into structured lines.
Thin wrapper over :func:parse_lyrics_text that reads the file first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to a UTF-8 plain-text lyrics file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
One |
list[LyricLine]
|
class: |