Closed hagenw closed 3 years ago
If a user does something like:
transform = audsp.Spectrogram(...) transform.to_yaml('transform.yaml')
it is obvious what will happen.
But to load the transform the user can do:
audobject.Object.from_yaml('transform.yaml') audsp.Spectrogram.from_yaml('transform.yaml') audsp.Cepstrogram.from_yaml('transform.yaml')
which all return
{'$audsp.core.spectrogram.Spectrogram': {'win_dur': 0.2, 'hop_dur': 0.1, 'power': False, 'num_fft': 4096, 'center': False, 'reflect': False, 'zero_phase': False, 'audspec': None, 'unit': 'seconds', 'channels': [0], 'mixdown': False, 'resample': False, 'sampling_rate': 16000}}
Especially audsp.Cepstrogram.from_yaml('transform.yaml') is very misleading.
audsp.Cepstrogram.from_yaml('transform.yaml')
I would propose that me move the static functions
audobject.Object.from_dict()
audobject.Object.from_yaml()
audobject.Object.from_yaml_s()
audobject.from_dict()
audobject.from_yaml()
audobject.from_yaml_s()
Or maybe add a load, e.g. audobject.load_from_dict(), ...
load
audobject.load_from_dict()
In the above example the code would then read:
audobject.from_yaml('transform')
and this is the only way to load the transform. The only downside is that the user has to import audobject on top/instead of audsp.
audobject
audsp
I like your proposal as it indeed provides a cleaner API.
If a user does something like:
it is obvious what will happen.
But to load the transform the user can do:
which all return
Especially
audsp.Cepstrogram.from_yaml('transform.yaml')
is very misleading.I would propose that me move the static functions
audobject.Object.from_dict()
audobject.Object.from_yaml()
audobject.Object.from_yaml_s()
to the module level:audobject.from_dict()
audobject.from_yaml()
audobject.from_yaml_s()
Or maybe add a
load
, e.g.audobject.load_from_dict()
, ...In the above example the code would then read:
and this is the only way to load the transform. The only downside is that the user has to import
audobject
on top/instead ofaudsp
.