pumpp.core.Pump

class pumpp.core.Pump(*ops)[source]

Top-level pump object.

This class is used to collect feature and task transformers

Examples

Create a CQT and chord transformer

>>> p_cqt = pumpp.feature.CQT('cqt', sr=44100, hop_length=1024)
>>> p_chord = pumpp.task.ChordTagTransformer(sr=44100, hop_length=1024)
>>> pump = pumpp.Pump(p_cqt, p_chord)
>>> data = pump.transform(audio_f='/my/audio/file.mp3',
...                       jam='/my/jams/annotation.jams')

Or use the call interface:

>>> data = pump(audio_f='/my/audio/file.mp3',
...             jam='/my/jams/annotation.jams')

Or apply to audio in memory, and without existing annotations:

>>> y, sr = librosa.load('/my/audio/file.mp3')
>>> data = pump(y=y, sr=sr)

Access all the fields produced by this pump:

>>> pump.fields
{'chord/chord': Tensor(shape=(None, 170), dtype=<class 'bool'>),
 'cqt/mag': Tensor(shape=(None, 288), dtype=<class 'numpy.float32'>),
 'cqt/phase': Tensor(shape=(None, 288), dtype=<class 'numpy.float32'>)}

Access a constituent operator by name:

>>> pump['chord'].fields
{'chord/chord': Tensor(shape=(None, 170), dtype=<class 'bool'>)}

Attributes

ops (list of (BaseTaskTransformer, FeatureExtractor)) The operations to apply
__init__(*ops)[source]

Methods

__init__(*ops)
add(operator) Add an operation to this pump.
crop(data) Crop a data dictionary down to its common time
data_duration(data) Compute the valid data duration of a dict
layers() Construct Keras input layers for all feature transformers in the pump.
sampler(n_samples, duration[, random_state]) Construct a sampler object for this pump’s operators.
transform([audio_f, jam, y, sr, crop]) Apply the transformations to an audio file, and optionally JAMS object.

Attributes

fields A dictionary of fields constructed by this pump