soundmentations.RandomGain¶
- class soundmentations.RandomGain(min_gain: float, max_gain: float, clip: bool = True, p: float = 1.0)[source]¶
Bases:
GainApply a random gain to audio samples within a specified range.
This transform randomly selects a gain value from a uniform distribution between min_gain and max_gain, applying it to the audio samples.
- Parameters:
Examples
>>> import numpy as np >>> from soundmentations.transforms.amplitude import RandomGain >>> >>> # Create audio samples >>> samples = np.array([0.1, 0.2, -0.1, 0.3]) >>> >>> # Apply random gain between -6dB and +6dB >>> random_gain_transform = RandomGain(min_gain=-6.0, max_gain=6.0) >>> result = random_gain_transform(samples)