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
Conversation
|
||
# 2.c. On-the-fly Narrowband augmentation | ||
if config.nb_augmentation: | ||
nb_cuts = cuts.resample(config.sample_rate // 2) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
jenkins |
228c86f
to
a4456cc
Compare
jenkins |
1 similar comment
jenkins |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
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>
2b81941
to
6d6731e
Compare
for more information, see https://pre-commit.ci
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. |
This PR was closed because it has been inactive for 7 days since being marked as stale. |
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
Usage
# 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:
PR Type:
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