Remove audio selection loader classs
This merge request removes the AudioSelectionLoader Class. Overall this class was mostly a helper (utility) class to save a couple of lines of code and i found it very unnecessary for the little it was doing. I also added more examples to the AudioLoader
class docstrings.
Furthermore it added confusion on which class to use when. I find that working with the lower level classes is more straightforward and allows greater flexibility. In summary, this change effectively means that instead of doing:
loader = AudioSelectionLoader(path="path/to/wav/", selections=sel, repres=rep)
You now have to use the more primitive classes:
loader = AudioLoader(selection_gen=SelectionTableIterator(data_dir="path/to/wav/", selection_table=sel), repres=rep)
As you can see, barely anything changes.
A more complete example to test:
from ketos.audio.audio_loader import AudioLoader, SelectionTableIterator
from ketos.data_handling.selection_table import standardize
import pandas as pd
# specify the audio representation
rep = {'type':'MagSpectrogram', 'window':0.2, 'step':0.02, 'window_func':'hamming'}
# Load selections
annot = pd.DataFrame([{"filename":"2min.wav", "start":2.0, "end":3.0, "label":0},
{"filename":"2min.wav", "start":5.0, "end":6.0, "label":0},
{"filename":"2min.wav", "start":21.0, "end":22.0, "label":},
{"filename":"2min.wav", "start":25.0, "end":27.0, "label":0}]
annot_std = standardize(table=annot)
# create a generator for iterating over all the selections
generator = SelectionTableIterator(data_dir="ketos/tests/assets/", selection_table=annot_std)
# Create a loader by passing the generator and the representation to the AudioLoader
loader = AudioLoader(selection_gen=generator, repres=rep)
spec = next(loader)
fig = spec.plot()
import matplotlib.pyplot as plt
plt.show()