soundmentations.StartPad¶
- class soundmentations.StartPad(pad_length: int, p: float = 1.0)[source]¶
Bases:
BasePadPad audio to minimum length by adding zeros at the beginning.
If the input audio is shorter than pad_length, zeros are prepended to reach the minimum length. If already longer or equal, returns unchanged.
- Parameters:
Examples
Apply start padding:
>>> import numpy as np >>> from soundmentations.transforms.time import StartPad >>> >>> audio = np.array([1, 2, 3]) >>> pad_transform = StartPad(pad_length=6) >>> result = pad_transform(audio) >>> print(result) # [0 0 0 1 2 3]
Use for aligning audio to end of fixed windows:
>>> # Align audio to end of 3-second windows >>> start_pad = StartPad(pad_length=132300) # 3 seconds at 44.1kHz >>> aligned_audio = start_pad(audio_sample)