Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bf035d9
Add VADSegmentationStage
shubhamNvidia Mar 5, 2026
8de8742
Add unit tests for VADSegmentationStage
shubhamNvidia Mar 5, 2026
eb4b2bc
Simplified config, canonical waveform format refactoring
shubhamNvidia Mar 11, 2026
5dee980
Remove threading lock, fix squeeze dim, copy metadata per fan-out seg…
shubhamNvidia Mar 12, 2026
76d6af7
Fix copyrights, remove unused imports, fix multi-channel squeeze, cle…
shubhamNvidia Mar 20, 2026
a1206b7
Add common utilities, replace duplicate _load_audio_file with shared …
shubhamNvidia Mar 22, 2026
f53d83c
change resource allocation pattern
shubhamNvidia Mar 22, 2026
511a4ae
Remove VADConfig, guard silero import, fix segment_num and waveform o…
shubhamNvidia Mar 24, 2026
c11d25e
Merge upstream/main into pr/audio-vad
shubhamNvidia Mar 25, 2026
8208545
Merge branch 'main' into pr/audio-vad
sarahyurick Mar 25, 2026
174a521
Fix ruff lint violations in audio VAD segmentation stage
shubhamNvidia Mar 25, 2026
494c088
Migrate to AudioTask single-dict pattern
shubhamNvidia Mar 26, 2026
fcac79b
Merge upstream/main, resolve conflicts keeping utility functions
shubhamNvidia Mar 26, 2026
b184313
Add nested segment mode to VADSegmentationStage
shubhamNvidia Mar 30, 2026
551ede5
Merge branch 'main' into pr/audio-vad
sarahyurick Mar 31, 2026
23db429
fix ruff linting errors in vad segmentation
shubhamNvidia Apr 1, 2026
4088c20
Merge upstream/main into pr/audio-vad
shubhamNvidia Apr 1, 2026
46eb1d8
fix: guard torchaudio import to avoid ImportError during test collection
shubhamNvidia Apr 1, 2026
c26094d
Merge remote-tracking branch 'upstream/main' into pr/audio-vad
shubhamNvidia Apr 2, 2026
6e650d8
fix: skip VAD tests when silero_vad is not installed
shubhamNvidia Apr 2, 2026
e240495
Merge remote-tracking branch 'upstream/main' into pr/audio-vad
shubhamNvidia Apr 2, 2026
ef09da8
fix: apply reviewer suggestions - typo fix, remove redundant init, to…
shubhamNvidia Apr 2, 2026
ed69cb8
Merge branch 'main' into pr/audio-vad
shubhamNvidia Apr 2, 2026
7aa9caf
Merge upstream/main, resolve __init__.py keeping both changes
shubhamNvidia Apr 3, 2026
6e29adc
Apply suggestions from code review
sarahyurick Apr 3, 2026
0f34b80
Merge branch 'main' into pr/audio-vad
sarahyurick Apr 3, 2026
835cd3e
Apply suggestion from @sarahyurick
sarahyurick Apr 3, 2026
1a265e3
Merge upstream/main into pr/audio-vad
shubhamNvidia Apr 4, 2026
baee33b
Merge branch 'pr/audio-vad' of origin into pr/audio-vad
shubhamNvidia Apr 4, 2026
599f658
Address review: default VAD to CPU, fix nested no-speech contract
shubhamNvidia Apr 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions nemo_curator/stages/audio/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
NeMo Curator Audio Processing Stages.

Segmentation:
- VADSegmentationStage: Voice Activity Detection segmentation
"""

from nemo_curator.stages.audio.segmentation import (
VADSegmentationStage,
)

from nemo_curator.stages.audio.configs import (
VADConfig,
)

__all__ = [
"VADSegmentationStage",
"VADConfig",
]
10 changes: 10 additions & 0 deletions nemo_curator/stages/audio/configs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
# Licensed under the Apache License, Version 2.0

"""Configuration classes for audio processing stages."""
Comment thread
shubhamNvidia marked this conversation as resolved.
Resolved

from .vad import VADConfig

__all__ = [
"VADConfig",
]
74 changes: 74 additions & 0 deletions nemo_curator/stages/audio/configs/vad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""VAD (Voice Activity Detection) configuration."""

from dataclasses import dataclass
from typing import Any

# Internal defaults (not exposed in config)
_MIN_INTERVAL_MS = 500
_THRESHOLD = 0.5
_SPEECH_PAD_MS = 300


@dataclass
class VADConfig:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Discussed offline. We do not need a config class per stage.

"""
Configuration for Voice Activity Detection stage.

Controls how audio is segmented based on speech activity.
Uses Silero VAD model which supports both CPU and GPU execution.

Attributes:
min_duration_sec: Minimum segment duration to keep (seconds)
max_duration_sec: Maximum segment duration (seconds)

Example:
config = VADConfig(min_duration_sec=2.0, max_duration_sec=30.0)
"""

min_duration_sec: float = 2.0
max_duration_sec: float = 60.0

@property
def min_interval_ms(self) -> int:
return _MIN_INTERVAL_MS

@property
def threshold(self) -> float:
return _THRESHOLD

@property
def speech_pad_ms(self) -> int:
return _SPEECH_PAD_MS

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

threshold, speech_pad_ms, and min_interval_ms are non-configurable read-only properties

These three parameters are declared as @property methods returning module-level constants, not as dataclass fields. This means they can never be configured by the caller, and the following all break at runtime:

  1. VADConfig(threshold=0.7) → TypeError: __init__() got an unexpected keyword argument 'threshold'
  2. VADConfig.from_dict({"threshold": 0.6}) silently ignores "threshold" because __dataclass_fields__ only contains min_duration_sec and max_duration_sec
  3. to_dict() doesn't serialize them, so a round-trip always loses these values

This directly breaks multiple tests:

  • test_from_dict (line 36-39): calls from_dict({"threshold": 0.6}) and asserts cfg.threshold == 0.6 — always 0.5, fails
  • test_from_dict_ignores_unknown (line 46-47): asserts cfg.threshold == 0.3 after from_dict({"threshold": 0.3}) — always 0.5, fails
  • test_roundtrip (line 56): calls VADConfig(min_duration_sec=1.5, threshold=0.7, speech_pad_ms=200) — raises TypeError
  • test_config_overrides_params in the stage tests (line 81): calls VADConfig(threshold=0.7) — raises TypeError

These fields must be promoted to proper dataclass fields to be configurable:

@dataclass
class VADConfig:
    min_duration_sec: float = 2.0
    max_duration_sec: float = 60.0
    threshold: float = _THRESHOLD
    speech_pad_ms: int = _SPEECH_PAD_MS
    min_interval_ms: int = _MIN_INTERVAL_MS

And to_dict() must include them so the round-trip works correctly.


@classmethod
def from_dict(cls, d: dict) -> "VADConfig":
"""Create config from dictionary."""
if d is None:
return cls()
valid_keys = cls.__dataclass_fields__.keys()
return cls(**{k: v for k, v in d.items() if k in valid_keys})
Comment thread
shubhamNvidia marked this conversation as resolved.
Resolved

def to_dict(self) -> dict:
"""Convert to dictionary."""
return {
'min_duration_sec': self.min_duration_sec,
'max_duration_sec': self.max_duration_sec,
}

def get(self, key: str, default: Any = None) -> Any:
"""Get configuration value with default."""
return getattr(self, key, default)
Comment thread
shubhamNvidia marked this conversation as resolved.
Resolved
8 changes: 8 additions & 0 deletions nemo_curator/stages/audio/segmentation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
# Licensed under the Apache License, Version 2.0

"""Audio segmentation stages."""
Comment thread
shubhamNvidia marked this conversation as resolved.
Resolved

from .vad_segmentation import VADSegmentationStage

__all__ = ["VADSegmentationStage"]
Loading