espnet2.gan_svs.visinger2.ddsp.amp_to_impulse_response
Less than 1 minute
espnet2.gan_svs.visinger2.ddsp.amp_to_impulse_response
espnet2.gan_svs.visinger2.ddsp.amp_to_impulse_response(amp, target_size)
Converts an amplitude spectrum to an impulse response using the inverse FFT.
This function takes an amplitude spectrum and converts it into an impulse response suitable for signal processing tasks. It first stacks the amplitude spectrum with a zero imaginary part, converts it to a complex tensor, and applies the inverse real FFT to obtain the time-domain signal. The result is then windowed and padded to match the specified target size.
- Parameters:
- amp (torch.Tensor) – The input amplitude spectrum of shape (n_freq,).
- target_size (int) – The desired size of the output impulse response.
- Returns: The impulse response of shape (target_size,).
- Return type: torch.Tensor
Examples
>>> amp = torch.tensor([0.1, 0.2, 0.3, 0.4])
>>> target_size = 8
>>> impulse_response = amp_to_impulse_response(amp, target_size)
>>> print(impulse_response.shape)
torch.Size([8])
NOTE
The input amplitude spectrum should contain non-negative values, and the target size must be greater than or equal to the size of the computed impulse response.
- Raises:
- ValueError – If the target_size is less than the length of the computed
- impulse response. –