Skip to content

fix(ttml): 支持 AM 歌词简繁替换并过滤重复翻译与音译 - #17

Open
kid141252010 wants to merge 2 commits into
SPlayer-Dev:mainfrom
kid141252010:fix/am-ttml-annotations
Open

kid141252010 wants to merge 2 commits into
SPlayer-Dev:mainfrom
kid141252010:fix/am-ttml-annotations

Conversation

@kid141252010

Copy link
Copy Markdown

变更内容

按语言偏好替换正文

  • 将 translation type="replacement" 与普通翻译字幕分开处理。
  • preferredLang 为 zh-CN / zh-Hans 时,优先使用匹配的简体 replacement;繁体偏好同理。
  • 未指定语言偏好或没有匹配轨时,保留原文,不跨简繁字形回退。
  • 支持主歌词及对应 x-bg 的正文替换。
  • 替换轨包含逐字时间时使用其时间戳;仅包含整句文本时保留原句时间范围,不伪造逐字同步。
  • replacement 不再作为额外翻译字幕输出。

屏蔽重复翻译与音译

  • 以每句主歌词、每条独立的 x-bg 为比较区域,基于替换后的正文判断重复。
  • 翻译与正文完全相同时,清空 translatedLyric。
  • 音译与正文完全相同时,清空 romanLyric,同时不挂载 romanWord。
  • 规范化空白并忽略背景歌词的包裹括号,不忽略大小写或标点差异。
  • 部分内容相同的混合语言行保留完整音译,不逐词删除相同片段。
  • 同一句内的多条 x-bg 独立匹配,避免辅助歌词相互拼接或串用。

兼容性

  • parseTTML 与 parseLyric 均生效,无需新增配置项。
  • 更新 preferredLang 类型说明及中英文 README。

- Exclude replacement tracks from subtitles and prevent cross-script Chinese fallbacks.
- Suppress identical translations and romanizations per main line and individual background line.
- Add regression coverage and document the parser behavior.

Verified: 115 focused tests passed; TypeScript typecheck passed.
- Select matching replacement tracks for main lyrics and individual background lines in both Chinese scripts.
- Reuse content parsing to retain replacement word timings, whitespace and annotations; retain original timing for untimed replacement text.
- Compare translations and romanizations against the selected replacement text.
- Cover both script directions and update API and README documentation.

Verified: 125 focused tests passed; TypeScript typecheck and both real-world samples passed.
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