Skip to content

nexuml.data.loaders.dali_wav

nexuml.data.loaders.dali_wav

DALI WAV audio pipeline for file-backed audio datasets.

PyTorchIterator

Bases: DALIGenericIterator

DALIGenericIterator with multi-label support via TensorDict lookup.

wav_data_pipeline

wav_data_pipeline(
    files: list[str],
    target_sr: int = 16000,
    target_length: float | None = 10,
    mono: bool = True,
    shuffle: bool = False,
    shard_id: int = 0,
    num_shards: int = 1,
    device: str = "cpu",
    dont_use_mmap: bool = True,
    rnd_crop_size: float | None = None,
    start_sec: float | None = None,
) -> Any

Load WAV files with DALI native readers and return audio + file index label.

Returns:

Type Description
Any

Tuple of audio tensor and integer file-index label.

Raises:

Type Description
ValueError

If a crop/start offset is requested without a target length.

DaliAudioPipeline

DaliAudioPipeline(
    files: list[str],
    labels: list[list[int]] | TensorDict,
    batch_size: int,
    target_sr: int = 16000,
    target_length: float = 10,
    mono: bool = True,
    num_threads: int = -1,
    prefetch_factor: int = 2,
    shuffle: bool = False,
    local_rank: int = 0,
    global_rank: int = 0,
    world_size: int = 1,
    random_crop_size: float | None = None,
    start_sec: float | None = None,
    **kwargs,
) -> PyTorchIterator

Build and return a DALI audio pipeline as a PyTorchIterator.

Returns:

Type Description
PyTorchIterator

A PyTorchIterator over the built DALI pipeline.