Configuration and errors¶
kudio.config
¶
YAML-backed configuration with attribute access.
>>> from kudio import KudioConfig
>>> cfg = KudioConfig.load_config('TrainConfig.yaml')
>>> cfg.train.clean
'data/train/clean'
Classes:
| Name | Description |
|---|---|
KudioConfig |
Attribute-style config with YAML load/save and audio-centric defaults. |
Dict
¶
Bases: dict
dict subclass with attribute access and recursive conversion.
Vendored from the addict <https://github.com/mewwts/addict>_ project
(MIT license), trimmed to what kudio needs.
Source code in kudio/config.py
KudioConfig
¶
Bases: Dict
Attribute-style config with YAML load/save and audio-centric defaults.
Methods:
| Name | Description |
|---|---|
write_config |
Dump the config to file; refuses to overwrite unless |
load_config |
Load a YAML config file. |
default_config |
Audio-only defaults. Training/model settings live in the |
show |
Print one key (or the whole config) to the log. |
Source code in kudio/config.py
write_config
¶
Dump the config to file; refuses to overwrite unless exist_ok.
Source code in kudio/config.py
load_config
classmethod
¶
Load a YAML config file.
cfg_dir may be a file, or a directory containing exactly one
cfg.yaml at any depth. Anything else falls back to
default_config, with a UserWarning when a path was named
or a search found more than one file: a misspelt file name came back
as the defaults with nothing said.
A key the file does not have reads as an empty section, which is what
lets cfg.a.b = 1 build a new one. Call freeze on the result
to make a misspelt key raise KeyError instead.
Source code in kudio/config.py
default_config
staticmethod
¶
Audio-only defaults. Training/model settings live in the application layer, not in the audio library.
Source code in kudio/config.py
show
¶
Print one key (or the whole config) to the log.
Source code in kudio/config.py
kudio.exceptions
¶
Exception hierarchy for kudio.
What goes wrong with a file, a device, a feature, a synthesis run or a missing
extra derives from KudioError, so callers can:
A wrong argument -- a negative rate, an unknown metric, two signals too
different in length to compare -- raises ValueError or TypeError as the
standard library would, and a buffer that waited too long raises
TimeoutError.
Classes:
| Name | Description |
|---|---|
KudioError |
Base class for every error raised by kudio. |
AudioIOError |
Reading or writing an audio file failed. |
UnsupportedFormatError |
The file type / dtype is not supported. |
DeviceError |
An audio input/output device could not be opened or configured. |
FeatureError |
A feature, effect, room, channel or enhancement step refused its input |
SynthesisError |
Noisy-data synthesis failed. |
DependencyError |
An optional dependency is required for this operation but not installed. |
KudioError
¶
Bases: Exception
Base class for every error raised by kudio.
AudioIOError
¶
Bases: KudioError
Reading or writing an audio file failed.
UnsupportedFormatError
¶
Bases: AudioIOError
The file type / dtype is not supported.
Not raised by kudio itself at present: a file soundfile cannot read comes
back as a plain AudioIOError. Catch that one.
DeviceError
¶
Bases: KudioError, RuntimeError
An audio input/output device could not be opened or configured.
Also a RuntimeError: kudio.CheckDevice.input_device raised
plain RuntimeError for the same failures, and code written against
that still catches them.
FeatureError
¶
Bases: KudioError
A feature, effect, room, channel or enhancement step refused its input or its settings: the wrong shape of audio, a parameter out of range, a clip too short to frame.
SynthesisError
¶
Bases: KudioError
Noisy-data synthesis failed.
DependencyError
¶
Bases: KudioError, ImportError
An optional dependency is required for this operation but not installed.