chore: 知识库冷启动收尾 + CCA 大洋时间戳规则 + 依赖/文档同步
- CLAUDE.md 状态更新:知识库冷启动完成,下一步语义搜索 - backend/requirements.txt 增加 python-docx(doco 导入脚本依赖) - CCA srt_writer 增加大洋"单下单上"40ms 间隔后处理 - Doco 寄存条状态更新为"已交付" Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,27 @@ def ms_to_srt_time(ms: int) -> str:
|
||||
return f"{hours:02d}:{minutes:02d}:{seconds:02d},{millis:03d}"
|
||||
|
||||
|
||||
def _apply_dayang_timing(
|
||||
subtitle_lines: List[Tuple[int, int, str]],
|
||||
) -> List[Tuple[int, int, str]]:
|
||||
"""
|
||||
大洋"单下单上":每条字幕的结束时间 = 下一条开始时间 - 40ms。
|
||||
"""
|
||||
if len(subtitle_lines) <= 1:
|
||||
return subtitle_lines
|
||||
|
||||
GAP_MS = 40
|
||||
adjusted = []
|
||||
for i, (start_ms, end_ms, text) in enumerate(subtitle_lines):
|
||||
if i < len(subtitle_lines) - 1:
|
||||
next_start = subtitle_lines[i + 1][0]
|
||||
end_ms = next_start - GAP_MS
|
||||
if end_ms < start_ms:
|
||||
end_ms = start_ms
|
||||
adjusted.append((start_ms, end_ms, text))
|
||||
return adjusted
|
||||
|
||||
|
||||
def write_srt(
|
||||
subtitle_lines: List[Tuple[int, int, str]],
|
||||
output_path: str,
|
||||
@@ -36,6 +57,8 @@ def write_srt(
|
||||
output_path: 输出文件路径
|
||||
time_offset: 时间偏移(用于正片拆分后各段从0开始计时的情况,这里不用,保持绝对时间)
|
||||
"""
|
||||
subtitle_lines = _apply_dayang_timing(subtitle_lines)
|
||||
|
||||
with open(output_path, "w", encoding="utf-8") as f:
|
||||
for idx, (start_ms, end_ms, text) in enumerate(subtitle_lines, 1):
|
||||
start = ms_to_srt_time(start_ms - time_offset)
|
||||
|
||||
Reference in New Issue
Block a user