Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding SalientExcerptMixSourceFolder object #228

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Conversation

ethman
Copy link
Collaborator

@ethman ethman commented Jun 26, 2021

Fixes #225

@codecov-commenter
Copy link

codecov-commenter commented Jul 2, 2021

Codecov Report

Merging #228 (134030f) into master (471e796) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #228   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           72        72           
  Lines         5209      5280   +71     
=========================================
+ Hits          5209      5280   +71     
Impacted Files Coverage Δ
nussl/datasets/__init__.py 100.00% <ø> (ø)
nussl/core/utils.py 100.00% <100.00%> (ø)
nussl/datasets/hooks.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 471e796...134030f. Read the comment docs.

Copy link
Collaborator Author

@ethman ethman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! I've added inline comments, but I think the main takeaways for me are that I would expect the changes to be contained within the SalientExcerptMixSourceFolder object and related tests, but it seems like there's a bit of spillover. Overall, great work Boaz!

hop_dur = int(dur * hop_ratio)
threshold = np.power(10.0, threshold_db / 20.0)
# adjust the shape of a mono track
if audio.shape[0] == 1:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work with stereo?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll double check, but I believe that the stereo worked fine, but for some reason mono needed to be formatted differently hence the special check.

nussl/datasets/base_dataset.py Outdated Show resolved Hide resolved
nussl/datasets/hooks.py Outdated Show resolved Hide resolved
nussl/datasets/hooks.py Outdated Show resolved Hide resolved
nussl/datasets/hooks.py Outdated Show resolved Hide resolved
tests/datasets/test_hooks.py Outdated Show resolved Hide resolved
nussl/datasets/hooks.py Outdated Show resolved Hide resolved
nussl/datasets/hooks.py Outdated Show resolved Hide resolved
nussl/datasets/hooks.py Outdated Show resolved Hide resolved
nussl/datasets/hooks.py Show resolved Hide resolved
… from base_dataset, adding padding code to hooks, reverting commit of multitrack, cleaning asserts in tests.
Copy link
Collaborator Author

@ethman ethman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good again. Getting closer. Keep iterating. I think we should nix the padding, as discussed below.

One nit pick is to make sure your code is following PEP8, specifically limiting the maximum line length to 79 chars: https://pep8.org/#maximum-line-length

nussl/datasets/hooks.py Outdated Show resolved Hide resolved
nussl/datasets/hooks.py Show resolved Hide resolved
nussl/datasets/hooks.py Outdated Show resolved Hide resolved
nussl/datasets/hooks.py Outdated Show resolved Hide resolved
nussl/datasets/hooks.py Outdated Show resolved Hide resolved
Copy link
Collaborator Author

@ethman ethman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking really good @boazcogan! Most of my comments are nit picks. I do have some opinions about how you should structure your code & logic for the balancing, but I'll pop into your stand up tomorrow to discuss.

folder (str): Location that should be processed to produce the
list of files.
salient_src (str): The name of the source that will be used to identify
salient samples in the dataset. e.g. ('drums')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure all of the wrapped lines have the same indent. Some have 4 spaces (or 1 tab) others have 2. Follow the docstrings in the rest of this file. This will be important when we have to build the documentation website.

segment_dur (float, optional): the duration of the desired audio clips
in seconds. Defaults to 4.0.
hop_ratio (float, optional): size of the hops to use when computing
the RMS. Defaults to 0.5.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not just the RMS, but more importantly the Segment window.

in seconds. Defaults to 4.0.
hop_ratio (float, optional): size of the hops to use when computing
the RMS. Defaults to 0.5.
verbose (bool, optional): suppress progress bar and logging for the
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This language is a bit ambiguous. Does "Suppress progress bar..." mean that if this arg is True it will suppress the progress bar? For bools, I like to be explicit in the docs: If True, this flag will blah blah. Else, blah blah.

self.hop_ratio,
mix.sample_rate,
self.threshold_db)
# this is a fairly cheap operation, no need to embed it within a
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need this comment

'mixsrc_item': item,
'start': start / mix.sample_rate
})
# if the balance flag is set then balance the metadata
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this comment. In general, use inline comments to explain code excerpts that might be difficult to parse like complex logic, a seemingly unorthodox decision, or the expected contents of a data structure. Adding unnecessary comments can clutter up the code.

A more effective comment here would be like # self._balance_set() will take care of the balancing logic. But I'm still not convinced you need a comment here though...

mixsrc_item = item['mixsrc_item']
# Note that the onset needs to be passed to the AudioSignal
# class as the kwarg offset.
onset = item['start']
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not rename this variable to start = item['start']? That way the code is clearer and we don't need this comment to explain what's happening.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it is right now, this variable is referred to by three names in just 3 lines of code: 'start' (in item['start']), onset, and offset (in the process_item kwarg). I'm not sure if there's enough context to name the variable offset here because there are a few layers of abstraction before the offset arg is used directly, so I think start conveys what's happening here well.

Sorry for the long winded explanation; I'm walking you through my thought process.

# others
avg_length = np.mean([elem[0] for elem in sample_counts])
metadata = []
for count, song, starts, sample_rate in sample_counts:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the AudioSignal might not be a song, so perhaps this is a confusing variable name. item would be better and more consistent with the rest of the object.

nussl/datasets/hooks.py Outdated Show resolved Hide resolved
list of files.
salient_src (str): The name of the source that will be used to identify
salient samples in the dataset. e.g. ('drums')
sample_rate (int, optional): the sampling rate for the audio files.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Make sure to use proper grammar in docstrings, including capitalizing the first word of each sentence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SalientExcerptMixSrc Dataset
3 participants