PyTorch torch.istft Function


Pytorch torch 参考手册Pytorch torch Reference Manual

torch.istftis a function in PyTorch used for the Inverse Short-Time Fourier Transform (ISTFT). It converts the frequency-domain representation back to a time-domain signal, and is used together withtorch.stftfor 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 Example

Example

import torch

# Perform STFT first, 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)
print("Reconstructed signal shape:", reconstructed.shape)

Pytorch torch 参考手册Pytorch torch Reference Manual

Other Extensions