"""数据集注册表:config 的 type(hf|custom) 映射到适配器。 公共集(ASCEND/AISHELL/LibriSpeech)统一走 HFDataset,差异全在 config.yaml 里描述 (hf_id/split/text_field/lang),所以"广覆盖 + 自定义"只需改配置,不必加代码。 """ from __future__ import annotations from .base import Dataset def build_dataset(cfg: dict, audio_cache: str) -> Dataset: dtype = cfg["type"] if dtype == "hf": from .hf import HFDataset return HFDataset(cfg, audio_cache) if dtype == "custom": from .custom import CustomDataset return CustomDataset(cfg) raise ValueError(f"未知数据集类型: {dtype}") __all__ = ["Dataset", "build_dataset"]