Skip to content

fix: 合并解析优化并发布整秒歌词兼容修复 - #11

Merged
imsyy merged 14 commits into
mainfrom
feat/timestamp-compatibility
Oct 11, 2026
Merged

imsyy merged 14 commits into
mainfrom
feat/timestamp-compatibility

Conversation

@imsyy

@imsyy imsyy commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

整秒 LRC 标签(如 [00:01])在 0.6.0 中被丢弃,导致 SPlayer-Next 将有效歌词显示为无歌词。本次统一正文、外部翻译/罗马音和逐字标签的整秒解析,并准备发布 0.6.1。

一并合入 feat/compatible-parser-improvements,保留原导出默认行为和扁平解析参数兼容性。优化包括精确时间优先的辅助歌词匹配、独立生效的 offset、显式 roundTrip 导出与可复用时间索引;新增回归修复同时开始的歌手归属、内嵌/外部注音重复和往返模式的毫秒精度。

TTML 以 applemusic-like-lyrics 本地源码为参照:歌手顺序变化时按 agent ID 对齐,行时间按逐字及背景人声范围计算。另完善 SRT 整秒及非法时间处理、ASS 不完整头部识别、KRC 分秒行头与 TTML 时间单位兼容。

验证:

  • 34 个测试文件、328 项测试通过,lint、typecheck、ESM/CJS 构建通过。
  • 与参考项目四份 TTML 样本对照,155 行的起止时间、逐字、注音、背景和对唱结构一致。
  • 匹配器使用独立线性参考进行密集重复时间戳回归;时间索引与原线性查询对照,覆盖重叠行、偏移及重建。
  • 时间索引只保存局部快照,时间或数组改变须重建,无模块级缓存;roundTrip 仅显式启用,格式表达能力限制已写入文档。

关联:SPlayer-Dev/SPlayer-Next#338

Copilot AI balanced review requested due to automatic review settings October 11, 2026 07:38
@imsyy
imsyy merged commit f8d4a0a into main Oct 11, 2026
2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

TTML range expansion incorrectly ignores explicitly timed child ranges beginning at zero milliseconds.

1 open finding
What changed in this PR

Fixes whole-second LRC parsing from SPlayer-Next #338 while merging parser, serialization, alignment, and lookup improvements for the 0.6.1 release.

Changes:

  • Adds whole-second and expanded timestamp compatibility across lyric formats.
  • Improves offset/kana handling, auxiliary lyric matching, and TTML timing.
  • Adds round-trip serialization and indexed active-line lookup.
File Description
tests/​timestamp-compatibility.spec.ts Covers timestamp compatibility.
tests/​sync-index.spec.ts Validates indexed lookup.
tests/​serialize-roundtrip.spec.ts Tests round-trip exports.
tests/​serialize-options.spec.ts Tests serialization options.
tests/​pair-translation.spec.ts Covers auxiliary alignment.
tests/​offset-options.spec.ts Verifies offset independence.
tests/​external-kana-offset.spec.ts Tests external kana offsets.
tests/​combined-parser-regressions.spec.ts Adds cross-feature regressions.
src/​utils/​timestamp.ts Expands timestamp parsing.
src/​utils/​sync.ts Adds indexed active-line queries.
src/​utils/​kana.ts Applies kana timing offsets.
src/​types.ts Adds serialization options.
src/​serialize/​srt.ts Adds SRT round-trip mode.
src/​serialize/​lrc.ts Adds LRC round-trip precision.
src/​serialize/​index.ts Supports nested parse options.
src/​parse/​yrc.ts Decouples offsets from metadata output.
src/​parse/​ttml.ts Expands TTML timing ranges.
src/​parse/​srt.ts Handles whole-second and invalid cues.
src/​parse/​qrc.ts Decouples offsets from metadata output.
src/​parse/​lys.ts Decouples offsets from metadata output.
src/​parse/​lrc.ts Parses whole-second LRC tags.
src/​parse/​krc.ts Supports whole-second KRC headers.
src/​parse/​index.ts Improves detection and auxiliary matching.
src/​index.ts Exports new public APIs.
README.md Documents new behavior.
README.zh-CN.md Updates Chinese documentation.
package.json Bumps version to 0.6.1.
benchmarks/​sync.mjs Benchmarks indexed lookup.
benchmarks/​README.md Documents benchmark results.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/parse/ttml.ts
if (bgState.words.length > 0) {
const childStart = Math.min(...bgState.words.map((word) => word.startTime));
const childEnd = Math.max(...bgState.words.map((word) => word.endTime));
if (bgStart === 0 || (childStart > 0 && childStart < bgStart)) bgStart = childStart;
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.

2 participants