I try to do some DSP thing and I need to convert frame into single bin and then restore the frame from that bin. Here’s minimal example:
import torch
import matplotlib.pyplot as plt
frame = torch.rand(1536)
bin = torch.stft(frame, n_fft=frame.shape[0], hop_length=frame.shape[0], center=False,
return_complex=True, window=torch.hann_window(frame.shape[0]))
rest_frame = torch.istft(bin, n_fft=frame.shape[0], hop_length=frame.shape[0], center=False,
return_complex=True, window=torch.hann_window(frame.shape[0]))
plt.plot(rest_frame-frame)
plt.show()
I expected to get the same frame, but instead I got
RuntimeError: Cannot have onesided output if window or input is complex
in istft. torch.stft produces the bin that I need, but I still can’t make istft work. What do I do wrong?