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

Feature/volume perturbation #382

Merged

Conversation

videodanchik
Copy link
Contributor

Add volume perturbation

Copy link
Collaborator

@pzelasko pzelasko left a comment

Choose a reason for hiding this comment

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

Wow great work and nice test coverage! I left a couple of comments. I’m also thinking that naming it perturb_volume rather than perturb_vol would be more consistent with other Lhotse names (we have usually avoided abbreviations in APIs so far).


def __init__(
self,
factors: Union[float, List[float]],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
factors: Union[float, List[float]],
factors: Union[float, Sequence[float]],

This allows tuples without type checker conflicts



def test_deserialize_transform(audio):
speed = AudioTransform.from_dict({'name': 'Speed', 'kwargs': {'factor': 1.1}})
perturbed = speed(audio, SAMPLING_RATE)
assert perturbed.shape == (1, 14545)
Copy link
Collaborator

@pzelasko pzelasko Aug 22, 2021

Choose a reason for hiding this comment

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

These changes would ideally be introduced in a copy of this unit test (my principle is one logical assertion == one unit test, to avoid tests that check two or more independent functionalities because they are confusing to readers and harder to debug)

speed = AudioTransform.from_dict(data)
perturbed = speed(audio, SAMPLING_RATE)
assert perturbed.shape == (1, 14545)
vol_orig = Vol(factor=0.5)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as above

@videodanchik
Copy link
Contributor Author

videodanchik commented Aug 23, 2021

I split tests and replaced vol with volume everywhere. Also did replacement you suggested: List -> Sequence in lhotse/dataset/cut_transforms/perturb_volume.py and lhotse/dataset/cut_transforms/perturb_speed.py (where I copied it from). And finally replaced recording_id=f'{self.recording_id}_vp{factor}' if affix_id else self.id with recording_id=f'{self.recording_id}_vp{factor}' if affix_id else self.recording_id in lhotse/supervision.py for perturb_speed/tempo/volume as I believe it was a typos (I made it with a separate commit, so this can be easily reverted).

@pzelasko
Copy link
Collaborator

Oh yeah that's a good catch. Thanks a lot!

@pzelasko pzelasko merged commit b8d8603 into lhotse-speech:master Aug 23, 2021
@pzelasko pzelasko added this to the v0.8 milestone Aug 23, 2021
@pzelasko pzelasko mentioned this pull request Aug 25, 2021
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.

2 participants