espnet2.gan_svs.visinger2.ddsp.resample
Less than 1 minute
espnet2.gan_svs.visinger2.ddsp.resample
espnet2.gan_svs.visinger2.ddsp.resample(x, factor: int)
Resamples the input tensor by a given factor using a convolutional approach.
This function takes a 3D tensor (batch, frame, channel) and resamples it by inserting zeros between the original samples, followed by a convolution with a Hann window to smooth the output.
- Parameters:
- x (torch.Tensor) – A 3D tensor of shape (batch, frame, channel) representing the input signal to be resampled.
- factor (int) – The factor by which to resample the input tensor. A factor of 2 will double the size of the output in the time dimension.
- Returns: A 3D tensor of shape (batch, factor * frame, channel) : representing the resampled signal.
- Return type: torch.Tensor
Examples
>>> x = torch.rand(4, 100, 2) # Batch of 4 signals, each with 100 frames and 2 channels
>>> resampled = resample(x, 2)
>>> print(resampled.shape)
torch.Size([4, 200, 2]) # Output shape is now (batch, 200 frames, channel)
NOTE
The input tensor should have at least 3 dimensions. The resampling is performed by inserting zeros between samples, followed by a convolution operation with a Hann window for smoothing.