selfclean_audio.datasets.utils#

Members

fast_scandir

Quickly scan a directory for files with specified extensions.

resize_waveform

Resize a waveform tensor to the target length by trimming or padding.

selfclean_audio.datasets.utils.resize_waveform(waveform: Tensor, target_length: int)[source]#

Resize a waveform tensor to the target length by trimming or padding.

Parameters:
  • waveform (torch.Tensor) – Input waveform tensor of shape (channels, length).

  • target_length (int) – Desired length of the output waveform.

Returns:

Resized waveform tensor with the specified length.

Return type:

torch.Tensor

selfclean_audio.datasets.utils.fast_scandir(path: str, exts: list[str], recursive: bool = False)[source]#

Quickly scan a directory for files with specified extensions. From github.com/drscotthawley/aeiou/blob/main/aeiou/core.py

Parameters:
  • path (str) – Directory path to scan.

  • exts (list[str]) – List of file extensions to filter (e.g., [‘.wav’, ‘.mp3’]).

  • recursive (bool) – If True, scan subdirectories recursively. Defaults to False.

Returns:

A tuple containing a list of subfolder paths and a list of matched file paths.

Return type:

tuple[list[str], list[str]]