PyTorch torch.istft 関数
torch.istftは PyTorch で短時間フーリエ逆変換(Inverse Short-Time Fourier Transform)を行うための関数です。周波数表現を時間領域の信号に変換し、torch.stftと組み合わせて信号処理を行います。
関数定義
torch.istft(input, n_fft, hop_length=None, win_length=None, window=None, center=True, normalized=False, onesided=True, length=None, return_complex=False)
使用例
サンプル
import torch
# まずSTFTを実行し、その後ISTFTを実行します
x = torch.randn(1, 16000)
window = torch.hann_window(512)
# 短時間フーリエ変換
stft_result = torch.stft(x, n_fft=512, hop_length=160, win_length=512, window=window)
# 短時間フーリエ逆変換
reconstructed = torch.istft(stft_result, n_fft=512, hop_length=160, win_length=512, window=window, length=16000)
print("再構成された信号の形状:", reconstructed.shape)
# まずSTFTを実行し、その後ISTFTを実行します
x = torch.randn(1, 16000)
window = torch.hann_window(512)
# 短時間フーリエ変換
stft_result = torch.stft(x, n_fft=512, hop_length=160, win_length=512, window=window)
# 短時間フーリエ逆変換
reconstructed = torch.istft(stft_result, n_fft=512, hop_length=160, win_length=512, window=window, length=16000)
print("再構成された信号の形状:", reconstructed.shape)
その他の拡張
Pytorch torch リファレンスマニュアル