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

Add narrow band augmentation support #8806

Closed

Conversation

jmayank1511
Copy link

What does this PR do ?

Add support for narrowband augmentations in lhotse dataloaders and fix small bug in noise augmentation

Add a one line overview of what this PR aims to accomplish.

Collection: [Note which collection this PR will affect]

Changelog

  • Add specific line by line info of high level changes in this PR.

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this 

Jenkins CI

To run Jenkins, a NeMo User with write access must comment jenkins on the PR.

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • New Feature
  • Bugfix
  • Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

Who can review?

Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.

Additional Information

  • Related to # (issue)

@github-actions github-actions bot added the common label Apr 3, 2024

# 2.c. On-the-fly Narrowband augmentation
if config.nb_augmentation:
nb_cuts = cuts.resample(config.sample_rate // 2)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm wondering if this SR shouldn't be hardcoded as 8000Hz since narrowband telephony is defined as 300Hz - 3400Hz, if somebody changes config.sample_rate it's not really going to go down to true narrowband.

nemo/collections/common/data/lhotse/dataloader.py Outdated Show resolved Hide resolved
pzelasko
pzelasko previously approved these changes Apr 5, 2024
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.

LGTM

@pzelasko
Copy link
Collaborator

pzelasko commented Apr 5, 2024

jenkins

@pzelasko
Copy link
Collaborator

jenkins

1 similar comment
@pzelasko
Copy link
Collaborator

jenkins

Copy link
Collaborator

@anteju anteju left a comment

Choose a reason for hiding this comment

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

Thanks @jmayank1511!
I added a couple comments.

def __init__(self, sampling_rate, target_sampling_rate=8000, p=0.5, seed=0):
self.sampling_rate = sampling_rate
self.target_sampling_rate = target_sampling_rate
self.p = p
Copy link
Collaborator

@anteju anteju Apr 15, 2024

Choose a reason for hiding this comment

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

Double-check that p is valid, e.g., in (0,1)

@@ -299,3 +310,24 @@ def _flatten_alt_text(cut) -> list:
text_instance.custom = {"text": data.pop("text"), "lang": data.pop("lang"), **data}
ans.append(text_instance)
return ans


class NarrowbandTransform:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This class is doing a resampling transform.
I'd suggest to consider naming it to something like ResamplingTransform.


# 2.b. On-the-fly speed perturbation.
# mux here ensures it's uniformly distributed throughout sampling,
# and applying it here (before sampler/dataset) ensures optimal
# bucket allocation.
if config.perturb_speed:
cuts = CutSet.mux(cuts, cuts.perturb_speed(0.9), cuts.perturb_speed(1.1),)

# 2.c. On-the-fly Narrowband augmentation
if config.nb_augmentation:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd suggest naming this parameter downsampling augmentation, or something similar.

A band-pass augmentation (e.g., to simulate telephony frequency bandwidth) could be an additional augmentation, with corresponding lower and upper frequency.


def __init__(self, sampling_rate, target_sampling_rate=8000, p=0.5, seed=0):
self.sampling_rate = sampling_rate
self.target_sampling_rate = target_sampling_rate
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: target_sampling_rate may be a bit misleading, since the output signal will be at sampling_rate.
Consider using something like resampling_rate, which could fit well with ResamplingTransform

nit2: consider checking resampling rate is less than the input sample rate, and raise either a warning or even an error otherwise.

Mayank Jain and others added 4 commits April 18, 2024 15:07
Signed-off-by: Mayank Jain <mayjain@nvidia.com>
for more information, see https://pre-commit.ci

Signed-off-by: Mayank Jain <mayjain@nvidia.com>
Signed-off-by: Mayank Jain <mayjain@nvidia.com>
Copy link
Contributor

github-actions bot commented May 3, 2024

This PR is stale because it has been open for 14 days with no activity. Remove stale label or comment or update or this will be closed in 7 days.

@github-actions github-actions bot added the stale label May 3, 2024
Copy link
Contributor

This PR was closed because it has been inactive for 7 days since being marked as stale.

@github-actions github-actions bot closed this May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants