Class AudioNoise<T>
- Namespace
- AiDotNet.Augmentation.Audio
- Assembly
- AiDotNet.dll
Adds background noise to audio data.
public class AudioNoise<T> : AudioAugmenterBase<T>, IAugmentation<T, Tensor<T>>
Type Parameters
TThe numeric type for calculations.
- Inheritance
-
AugmentationBase<T, Tensor<T>>AudioNoise<T>
- Implements
-
IAugmentation<T, Tensor<T>>
- Inherited Members
Remarks
For Beginners: This augmentation adds random noise to audio, simulating real-world recording conditions like background hum, ambient sounds, or electronic interference. This helps models become robust to noisy inputs.
SNR (Signal-to-Noise Ratio):
- Higher SNR = less noise (cleaner audio)
- Lower SNR = more noise (noisier audio)
- 20 dB = barely audible noise
- 10 dB = noticeable noise
- 0 dB = signal and noise are equal
Constructors
AudioNoise(double, double, double, int)
Creates a new audio noise augmentation.
public AudioNoise(double minSnrDb = 10, double maxSnrDb = 30, double probability = 0.3, int sampleRate = 16000)
Parameters
minSnrDbdoubleMinimum SNR in dB (default: 10.0).
maxSnrDbdoubleMaximum SNR in dB (default: 30.0).
probabilitydoubleProbability of applying this augmentation (default: 0.3).
sampleRateintSample rate of the audio in Hz (default: 16000).
Properties
MaxSnrDb
Gets the maximum signal-to-noise ratio in dB.
public double MaxSnrDb { get; }
Property Value
MinSnrDb
Gets the minimum signal-to-noise ratio in dB.
public double MinSnrDb { get; }
Property Value
NoiseType
Gets or sets the type of noise to add.
public NoiseType NoiseType { get; set; }
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.