Skip to content

[ASR] Add unit tests for VAD thresholding and post-processing logic#15704

Open
shivansh023023 wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
shivansh023023:test/vad-utils-thresholding-unit-tests
Open

[ASR] Add unit tests for VAD thresholding and post-processing logic#15704
shivansh023023 wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
shivansh023023:test/vad-utils-thresholding-unit-tests

Conversation

@shivansh023023
Copy link
Copy Markdown

What does this PR do?

Adds 26 CPU-only unit tests for the VAD (Voice Activity Detection) thresholding
and post-processing pipeline in nemo/collections/asr/parts/utils/vad_utils.py.
These functions had zero test coverage prior to this PR.

Collection: ASR

Changelog

  • tests/collections/asr/test_vad_utils.py (new file, 221 lines, 26 tests):
    • TestBinarization: symmetric threshold, hysteresis, empty input, all-zeros, all-ones, single-frame edge cases
    • TestBinarizationParametrized: threshold sweep over onset in [0.3, 0.5, 0.7, 0.9]
    • TestFiltering: short segment removal, no-op filtering, empty input
    • TestMergeOverlapSegment: overlapping merge, non-overlapping, empty input
    • TestSegmentHelpers: filter_short_segments, get_gap_segments, remove_segments
    • TestCalVadOnsetOffset: absolute and relative scale conversion
    • TestPercentile: basic and boundary percentile values
    • TestGenerateVadSegmentTablePerTensor: full pipeline correctness, determinism, non-overlapping output

Usage

# Run the new tests locally
pytest tests/collections/asr/test_vad_utils.py -v
# All 26 tests pass on CPU with no GPU required

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests? — Yes, this PR IS the tests
  • Did you add or update any necessary documentation? — No docs changes needed for test-only PR
  • Does the PR affect components that are optional to install? — No

PR Type:

  • New Feature
  • Bugfix
  • Documentation / Tests

Additional Information

Adds 26 CPU-only unit tests for nemo/collections/asr/parts/utils/vad_utils.py
covering the core VAD pipeline functions.

Tests cover:
- Binarization: symmetric threshold, hysteresis, empty/all-zeros/all-ones/single-frame
- Parametrized threshold sweep: onset in [0.3, 0.5, 0.7, 0.9]
- Filtering: short segment removal, gap merging, empty input
- Segment helpers: filter_short_segments, get_gap_segments, remove_segments
- Threshold scale conversion: absolute and relative modes
- Percentile utility: basic and boundary values
- Full pipeline integration: correctness, determinism, non-overlapping output

All tests are CPU-only and deterministic (torch.manual_seed(42)).

Signed-off-by: Hackathon User <hackathon@example.com>
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 16, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-maintainers Waiting on maintainers to respond label May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ASR community-request waiting-on-maintainers Waiting on maintainers to respond

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants