espnet3.utils.task_utils.get_espnet_model
Less than 1 minute
espnet3.utils.task_utils.get_espnet_model
espnet3.utils.task_utils.get_espnet_model(task: str, config: Dict | DictConfig) → AbsESPnetModel
Build and return an ESPnet2 model from a task class and config.
This is a thin wrapper around Task.get_default_config() and Task.build_model(...). It temporarily overrides sys.argv to satisfy some task implementations that rely on argument parsing.
- Parameters:
- task (str) – Dotted path to an ESPnet2 Task class.
- config (Union *[*Dict , DictConfig ]) – Model/config overrides merged into the task default config.
- Returns: Instantiated ESPnet2 model.
- Return type:AbsESPnetModel
- Raises:RuntimeError – If the task class cannot be resolved.
Example
>>> model = get_espnet_model(
... "espnet2.tasks.asr.ASRTask",
... {"frontend": "default"},
... )