espnetez.config.from_yaml
Less than 1 minute
espnetez.config.from_yaml
espnetez.config.from_yaml(task, path)
Load configuration from a YAML file and merge it with the default configuration.
This function reads a YAML configuration file from the specified path and merges its contents with the default configuration for the specified task. If there are any keys in the YAML file that have the string value “none”, they are converted to None type. The resulting configuration dictionary is returned.
- Parameters:
- task (str) – The name of the task for which the configuration is being loaded.
- path (str) – The file path to the YAML configuration file.
- Returns: A dictionary containing the merged configuration settings.
- Return type: dict
- Raises:
- FileNotFoundError – If the specified YAML file does not exist.
- yaml.YAMLError – If the YAML file is not formatted correctly.
Examples
>>> config = from_yaml('speech_recognition', 'config.yaml')
>>> print(config)
{'learning_rate': 0.001, 'batch_size': 32, 'preprocessor_conf': None}
>>> config = from_yaml('text_to_speech', 'path/to/config.yaml')
>>> print(config['model_type'])
'tacotron2'
NOTE
Ensure that the task name provided corresponds to a valid task class in the espnetez.task module to avoid runtime errors.