selfclean_audio.utils.sample#

Members

extract_sample

Normalize dataset samples to a common shape.

selfclean_audio.utils.sample.extract_sample(sample_tuple: tuple) Tuple[Tensor, str | None, int, Tensor][source]#

Normalize dataset samples to a common shape.

Accept tuples returned by various dataset implementations and return a tuple of (waveform, path, label, noisy_label) where: - waveform: torch.Tensor, shape (C, T) or (T,) - path: Optional[str] (file path or None if unavailable) - label: int (class index) - noisy_label: torch.Tensor scalar long, 0 for clean, 1 for noisy

This helper avoids repeated ad-hoc tuple length checks across the codebase.