Skip to content

Align NetEase and Musixmatch word timings to the Spotify lines - #52

Open
VitzS7 wants to merge 1 commit into
fatyzzz:mainfrom
VitzS7:lyrics-align
Open

VitzS7 wants to merge 1 commit into
fatyzzz:mainfrom
VitzS7:lyrics-align

Conversation

@VitzS7

@VitzS7 VitzS7 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

When Spotify only has line timings, fetch_cached swaps them for the word timings from NetEase or Musixmatch as they come. Those sources often timed another cut of the recording (a different intro, a remaster), so the whole text runs early or late by a fixed amount. NetEase YRC for "Lose Yourself" is 1.2 s ahead of the LRCLIB lines, and its duration is 4 s shorter than the Spotify one.

Now the word timings are shifted by the median offset between lines with the same text. If the offset spreads by more than a second across the song, the source fits another version, so the Spotify lines stay. Under 3 matching lines nothing changes. The lyrics cache goes to version 10 so the old upgrades are fetched again.

Checked with the app on a real account:

  • Blinding Lights: NetEase words shifted -0.220 s onto 33 Spotify lines
  • Bohemian Rhapsody: shifted +0.020 s onto 26 lines

Tests: cargo test -p mf-lyrics (3 new: shift, other cut rejected, unmatched left alone).

How to test: play a track whose Spotify lyrics are line by line and that NetEase has word lyrics for (Blinding Lights works), skip away and back once the upgrade is cached, and run with RUST_LOG=mf_lyrics=debug to see the applied shift.

When Spotify only has line timings, the word timings from NetEase or
Musixmatch replace them as they are. Those sources often timed another
cut of the recording, so the whole text runs early or late by a fixed
amount (NetEase YRC for "Lose Yourself" is 1.2 s ahead).

Shift the word timings by the median offset between matching lines.
When the offset varies by more than a second across the song, it is a
different version, so the Spotify lines stay. Bump the cache to 10 so
the old unaligned upgrades are fetched again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant