Fix random_segment TypeError when duration_sec is a float - #16303
Open
SIDDARTHAREDDY8 wants to merge 1 commit into
Open
SIDDARTHAREDDY8 wants to merge 1 commit into
SIDDARTHAREDDY8 wants to merge 1 commit into
Conversation
Signed-off-by: SIDDARTHA REDDY <75976672+SIDDARTHAREDDY8@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
The
Update branchbutton must only be pressed in very rare occassions.An outdated branch is never blocking the merge of a PR.
Please reach out to the automation team before pressing that button.
What does this PR do ?
Fixes
RandomSegmentPerturbation(random_segmentaugmentation) crashing withTypeError:pad_widthmust be of integral type.whenever it has to pad a short utterance andduration_secis a float - including the constructor default32.0.Collection: ASR
Changelog
nemo/collections/asr/parts/preprocessing/perturb.py: computepad_sizeasmath.ceil(self._duration_sec * data.sample_rate) - data.num_samples, an integer number of samples, soAudioSegment.pad->numpy.padalways receives an integralpad_width.math.ceilrather thanround/truncation is deliberate: the next statement issubsegment(0.0, duration_sec), which raisesValueErrorif the segment ends up shorter thanduration_sec, so the padded length must not round down. The integer-duration_secpath is unchanged (math.ceilof an int is a no-op).tests/collections/asr/test_preprocessing_segment.py: newTestRandomSegmentPerturbationwith parametrizedduration_secin[32.0, 32, 16.0, 16]verifying a short utterance is zero-padded to exactlyint(duration_sec) * sample_ratesamples for both int and float spellings.Usage
Before your PR is "Ready for review"
Pre checks:
PR Type:
Additional Information
math.ceilapproach.docs/source/asr/ssl/configs.rstomitspad_to_duration: truefrom itsrandom_segmentsnippet; this PR fixes only the crash and intentionally leaves the docs change out (it was part of fix(asr): pad random_segment with an integer sample count #16105 if a maintainer wants it restored).