API Reference

Quick Import Guide

Import all transforms directly from the main package:

from soundmentations import *

All Available Transforms

Compose

Compose multiple audio transforms into a sequential pipeline.

OneOf

Apply one transform from a list of transforms, chosen at random.

Trim

Trim audio to keep only the portion between start_time and end_time.

RandomTrim

Randomly trim audio by selecting a random segment of specified duration.

StartTrim

Trim audio to keep only the portion starting from start_time to the end.

EndTrim

Trim audio to keep only the portion from the start to end_time.

CenterTrim

Trim audio to keep only the center portion of specified duration.

Pad

Pad audio to minimum length by adding zeros at the end.

CenterPad

Pad audio to minimum length by adding zeros symmetrically on both sides.

StartPad

Pad audio to minimum length by adding zeros at the beginning.

PadToLength

Pad or trim audio to exact target length using end operations.

CenterPadToLength

Pad or trim audio to exact target length using center operations.

PadToMultiple

Pad audio to make its length a multiple of the specified value.

Mask

Mask a random contiguous segment of audio data with zeros.

Gain

Apply a fixed gain (in dB) to audio samples.

RandomGain

Apply a random gain to audio samples within a specified range.

PerSampleRandomGain

Apply a different random gain to each audio sample in a batch.

RandomGainEnvelope

Apply a smoothly varying random gain envelope to audio samples.

Limiter

Apply hard limiting to audio samples to prevent clipping.

FadeIn

Fade-in effect for audio samples.

FadeOut

Apply a fade-out effect to the end of audio samples.

Compressor

Apply dynamic range compression to the audio sample.

PitchShift

Shift the pitch of audio by a specified number of semitones.

RandomPitchShift

Randomly shift the pitch within a specified semitone range.

Transforms by Category

Composition

Compose(transforms)

Compose multiple audio transforms into a sequential pipeline.

OneOf(transforms[, p])

Apply one transform from a list of transforms, chosen at random.

Time Transforms

Trim Transforms

Trim([start_time, end_time, p])

Trim audio to keep only the portion between start_time and end_time.

RandomTrim(duration[, p])

Randomly trim audio by selecting a random segment of specified duration.

StartTrim([start_time, p])

Trim audio to keep only the portion starting from start_time to the end.

EndTrim(end_time[, p])

Trim audio to keep only the portion from the start to end_time.

CenterTrim(duration[, p])

Trim audio to keep only the center portion of specified duration.

Pad Transforms

Pad(pad_length[, p])

Pad audio to minimum length by adding zeros at the end.

CenterPad(pad_length[, p])

Pad audio to minimum length by adding zeros symmetrically on both sides.

StartPad(pad_length[, p])

Pad audio to minimum length by adding zeros at the beginning.

PadToLength(pad_length[, p])

Pad or trim audio to exact target length using end operations.

CenterPadToLength(pad_length[, p])

Pad or trim audio to exact target length using center operations.

PadToMultiple(pad_length[, p])

Pad audio to make its length a multiple of the specified value.

Mask Transforms

Mask([mask_ratio, p])

Mask a random contiguous segment of audio data with zeros.

Amplitude Transforms

Gain Transforms

Gain([gain, clip, p])

Apply a fixed gain (in dB) to audio samples.

RandomGain(min_gain, max_gain[, clip, p])

Apply a random gain to audio samples within a specified range.

PerSampleRandomGain(min_gain, max_gain[, ...])

Apply a different random gain to each audio sample in a batch.

RandomGainEnvelope(min_gain, max_gain[, ...])

Apply a smoothly varying random gain envelope to audio samples.

Limiter Transforms

Limiter([threshold, p])

Apply hard limiting to audio samples to prevent clipping.

Fade Transforms

FadeIn([duration, p])

Fade-in effect for audio samples.

FadeOut([duration, p])

Apply a fade-out effect to the end of audio samples.

Compressor Transforms

Compressor(threshold, ratio, attack_time, ...)

Apply dynamic range compression to the audio sample.

Frequency Transforms

Pitch Transforms

PitchShift(semitones[, p])

Shift the pitch of audio by a specified number of semitones.

RandomPitchShift([min_semitones, ...])

Randomly shift the pitch within a specified semitone range.