espnet2.gan_svs.utils.expand_f0.expand_f0
espnet2.gan_svs.utils.expand_f0.expand_f0
espnet2.gan_svs.utils.expand_f0.expand_f0(f0_frame, hop_length, method='interpolation')
Expand the fundamental frequency (f0) to match the output waveform length.
This function takes an input tensor representing f0 values across frames and expands it to a longer output tensor corresponding to the desired waveform length using specified methods.
espnet2.gan_svs.utils.expand_f0.f0_frame
Input tensor with shape (B, 1, frame_len) representing f0 values for each frame.
- Type: Tensor
espnet2.gan_svs.utils.expand_f0.hop_length
The hop length to calculate the output waveform length.
- Type: Tensor
espnet2.gan_svs.utils.expand_f0.method
The method used for expansion, either ‘interpolation’ or ‘repeat’.
Type: str
Parameters:
- f0_frame (Tensor) – Input tensor (B, 1, frame_len) containing f0 values.
- hop_length (int) – The hop length to determine the output length.
- method (str) – The method to expand f0. Choose either ‘interpolation’ or ‘repeat’.
Returns: Output tensor (B, 1, wav_len) containing expanded f0 values.
Return type: Tensor
Raises:ValueError – If the specified method is not ‘interpolation’ or ‘repeat’.
Examples
>>> import torch
>>> f0 = torch.randn(2, 1, 5) # Example f0 frame tensor
>>> hop_length = 4
>>> expanded_f0 = expand_f0(f0, hop_length, method="interpolation")
>>> expanded_f0.shape
torch.Size([2, 1, 20])
>>> expanded_f0_repeat = expand_f0(f0, hop_length, method="repeat")
>>> expanded_f0_repeat.shape
torch.Size([2, 1, 20])
NOTE
The output tensor length is determined by the product of hop_length and the input frame length.