fix(eval): 单条样本失败不再拖垮整轮评估
- cli:逐样本 transcribe 包 try/except,失败记为该样本 error 并继续; 失败样本 counts 置空,不计入准确率,仅在 errors 列计数 - custom 数据集:manifest 引用的音频不存在时 warn 跳过,不再让 soundfile 抛错崩掉整轮(修复默认 config 的 custom 示例集指向不存在音频导致的崩溃) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -17,8 +17,8 @@ from rich.console import Console
|
||||
from rich.progress import BarColumn, Progress, TextColumn, TimeElapsedColumn
|
||||
|
||||
from .datasets import build_dataset
|
||||
from .engines import build_engine
|
||||
from .metrics.err import score_sample
|
||||
from .engines import Transcript, build_engine
|
||||
from .metrics.err import empty_counts, score_sample
|
||||
from .metrics.resource import ResourceProbe
|
||||
from .report import aggregate, render_markdown, write_reports
|
||||
|
||||
@@ -117,8 +117,12 @@ def cmd_run(args: argparse.Namespace) -> int:
|
||||
) as prog:
|
||||
task = prog.add_task(f"{name}", total=len(samples))
|
||||
for s in samples:
|
||||
tr = _transcribe_one(engine, s.audio_path)
|
||||
sc = score_sample(s.ref_text, tr.text)
|
||||
try:
|
||||
tr = _transcribe_one(engine, s.audio_path)
|
||||
except Exception as ex: # 单条样本失败不拖垮整轮评估
|
||||
tr = Transcript(text="", audio_sec=0.0, proc_sec=0.0, error=str(ex))
|
||||
# 失败样本不计入准确率(counts 置空),仅在 errors 列计数
|
||||
sc = empty_counts() if tr.error else score_sample(s.ref_text, tr.text)
|
||||
rows.append({
|
||||
"engine": name,
|
||||
"dataset": s.dataset,
|
||||
|
||||
@@ -11,6 +11,7 @@ from __future__ import annotations
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from collections.abc import Iterator
|
||||
|
||||
from ..manifest import Sample
|
||||
@@ -50,6 +51,9 @@ class CustomDataset:
|
||||
audio = row["audio"]
|
||||
if not os.path.isabs(audio):
|
||||
audio = os.path.join(self._base, audio)
|
||||
if not os.path.exists(audio):
|
||||
print(f"[custom] 跳过缺失音频:{audio}", file=sys.stderr)
|
||||
continue
|
||||
lang = row.get("lang") or _guess_lang(text)
|
||||
n += 1
|
||||
yield Sample(
|
||||
|
||||
Reference in New Issue
Block a user