espnet2.layers.augmentation.preemphasis
Less than 1 minute
espnet2.layers.augmentation.preemphasis
espnet2.layers.augmentation.preemphasis(waveform, sample_rate: int, coeff: float = 0.97)
Pre-emphasize a waveform along the time dimension.
The pre-emphasis operation is defined as: : y[i] = x[i] - coeff * x[i - 1]
This process enhances the high-frequency components of the audio signal, which can be beneficial for certain types of processing, such as speech recognition.
- Parameters:
- waveform (torch.Tensor) – audio signal (…, time)
- sample_rate (int) – sampling rate in Hz (not used)
- coeff (float) – pre-emphasis coefficient. Typically between 0.0 and 1.0.
- Returns: pre-emphasized signal (…, time)
- Return type: ret (torch.Tensor)
Examples
>>> import torch
>>> waveform = torch.tensor([0.0, 1.0, 0.5, 0.2])
>>> sample_rate = 16000
>>> preemphasized_waveform = preemphasis(waveform, sample_rate)
>>> print(preemphasized_waveform)