class Resynthesizer(object): def __init__(self, device, win_size=320, hop_size=160): self.stft = STFT(win_size, hop_size).to(device) def __call__(self, est, mix): sph_est = self.stft.istft(est) sph_est = F.pad(sph_est, [0, mix.shape[1]-sph_est.shape[1]]) return sph_est
class Resynthesizer(object): def __init__(self, device, win_size=320, hop_size=160): self.stft = STFT(win_size, hop_size).to(device) def __call__(self, est, mix): real_mix, imag_mix = self.stft.stft(mix) pha_mix = torch.atan2(imag_mix.data, real_mix.data) real_est = est * torch.cos(pha_mix) imag_est = est * torch.sin(pha_mix) sph_est = self.stft.istft(torch.stack([real_est, imag_est], dim=1)) sph_est = F.pad(sph_est, [0, mix.shape[1]-sph_est.shape[1]]) return sph_est