Class TimeStretch<T>
- Namespace
- AiDotNet.Augmentation.Audio
- Assembly
- AiDotNet.dll
Stretches or compresses audio in time without changing pitch.
public class TimeStretch<T> : AudioAugmenterBase<T>, IAugmentation<T, Tensor<T>>
Type Parameters
TThe numeric type for calculations.
- Inheritance
-
AugmentationBase<T, Tensor<T>>TimeStretch<T>
- Implements
-
IAugmentation<T, Tensor<T>>
- Inherited Members
Remarks
For Beginners: Time stretching makes audio faster or slower without changing the pitch - like how a slower speaker still has the same voice pitch. This is different from simply playing at a different speed.
When to use:
- Speech recognition to handle different speaking speeds
- Music tempo adjustment
- Synchronizing audio with video
Constructors
TimeStretch(double, double, double, int)
Creates a new time stretch augmentation.
public TimeStretch(double minRate = 0.8, double maxRate = 1.2, double probability = 0.5, int sampleRate = 16000)
Parameters
minRatedoubleMinimum stretch rate (default: 0.8).
maxRatedoubleMaximum stretch rate (default: 1.2).
probabilitydoubleProbability of applying this augmentation (default: 0.5).
sampleRateintSample rate of the audio in Hz (default: 16000).
Properties
MaxRate
Gets the maximum time stretch factor.
public double MaxRate { get; }
Property Value
Remarks
Default: 1.2 (20% slower)
Values greater than 1.0 slow down the audio.
MinRate
Gets the minimum time stretch factor.
public double MinRate { get; }
Property Value
Remarks
Default: 0.8 (20% faster)
Values less than 1.0 speed up the audio.
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.