espnet2.gan_svs.visinger2.ddsp.upsample
Less than 1 minute
espnet2.gan_svs.visinger2.ddsp.upsample
espnet2.gan_svs.visinger2.ddsp.upsample(signal, factor)
Upsample a given signal by a specified factor using interpolation.
This function takes a 3-dimensional input tensor representing a batch of signals, where the dimensions correspond to (batch_size, num_channels, num_frames). It uses the PyTorch interpolate function to upsample the signal along the last dimension by the specified factor.
- Parameters:
- signal (torch.Tensor) – Input tensor of shape (batch_size, num_channels, num_frames) representing the signal to be upsampled.
- factor (int) – The upsampling factor. This determines how many times the signal will be upsampled.
- Returns: The upsampled signal tensor of shape (batch_size, : num_channels, num_frames * factor).
- Return type: torch.Tensor
Examples
>>> import torch
>>> signal = torch.randn(2, 3, 4) # Example input tensor
>>> upsampled_signal = upsample(signal, 2)
>>> print(upsampled_signal.shape)
torch.Size([2, 3, 8]) # Output shape is doubled in the last dimension
NOTE
The upsampling is performed using linear interpolation, which may introduce artifacts in the signal. It is recommended to use this function when the input signal is well-sampled.