-
-
Notifications
You must be signed in to change notification settings - Fork 98
Fix lyrics parsing actual lyrics lines as translations for a blank lyric line #645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: beta
Are you sure you want to change the base?
Fix lyrics parsing actual lyrics lines as translations for a blank lyric line #645
Conversation
| ?: Long.MAX_VALUE.toULong() | ||
| lyric.isTranslated = lyric.start == previousTimestamp | ||
| previousTimestamp = lyric.start | ||
| lyric.isTranslated = lyric.start == previousLyric?.start && previousLyric.text.isNotBlank() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's a good start, but that fix is too simple. This breaks a few other parts of the app coded under the assumption translation means duplicate timestamp and lyric lines otherwise being unique:
- The code in new lyric view to determine current y offset of active lyric line:
Gramophone/app/src/main/java/org/akanework/gramophone/ui/components/NewLyricsView.kt
Line 433 in d778b0c
heightSoFarWithoutTranslated = heightSoFar - code used by meizu lyric and widget for getting active lyric line (at least possibly broken):
Gramophone/app/src/main/java/org/akanework/gramophone/logic/GramophonePlaybackService.kt
Line 982 in d778b0c
fun getCurrentLyricIndex(withTranslation: Boolean) =
and please also do add a minimalistic test to avoid regressions of this behaviour
and this breaks "copy-paste translations", where two identical lyc files but changed text are copy-pasted, consider:
[00:44.42]Es ist hart zu atmen aber egal
[00:47.32]Hhhhh
[00:56.44]
[00:59.22]Sei leise
[01:09.32]
[01:11.46]Klebeband meine Augen öffnen zum erzwingen realität (oh nein, nööö)
[01:17.99]Warum kann ich nicht mein Gewicht essen in Gelee?
[00:44.42]It's hard to breathe but that's alright
[00:47.32]Hush
[00:56.44]
[00:59.22]Shh
[01:09.32]
[01:11.46]Tape my eyes open to force reality (oh no, no)
[01:17.99]Why can't you just let me eat my weight in glee?
the empty lines would be marked as translation before, but not anymore. should be fixed otherwise they are too big.
|
just fyi "The code in new lyric view to determine current y offset of active lyric line" is still pending |
|
@copilot review this pr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Fixes lyrics parsing issue where blank lyric lines were incorrectly being paired with actual lyrics as translations due to duplicate timestamps.
- Updates translation detection logic to prevent blank lines from being eligible for translation with non-blank lines
- Adds comprehensive test coverage for the empty lyric scenario
- Updates existing test data to reflect the corrected parsing behavior
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| SemanticLyrics.kt | Modified translation detection logic to handle blank lines correctly |
| LrcUtilsTest.kt | Added new test case to verify empty lyrics are not treated as translations |
| LrcTestData.kt | Updated test data to reflect corrected parsing of blank lyric lines |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| lyric.isTranslated = lyric.start == previousTimestamp | ||
| previousTimestamp = lyric.start | ||
| lyric.isTranslated = lyric.start == previousLyric?.start | ||
| && (previousLyric.text.isNotBlank() || previousLyric.text.isBlank() && lyric.text.isBlank()) |
Copilot
AI
Aug 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition (previousLyric.text.isNotBlank() || previousLyric.text.isBlank() && lyric.text.isBlank()) is overly complex and confusing. This can be simplified to previousLyric.text.isNotBlank() || lyric.text.isBlank() which has the same logical meaning but is much clearer.
| && (previousLyric.text.isNotBlank() || previousLyric.text.isBlank() && lyric.text.isBlank()) | |
| && (previousLyric.text.isNotBlank() || lyric.text.isBlank()) |
b1f0157 to
9b79448
Compare
|
|
Some lyrics providers have lyrics that use duplicated timestamps for formatting reasons, causing the blank line to be parsed as the main lyric, and the second (actual line) to be parsed as a translation. After this change, blank lines will not be eligible for translation. See the following for an example: [00:23.73]I see the world through eyes covered in ink and bleach [00:29.70]Cross out the ones who heard my cries and watched me weep [00:35.64] [00:35.64]I love everything [00:38.51]Fire's spreading all around my room [00:43.13]My world's so bright [00:44.42]It's hard to breathe but that's alright [00:47.32]Hush [00:59.22] [00:59.22]Shh [01:11.46] [01:11.46]Tape my eyes open to force reality (oh no, no) [01:17.99]Why can't you just let me eat my weight in glee?
getCurrentLyricIndex() is updated to return the first non-blank item with the highest timestamp. Single blank lines are assumed to be intentional. Multiple blank lines without a non-blank line will follow the previous behaviour
9b79448 to
ad668e7
Compare
|
I can't verify Meizu status bar lyrics, but did verify the indexes that were sent to the widget. They seemed to match up with what should be displayed. |
Some lyrics providers have lyrics that use duplicated timestamps for formatting reasons, causing the blank line to be parsed as the main lyric, and the second (actual line) to be parsed as a translation. After this change, blank lines will not be eligible for translation.
See the following for an example without translations:
Lmk if you want me to write tests for this