espnet2.layers.augmentation.polarity_inverse
Less than 1 minute
espnet2.layers.augmentation.polarity_inverse
espnet2.layers.augmentation.polarity_inverse(waveform, sample_rate)
Invert the polarity of the input waveform.
This function takes an audio waveform as input and returns the waveform with its polarity inverted, effectively multiplying the waveform by -1. This can be useful in audio processing to create effects or mitigate phase issues.
- Parameters:
- waveform (torch.Tensor) – The audio signal to be processed. It should have the shape (…, time).
- sample_rate (int) – The sampling rate of the audio signal (not used in this function).
- Returns: The waveform with inverted polarity, having the same : shape as the input waveform.
- Return type: torch.Tensor
Examples
>>> import torch
>>> waveform = torch.tensor([0.5, -0.2, 0.3, -0.1])
>>> inverted_waveform = polarity_inverse(waveform, sample_rate=16000)
>>> print(inverted_waveform)
tensor([-0.5000, 0.2000, -0.3000, 0.1000])