Skip to content
This repository was archived by the owner on Jul 17, 2026. It is now read-only.

fix(lyric): 未正确解析带翻译 lrc 的歌词行结束时间 - #661

Merged
imsyy merged 1 commit into
SPlayer-Dev:devfrom
MoYingJi:pr/fix-ll
Dec 26, 2025
Merged

imsyy merged 1 commit into
SPlayer-Dev:devfrom
MoYingJi:pr/fix-ll

Conversation

@MoYingJi

Copy link
Copy Markdown
Collaborator

No description provided.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @MoYingJi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a bug in the lyric parsing logic where the end time of lyric lines, particularly those accompanied by translations, was not being correctly determined. The changes introduce a more robust mechanism for calculating lyric line durations, ensuring that the main lyric line's end time correctly accounts for the presence and duration of its translated or romanized counterparts. This enhancement improves the accuracy of lyric synchronization and display.

Highlights

  • Improved Lyric End Time Calculation: A new helper function, toEndTime, has been introduced to accurately determine the end time of a lyric line. This function prioritizes an explicit endTime property, then the endTime of the last word in a line, ensuring more robust duration calculation.
  • Corrected Translated Lyric Synchronization: When aligning translated or romanized lyrics, the base lyric line's endTime is now updated to be the maximum of its own calculated end time and the associated translated/romanized line's end time. This ensures that the main lyric line's duration correctly encompasses its translations, fixing synchronization issues.
  • Lodash Utility Integration: The max utility from lodash-es has been imported and utilized to facilitate the comparison and selection of the later end time between the base lyric line and its translated/romanized counterparts.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

本次 PR 修复了在处理带翻译的 lrc 歌词时,歌词行结束时间未被正确计算的问题。您通过引入 toEndTime 辅助函数,并使用 lodash.max 来确保歌词行的 endTime 能够覆盖原文、翻译和音译中最晚结束的时间点,这个修复是正确且有效的。代码整体质量不错,我只提出了一处关于代码可读性和可维护性的建议,旨在使逻辑更加清晰。做得很好!

Comment on lines +130 to +137
if (!base.translatedLyric && tran) {
base.translatedLyric = toText(tran);
base.endTime = max([toEndTime(base), toEndTime(tran)]);
}
if (!base.romanLyric && roma) {
base.romanLyric = toText(roma);
base.endTime = max([toEndTime(base), toEndTime(roma)]);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

当前实现虽然正确,但对 base.endTime 进行了多次可变更新,这可能使逻辑稍显复杂。通过将所有相关的结束时间收集到一个数组中,然后一次性计算最大值,可以使代码意图更清晰,也更易于维护。这种方法将计算与赋值分离开来,提高了代码的可读性。

      const endTimes = [toEndTime(base)];
      if (!base.translatedLyric && tran) {
        base.translatedLyric = toText(tran);
        endTimes.push(toEndTime(tran));
      }
      if (!base.romanLyric && roma) {
        base.romanLyric = toText(roma);
        endTimes.push(toEndTime(roma));
      }
      base.endTime = max(endTimes);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants