Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
2c80669
Add SIGMOSFilterStage and ensure_cudnn_loaded utility
shubhamNvidia Mar 5, 2026
5faad7a
Add SIGMOS model files
shubhamNvidia Mar 5, 2026
e64f75b
Add unit tests for SIGMOSFilterStage
shubhamNvidia Mar 5, 2026
f3f8928
Simplified config, removed temp file creation, uses in-memory predict…
shubhamNvidia Mar 11, 2026
01dc37e
Guard GPU fallback, delegate GPU detection to stage, replace print wi…
shubhamNvidia Mar 12, 2026
ffd5888
Fix copyrights, restore upstream gpu_utils and added ensure cudnn fun…
shubhamNvidia Mar 20, 2026
be96268
Add common utilities, replace duplicate _resolve_model_path in sigmos.py
shubhamNvidia Mar 22, 2026
fda7068
Add AudioDataFilterStage composite pipeline with VAD, quality filteri…
shubhamNvidia Mar 22, 2026
ab83471
change resource allocation pattern
shubhamNvidia Mar 22, 2026
24834bd
change resource allocation pattern
shubhamNvidia Mar 22, 2026
cfc3cdc
Fix CompositeStage example, make TimestampMapper conditional on segme…
shubhamNvidia Mar 23, 2026
dfc6ae9
Remove SIGMOSConfig, modernize types, untrack ADV test
shubhamNvidia Mar 24, 2026
042f36b
Replace AudioDataFilterConfig with YAML config, resolve PR review com…
shubhamNvidia Mar 24, 2026
7dacb2e
Merge upstream/main into pr/audio-sigmos
shubhamNvidia Mar 25, 2026
802fa41
Merge remote-tracking branch 'upstream/main' into pr/advance-pipeline
shubhamNvidia Mar 25, 2026
b2c48cf
Merge branch 'main' into pr/audio-sigmos
sarahyurick Mar 25, 2026
64e09ed
Merge branch 'main' into pr/advance-pipeline
sarahyurick Mar 25, 2026
e910433
Fix ruff lint violations in audio sigmos filter stage
shubhamNvidia Mar 25, 2026
65533a6
Fix ruff lint violations in advance pipeline stage
shubhamNvidia Mar 25, 2026
9e3c559
Migrate to AudioTask single-dict pattern
shubhamNvidia Mar 26, 2026
9acf672
Migrate to AudioTask single-dict pattern
shubhamNvidia Mar 26, 2026
3840328
Merge upstream/main, resolve conflicts keeping utility functions
shubhamNvidia Mar 26, 2026
250c67f
Add nested segments handling to SIGMOSFilterStage
shubhamNvidia Mar 30, 2026
fd740de
Merge branch 'main' into pr/advance-pipeline
shubhamNvidia Mar 30, 2026
6912606
Merge branch 'main' into pr/audio-sigmos
sarahyurick Mar 31, 2026
b4035d5
Merge branch 'main' into pr/advance-pipeline
sarahyurick Mar 31, 2026
8eb54e7
Add AudioDataFilterStage export to audio stages __init__.py
shubhamNvidia Apr 1, 2026
65730b0
fix ruff linting errors in sigmos files
shubhamNvidia Mar 31, 2026
37d2a80
Merge upstream/main into pr/advance-pipeline
shubhamNvidia Apr 1, 2026
de20c46
Merge upstream/main into pr/audio-sigmos
shubhamNvidia Apr 1, 2026
672dfe0
fix: lazy import predict_audio_mos to avoid onnxruntime import at col…
shubhamNvidia Apr 1, 2026
a1f3c82
fix: guard sigmos import to avoid ImportError during test collection
shubhamNvidia Apr 1, 2026
3747312
Merge branch 'main' into pr/audio-sigmos
shubhamNvidia Apr 2, 2026
42c2e29
Merge branch 'main' into pr/advance-pipeline
shubhamNvidia Apr 2, 2026
e089988
Merge remote-tracking branch 'upstream/main' into pr/audio-sigmos
shubhamNvidia Apr 2, 2026
2380e51
Merge remote-tracking branch 'upstream/main' into pr/advance-pipeline
shubhamNvidia Apr 2, 2026
b3228af
Merge branch 'main' into pr/audio-sigmos
shubhamNvidia Apr 2, 2026
02d3580
fix: move _deep_merge to top-level import
shubhamNvidia Apr 2, 2026
25a5956
Merge branch 'main' into pr/advance-pipeline
shubhamNvidia Apr 2, 2026
32215b4
Merge upstream/main, resolve conflicts keeping both changes
shubhamNvidia Apr 3, 2026
6beb62b
Merge upstream/main, resolve __init__.py keeping both changes
shubhamNvidia Apr 3, 2026
a0022ea
Merge upstream/main and address reviewer feedback for SIGMOS
shubhamNvidia Apr 5, 2026
75809cc
Remove bundled ONNX model, auto-download from Microsoft GitHub
shubhamNvidia Apr 5, 2026
d0936c4
Address review feedback: guard teardown, add deps, remove dead code
shubhamNvidia Apr 5, 2026
f297f01
Merge branch 'main' into pr/audio-sigmos
sarahyurick Apr 6, 2026
7e6be59
Merge upstream/main into pr/advance-pipeline, resolve __init__.py con…
shubhamNvidia Apr 6, 2026
ec072cb
Merge origin/pr/audio-sigmos into pr/advance-pipeline, resolve __init…
shubhamNvidia Apr 6, 2026
e18eb77
Address review feedback: rename dirs, add validations, fix bugs, add …
shubhamNvidia Apr 6, 2026
47372e3
Fix ruff lint: sort imports, remove unused imports, escape regex, ext…
shubhamNvidia Apr 6, 2026
abeca1e
Merge branch 'main' into pr/advance-pipeline
shubhamNvidia Apr 6, 2026
f1696f2
Address test review: remove redundant tests, move pickle import to to…
shubhamNvidia Apr 6, 2026
1ea1455
Merge upstream/main into pr/advance-pipeline, resolve conflicts
shubhamNvidia Apr 6, 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
5 changes: 4 additions & 1 deletion nemo_curator/stages/audio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
Audio curation stages for NeMo Curator.

This module provides stages for processing and curating audio data,
including ASR inference, quality assessment, and ALM data preparation.
including ASR inference, quality assessment, ALM data preparation,
and advanced audio processing pipelines.
"""

from nemo_curator.stages.audio.advance_pipelines import AudioDataFilterStage

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.

Adding AudioDataFilterStage to the top-level audio/__init__.py means import nemo_curator.stages.audio triggers the entire import chain:

  • AudioDataFilterStage → SIGMOSFilterStage → third-party sigmos.py → import librosa, import scipy, import onnxruntime
  • AudioDataFilterStage → VADSegmentationStage → import torch, import torchaudio, from silero_vad import ...
  • AudioDataFilterStage → UTMOSFilterStage → import torch

Users who only need basic audio stages (e.g., GetAudioDurationStage, PreserveByValueStage) pay the cost of loading all these heavy ML libraries.

Fix with lazy-importing AudioDataFilterStage.

from nemo_curator.stages.audio.alm import ALMDataBuilderStage, ALMDataOverlapStage
from nemo_curator.stages.audio.common import (
GetAudioDurationStage,
Expand All @@ -28,6 +30,7 @@
__all__ = [
"ALMDataBuilderStage",
"ALMDataOverlapStage",
"AudioDataFilterStage",
"GetAudioDurationStage",
"PreserveByValueStage",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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.

"""
Audio Data Filter pipeline.

Composite pipeline stage for audio curation with VAD,
quality filtering, speaker separation, and timestamp tracking.

Example::

from nemo_curator.stages.audio.advance_pipelines import (
AudioDataFilterStage,
)

# Using default config
pipeline.add_stage(AudioDataFilterStage())

# Using custom YAML config
pipeline.add_stage(AudioDataFilterStage(config_path="my_config.yaml"))
"""

from .audio_data_filter import AudioDataFilterStage

__all__ = [
"AudioDataFilterStage",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
# 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.

"""
Audio Data Filter Stage -- CompositeStage that decomposes into independent
pipeline stages for extracting clean single-speaker segments.

Pipeline (when all filters + speaker separation enabled)::

1. MonoConversion (1:1)
2. VAD batch mode (1:1, items = N segments)
3. BandFilter (1:1, filter items)
4. UTMOS (1:1, filter items)
5. SIGMOS (1:1, filter items)
6. SegmentConcatenation (1:1, M items -> 1 item + timestamp mappings)
7. SpeakerSeparation (1:N fan-out)
8-11. Per-speaker: VAD + Band + UTMOS + SIGMOS
12. TimestampMapper (1:1, resolve to original file positions)

Usage::

# Using default config
pipeline.add_stage(AudioDataFilterStage())

# Using custom YAML config
pipeline.add_stage(AudioDataFilterStage(config_path="/path/to/config.yaml"))
"""

from __future__ import annotations

from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
from pathlib import Path

from loguru import logger

from nemo_curator.stages.audio.filtering import BandFilterStage, SIGMOSFilterStage, UTMOSFilterStage
from nemo_curator.stages.audio.postprocessing import TimestampMapperStage
from nemo_curator.stages.audio.preprocessing import MonoConversionStage, SegmentConcatenationStage
from nemo_curator.stages.audio.segmentation import SpeakerSeparationStage, VADSegmentationStage
from nemo_curator.stages.base import CompositeStage, ProcessingStage

from .config import get_enabled_stages, load_config


class AudioDataFilterStage(CompositeStage):
"""Complete audio data filtering and curation pipeline (CompositeStage).

Decomposes into independent stages that the executor can schedule with
cross-file parallelism. Each stage owns its own default resource
allocation. Use ``.with_()`` to override individual stage resources.

Args:
config_path: Path to a YAML config file. When *None* the
built-in ``default_config.yaml`` is used.
config: Pre-loaded config dict (alternative to *config_path*).
When both are given, *config* values override the YAML file.
name: Name for this composite stage instance.
"""

def __init__(
self,
config_path: str | Path | None = None,
config: dict[str, Any] | None = None,
name: str = "AudioDataFilter",
) -> None:
super().__init__()
self.name = name
self._cfg = load_config(config_path)
if config:
from .config import _deep_merge

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.

This can be a top-level import.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Currently, there is no test for this PR. Will add tests once the dependent PRs (filtering, segmentation, preprocessing) are merged; currently can't test due to cross-PR import dependencies.


self._cfg = _deep_merge(self._cfg, config)

def decompose(self) -> list[ProcessingStage]:
cfg = self._cfg
stages: list[ProcessingStage] = []

mc = cfg.get("mono_conversion", {})
stages.append(
MonoConversionStage(
output_sample_rate=mc.get("output_sample_rate", 48000),
strict_sample_rate=mc.get("strict_sample_rate", True),
name="MonoConversion",
)
)

vad = cfg.get("vad", {})
band = cfg.get("band_filter", {})
utmos = cfg.get("utmos", {})
sigmos = cfg.get("sigmos", {})
speaker = cfg.get("speaker_separation", {})
concat = cfg.get("concatenation", {})
ts = cfg.get("timestamp_mapper", {})

enable_vad = vad.get("enable", True)
enable_band = band.get("enable", True)
enable_utmos = utmos.get("enable", True)
enable_sigmos = sigmos.get("enable", True)
enable_speaker = speaker.get("enable", True)

self._append_filter_stages(
stages,
vad,
band,
utmos,
sigmos,
enable_vad,
enable_band,
enable_utmos,
enable_sigmos,
suffix="",
)

if enable_speaker:
if enable_vad:
stages.append(
SegmentConcatenationStage(
silence_duration_sec=concat.get("silence_duration_sec", 0.5),
name="SegmentConcat",
)
)

stages.append(
SpeakerSeparationStage(
exclude_overlaps=speaker.get("exclude_overlaps", True),
min_duration=speaker.get("min_duration", 0.8),
gap_threshold=speaker.get("gap_threshold", 0.1),
buffer_time=speaker.get("buffer_time", 0.5),
name="SpeakerSeparation",
)
)

self._append_filter_stages(
stages,
vad,
band,
utmos,
sigmos,
enable_vad,
enable_band,
enable_utmos,
enable_sigmos,
suffix="_Speaker",
)

if enable_vad or enable_speaker:
stages.append(
TimestampMapperStage(
passthrough_keys=ts.get("passthrough_keys"),
name="TimestampMapper",
)
)

enabled = get_enabled_stages(cfg)
logger.info(
f"AudioDataFilterStage decomposed into {len(stages)} stages "
f"(enabled: {enabled}, speaker_sep: {enable_speaker})"
)
return stages

@staticmethod
def _append_filter_stages( # noqa: PLR0913
stages: list[ProcessingStage],
vad: dict,
band: dict,
utmos: dict,
sigmos: dict,
enable_vad: bool,
enable_band: bool,
enable_utmos: bool,
enable_sigmos: bool,
*,
suffix: str,
) -> None:
"""Append VAD + quality filter stages to *stages* list."""
if enable_vad:
stages.append(
VADSegmentationStage(
min_duration_sec=vad.get("min_duration_sec", 2.0),
max_duration_sec=vad.get("max_duration_sec", 60.0),
threshold=vad.get("threshold", 0.5),
min_interval_ms=vad.get("min_interval_ms", 500),
speech_pad_ms=vad.get("speech_pad_ms", 300),
nested=(suffix == ""),
name=f"VAD{suffix}",
)
)

if enable_band:
stages.append(
BandFilterStage(
band_value=band.get("band_value", "full_band"),
name=f"BandFilter{suffix}",
)
)

if enable_utmos:
stages.append(
UTMOSFilterStage(
mos_threshold=utmos.get("mos_threshold", 3.5),
name=f"UTMOS{suffix}",
)
)

if enable_sigmos:
stages.append(
SIGMOSFilterStage(
noise_threshold=sigmos.get("noise_threshold", 4.0),
ovrl_threshold=sigmos.get("ovrl_threshold", 3.5),
sig_threshold=sigmos.get("sig_threshold"),
col_threshold=sigmos.get("col_threshold"),
disc_threshold=sigmos.get("disc_threshold"),
loud_threshold=sigmos.get("loud_threshold"),
reverb_threshold=sigmos.get("reverb_threshold"),
name=f"SIGMOS{suffix}",
)
)
Loading
Loading