soundmentations.StartTrim¶
- class soundmentations.StartTrim(start_time: float = 0.0, p: float = 1.0)[source]¶
Bases:
BaseTrim
Trim audio to keep only the portion starting from start_time to the end.
This removes the beginning of the audio up to start_time, keeping everything after that point.
- Parameters:
Examples
Remove silence from beginning:
>>> import numpy as np >>> from soundmentations.transforms.time import StartTrim >>> >>> # Remove first 2 seconds >>> trim_transform = StartTrim(start_time=2.0) >>> trimmed = trim_transform(audio, sample_rate=44100)
Use in preprocessing pipeline:
>>> import soundmentations as S >>> >>> # Remove intro and normalize >>> preprocess = S.Compose([ ... S.StartTrim(start_time=1.5, p=1.0), ... S.PadToLength(pad_length=132300, p=1.0) # 3 seconds ... ]) >>> >>> processed = preprocess(raw_audio, sample_rate=44100)