Skip to navigation

nemo_curator.stages.audio.postprocessing.sed_postprocessing

View as Markdown

SED Postprocessing stage: label audio entries with detected sound events.

Reads the per-frame probability matrix from task data (in-memory, preferred) or from an NPZ sidecar file (fallback), then detects events for each sound class group (speech, music, noise, etc.) using thresholding. The detected events are added as labels to the task data — no filtering or segmentation is performed.

Requires: pip install numpy (scipy optional for smoothing)

Module Contents

Classes

NameDescription
SEDPostprocessingStageLabel audio entries with detected sound events from SED framewise output.

API

class nemo_curator.stages.audio.postprocessing.SEDPostprocessingStage(
agg_mode: str = 'noisy_or',
threshold: float = 0.5,
min_duration_sec: float = 0.3,
smoothing_window_sec: float = 0.0,
hysteresis_low: float | None = None,
hysteresis_high: float | None = None,
merge_gap_sec: float = 0.0,
emit_superclasses: bool = False,
framewise_key: str = '_sed_framewise',
npz_filepath_key: str = 'npz_filepath',
events_key: str = 'sed_events',
name: str = 'SEDPostprocessing',
batch_size: int = 1,
resources: nemo_curator.stages.resources.Resources = (lambda: Resources(cpus=1.0...
)
Dataclass

Bases: ProcessingStage[AudioTask, AudioTask]

Label audio entries with detected sound events from SED framewise output.

Reads framewise data from task data (in-memory _sed_framewise key, preferred) or falls back to reading from NPZ file (npz_filepath key). For each sound class group in SUPERCLASS_GROUPS (speech, music, noise, etc.), aggregates probabilities, converts to events via thresholding, and stores all detected events as sed_events on the output task.

This is a labeling stage — the task passes through with event labels attached, no filtering or fan-out is performed.

Parameters:

agg_mode
strDefaults to 'noisy_or'

Aggregation mode for class groups. Default "noisy_or".

threshold
floatDefaults to 0.5

Probability threshold for event detection. Default 0.4.

min_duration_sec
floatDefaults to 0.3

Minimum event duration. Default 0.3.

smoothing_window_sec
floatDefaults to 0.0

Median filter window in seconds (0 = disabled).

hysteresis_low
float | NoneDefaults to None

Low threshold for hysteresis (None = simple threshold).

hysteresis_high
float | NoneDefaults to None

High threshold for hysteresis (None = simple threshold).

merge_gap_sec
floatDefaults to 0.0

Merge events with gaps smaller than this (0 = disabled).

emit_superclasses
boolDefaults to False

If True, aggregate probabilities per superclass group (noisy-or across member class indices) and emit one event series per superclass (e.g. "speech", "music"). Default False. When False (default), every AudioSet class index is thresholded independently; each event carries label (e.g. "electric_guitar") and superclass (e.g. "music").

framewise_key
strDefaults to '_sed_framewise'

Key in task data for in-memory framewise array. Default "_sed_framewise".

npz_filepath_key
strDefaults to 'npz_filepath'

Key in task data for NPZ path (fallback). Default "npz_filepath".

events_key
strDefaults to 'sed_events'

Key for output events list. Default "sed_events".

agg_mode
str = 'noisy_or'
batch_size
int = 1
emit_superclasses
bool = False
events_key
str = 'sed_events'
framewise_key
str = '_sed_framewise'
hysteresis_high
float | None = None
hysteresis_low
float | None = None
merge_gap_sec
float = 0.0
min_duration_sec
float = 0.3
name
str = 'SEDPostprocessing'
npz_filepath_key
str = 'npz_filepath'
resources
Resources
smoothing_window_sec
float = 0.0
threshold
float = 0.5
nemo_curator.stages.audio.postprocessing.SEDPostprocessingStage._default_fps() -> float
staticmethod
nemo_curator.stages.audio.postprocessing.SEDPostprocessingStage._detect_all_events(
data: dict
) -> list[dict]

Detect events for all SUPERCLASS_GROUPS and return a merged, sorted list.

nemo_curator.stages.audio.postprocessing.SEDPostprocessingStage.inputs() -> tuple[list[str], list[str]]
nemo_curator.stages.audio.postprocessing.SEDPostprocessingStage.outputs() -> tuple[list[str], list[str]]
nemo_curator.stages.audio.postprocessing.SEDPostprocessingStage.process(