espnet2.tts.feats_extract.yin.differenceFunctionTorch
Less than 1 minute
espnet2.tts.feats_extract.yin.differenceFunctionTorch
espnet2.tts.feats_extract.yin.differenceFunctionTorch(xs: Tensor, N, tau_max) → Tensor
Compute the difference function using PyTorch for batch audio data.
This function computes the difference function in a batch-wise manner, which corresponds to the equation (6) in the referenced literature. The implementation leverages PyTorch’s FFT capabilities for efficient computation.
- Parameters:
- xs (torch.Tensor) – A batch of audio data of shape (B, T) where B is the batch size and T is the number of samples in each audio.
- N (int) – The length of the audio data.
- tau_max (int) – The maximum integration window size for the difference function computation.
- Returns: A tensor containing the computed difference function, : with shape (B, tau_max).
- Return type: torch.Tensor
Examples
>>> xs = torch.randn(32, int(22050 * 1.5)).cuda()
>>> N = xs.shape[-1]
>>> tau_max = 2048
>>> result = differenceFunctionTorch(xs, N, tau_max)
>>> print(result.shape)
torch.Size([32, 2048])
NOTE
This function has a level of error around 1e-4 when processing input shapes of (32, 22050 * 1.5).