PyTorch torch.istft function
PyTorch torch reference manual
torch.istft is a function in PyTorch for the Inverse Short-Time Fourier Transform. It converts a frequency-domain representation back to a time-domain signal and is used together with torch.stft for signal processing.
Function definition
torch.istft(input, n_fft, hop_length=None, win_length=None, window=None, center=True, normalized=False, onesided=True, length=None, return_complex=False)
Usage examples
Example
import
torch
Perform STFT first and then ISTFT
x
=
torch.
randn
(
1
,
16000
)
window
=
torch.
hann_window
(
512
)
Short-Time Fourier Transform
stft_result
=
torch.
stft
(
x
,
n_fft
=
512
,
hop_length
=
160
,
win_length
=
512
,
window
=
window
)
Inverse Short-Time Fourier Transform
reconstructed
=
torch.
istft
(
stft_result
,
n_fft
=
512
,
hop_length
=
160
,
win_length
=
512
,
window
=
window
,
length
=
16000
)
(
"Reconstructed signal shape:"
,
reconstructed.
shape
)