nemo_curator.stages.audio.common
nemo_curator.stages.audio.common
Module Contents
Classes
Functions
API
Bases: ProcessingStage[AudioTask, AudioTask]
Compute audio duration from the file at audio_filepath_key and store the result under duration_key.
Parameters:
Key to get path to wav file.
Key to put audio duration.
Bases: CompositeStage[_EmptyTask, AudioTask]
Composite stage for reading JSONL manifests.
Decomposes into:
- FilePartitioningStage — discovers and partitions manifest files
- ManifestReaderStage — reads each partition line-by-line (no Pandas)
Parameters:
Path or list of paths to JSONL manifests (local or cloud).
Number of manifest files per partition. Defaults to 1.
Target size per partition (e.g., “100MB”). Ignored if files_per_partition is set.
File extensions to filter. Defaults to [“.jsonl”, “.json”].
Storage options for cloud paths (S3, GCS credentials, endpoints).
Bases: ProcessingStage[FileGroupTask, AudioTask]
Read JSONL manifest files from a FileGroupTask and emit one AudioTask per line.
Uses line-by-line streaming via fsspec (no Pandas) to keep memory at ~1x file size. Supports local and cloud paths (S3, GCS).
Bases: ProcessingStage[AudioTask, AudioTask]
Append a single AudioTask to a JSONL manifest file.
The output file is truncated once in setup() (called on the driver)
so repeated pipeline runs produce a clean output. setup_on_node()
only creates the parent directory — it never truncates, so multi-node
deployments do not erase each other’s data.
.. note::
Because all nodes append to the same path, callers in multi-node
setups should either use a shared filesystem or provide a
node-unique output_path.
Supports local and cloud paths via fsspec.
Parameters:
Destination JSONL path (local or cloud).
Truncate the output file once on the driver before processing starts.
Ensure parent directory exists on each node (no truncation).
Bases: ProcessingStage[AudioTask, AudioTask]
Filter entries by comparing input_value_key against target_value.
Returns None from process() to drop entries that fail the
comparison, matching the text-modality filter convention.
Parameters:
The field in the dataset entries to evaluate.
The value to compare with.
Comparison operator (lt, le, eq, ne, ge, gt).
Convert multi-channel waveform to mono. Assumes 2D (channels, samples) input.
Ensure waveform is a torch.Tensor in 2D (channels, samples) format.
Get the duration of the audio file in seconds.
Load audio file and return waveform tensor (channels, samples) and sample rate.
Resolve a relative model path using the reference file’s directory and module subdirectory.
Resolve (waveform, sample_rate) from an item dict, loading from file if needed.
Checks item[‘waveform’] + item[‘sample_rate’], falls back to loading from item[‘audio_filepath’], resolves missing sample_rate from file header. Updates item in-place when loading from file. Returns None if resolution fails.