Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • ketos ketos
  • Project information
    • Project information
    • Activity
    • Labels
    • Planning hierarchy
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 27
    • Issues 27
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • public_projects
  • ketosketos
  • Merge requests
  • !254

Merged
Created Jun 30, 2022 by Bruno Padovese@bpadoveseOwner

Remove audio selection loader classs

  • Overview 2
  • Commits 5
  • Pipelines 2
  • Changes 4

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()
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: remove_AudioSelectionLoaderClasss