FeaturesBase Class¶
Abstract Base Class for Audio Features
-
class
spiegel.features.features_base.
FeaturesBase
(dimensions, sampleRate=44100, frameSizeSamples=2048, hopSizeSamples=512)¶ Bases:
abc.ABC
- Parameters
dimensions (int) – Number of dimensions associated with these features
sampleRate (int, optional) – Audio sample rate, defaults to 44100
frameSizeSamples (int, optional) – frame size in audio samples, defaults to 2048
hopSizeSamples (int, optional) – hop size in audio samples, defaults to 512
-
fitNormalizers
(data, transform=False)¶ Fit normalizers to dataset for future transforms. Can also transform the data and return a normalized version of that data.
- Parameters
data (np.array) – data to train normalizer on
transform (bool, optional) – should the incoming data also be normalized? Defuaults to False
- Returns
None if no transform applied, np.array with normalized data if transform applied
- Return type
None or np.array
-
abstract
getFeatures
(audio, normalize=False)¶ Must be implemented. Run audio feature extraction on audio provided as parameter. Normalization should be applied based on the normalize parameter.
- Parameters
audio (np.array) – Audio to process features on
normalize (bool, optional) – Whether or not the features are normalized, defaults to False
- Returns
results from audio feature extraction
- Return type
np.array
-
loadNormalizers
(location)¶ Load trained normalizers from disk
- Parameters
location (str) – Pickled file of trained normalizers
-
normalize
(data)¶ Normalize features using pre-trained normalizer
- Parameters
data (np.array) – data to be normalized
- Returns
normalized data
- Return type
np.array
-
saveNormalizers
(location)¶ Save the trained normalizers for these features for later use
- Parameters
location (str) – Location to save pickled normalizers
-
setNormalizer
(dimension, normalizer)¶ Set a normalizer for a dimension, this will be used to normalize that dimension
- Parameters
dimension (int) – Which feature dimension to save this normalizer for
normalizer (Sklean Scaler) – A trained normalizer object