fix: SRT 按 cue 解析并按 ID 回填译文,OCR 空帧分段与失败重试
This commit is contained in:
@@ -397,8 +397,8 @@ def test_ocr_merges_consecutive_same_text(monkeypatch, tmp_path) -> None:
|
||||
assert "00:00:06,000 --> 00:00:10,000" in srt
|
||||
|
||||
|
||||
def test_ocr_skips_failed_frames(monkeypatch, tmp_path) -> None:
|
||||
"""个别帧 OCR 失败时跳过,不影响其余帧汇总。"""
|
||||
def test_ocr_preserves_checkpoint_for_failed_frames(monkeypatch, tmp_path) -> None:
|
||||
"""个别帧持续失败时返回 failed,其余成功帧存档供重试复用。"""
|
||||
frames = []
|
||||
for index in range(3):
|
||||
image = tmp_path / f"f{index}.png"
|
||||
@@ -421,9 +421,11 @@ def test_ocr_skips_failed_frames(monkeypatch, tmp_path) -> None:
|
||||
output_dir=str(tmp_path / "out"),
|
||||
)
|
||||
)
|
||||
assert response.status == "completed", response.error
|
||||
srt = Path(response.outputs["srt_uri"]).read_text(encoding="utf-8")
|
||||
assert "SUB 001" in srt
|
||||
assert response.status == "failed"
|
||||
partial = [json.loads(line) for line in (tmp_path / "out/ocr_partial.jsonl").read_text().splitlines()]
|
||||
assert {item["frame"] for item in partial} == {0, 2}
|
||||
assert all(item["text"] == "SUB 001" for item in partial)
|
||||
assert not (tmp_path / "out/subtitle.srt").exists()
|
||||
|
||||
|
||||
def test_ocr_missing_manifest(tmp_path) -> None:
|
||||
|
||||
Reference in New Issue
Block a user