espnet2.main_funcs.pack_funcs.get_dict_from_cache
Less than 1 minute
espnet2.main_funcs.pack_funcs.get_dict_from_cache
espnet2.main_funcs.pack_funcs.get_dict_from_cache(meta: Path | str) → Dict[str, str] | None
Retrieve a dictionary from a YAML cache file.
This function reads a YAML file located at the specified path and returns a dictionary mapping keys to file paths. The function ensures that the paths exist in the expected output directory.
- Parameters:meta (Union *[*Path , str ]) – The path to the YAML cache file.
- Returns: A dictionary containing key-value pairs from the YAML file, where keys are identifiers and values are file paths. Returns None if the YAML file does not exist or if any referenced file does not exist in the output directory.
- Return type: Optional[Dict[str, str]]
- Raises:
- AssertionError – If the loaded YAML content is not a dictionary or if
- the expected keys are not found. –
Examples
>>> cache_dict = get_dict_from_cache("path/to/meta.yaml")
>>> print(cache_dict)
{'asr_model_file': 'output/model.pth', 'other_file': 'output/other.file'}
NOTE
This function assumes the structure of the YAML file contains two dictionaries under the keys “yaml_files” and “files”.