espnet3.utils.scp_utils.load_scp_paths
Less than 1 minute
espnet3.utils.scp_utils.load_scp_paths
espnet3.utils.scp_utils.load_scp_paths(inference_dir: Path, test_name: str, inputs: List[str] | Dict[str, str], file_suffix: str = '.scp') → Dict[str, Path]
Resolve metric input aliases to SCP file paths.
This function does not read SCP contents. It only validates that the expected files exist under inference_dir / test_name and returns a mapping from metric input aliases to their corresponding paths.
- Parameters:
- inference_dir (Path) – Root directory of hypothesis/reference files.
- test_name (str) – Subdirectory name of the test set (e.g.,
"test-clean"). - inputs (Union *[*List *[*str ] , Dict *[*str , str ] ]) – Metric input declarations.
List[str]: alias and filename are the same.Dict[str, str]: alias -> filename.
- file_suffix (str , optional) – File extension appended to each filename. Default:
".scp".
- Returns: Mapping from metric aliases to resolved file paths, e.g.
{ "ref": Path("infer/test-clean/ref.scp"), "hyp": Path("infer/test-clean/hyp.scp"), } - Return type: Dict[str, Path]
- Raises:AssertionError – If the test directory or any required input file is missing.
Example
>>> load_scp_paths(
... Path("infer"),
... "test-other",
... inputs={"ref": "text", "hyp": "hypothesis"},
... )
{
"ref": Path("infer/test-other/text.scp"),
"hyp": Path("infer/test-other/hypothesis.scp"),
}Notes
- File contents are intentionally not loaded here.
- Consumers such as
BaseMetricmay stream the files or pass the returned paths directly to external tools.
