Class VolumeChange<T>
- Namespace
- AiDotNet.Augmentation.Audio
- Assembly
- AiDotNet.dll
Randomly changes the volume (gain) of audio.
public class VolumeChange<T> : AudioAugmenterBase<T>, IAugmentation<T, Tensor<T>>
Type Parameters
TThe numeric type for calculations.
- Inheritance
-
AugmentationBase<T, Tensor<T>>VolumeChange<T>
- Implements
-
IAugmentation<T, Tensor<T>>
- Inherited Members
Remarks
For Beginners: Volume change augmentation makes audio louder or quieter. This helps models become robust to different recording volumes and microphone distances.
Gain in dB:
- +6 dB ≈ 2x louder
- 0 dB = no change
- -6 dB ≈ 0.5x volume
Constructors
VolumeChange(double, double, double, int)
Creates a new volume change augmentation.
public VolumeChange(double minGainDb = -6, double maxGainDb = 6, double probability = 0.5, int sampleRate = 16000)
Parameters
minGainDbdoubleMinimum gain in dB (default: -6.0).
maxGainDbdoubleMaximum gain in dB (default: 6.0).
probabilitydoubleProbability of applying this augmentation (default: 0.5).
sampleRateintSample rate of the audio in Hz (default: 16000).
Properties
MaxGainDb
Gets the maximum volume change in dB.
public double MaxGainDb { get; }
Property Value
MinGainDb
Gets the minimum volume change in dB.
public double MinGainDb { get; }
Property Value
Methods
ApplyAugmentation(Tensor<T>, AugmentationContext<T>)
Implement this method to perform the actual augmentation.
protected override Tensor<T> ApplyAugmentation(Tensor<T> data, AugmentationContext<T> context)
Parameters
dataTensor<T>The input data.
contextAugmentationContext<T>The augmentation context.
Returns
- Tensor<T>
The augmented data.
GetParameters()
Gets the parameters of this augmentation.
public override IDictionary<string, object> GetParameters()
Returns
- IDictionary<string, object>
A dictionary of parameter names to values.