def __getitem__(self, idx): ys, meta, _, xs = self.mix[idx] xs = torch.from_numpy(xs) ys = torch.from_numpy(ys) X1s = torchaudio.functional.spectrogram(waveform=torch.transpose( xs[0, :, :], 0, 1), pad=0, window=torch.hann_window(400), n_fft=512, hop_length=256, win_length=400, power=None, normalized=False) X2s = torchaudio.functional.spectrogram(waveform=torch.transpose( xs[1, :, :], 0, 1), pad=0, window=torch.hann_window(400), n_fft=512, hop_length=256, win_length=400, power=None, normalized=False) Ys = torchaudio.functional.spectrogram(waveform=torch.transpose( ys, 0, 1), pad=0, window=torch.hann_window(400), n_fft=512, hop_length=256, win_length=400, power=None, normalized=False) M1s = (X1s[0, :, :, 0]**2 + X1s[0, :, :, 1]**2) / (X1s[0, :, :, 0]**2 + X1s[0, :, :, 1]**2 + X2s[0, :, :, 0]**2 + X2s[0, :, :, 1]**2) M2s = (X1s[1, :, :, 0]**2 + X1s[1, :, :, 1]**2) / (X1s[1, :, :, 0]**2 + X1s[1, :, :, 1]**2 + X2s[1, :, :, 0]**2 + X2s[1, :, :, 1]**2) Ms = torch.cat( (torch.unsqueeze(M1s, dim=0), torch.unsqueeze(M2s, dim=0)), 0) tau = BIRD.getTDOA(meta)[0] return Ys, Ms, tau
def __getitem__(self, idx): ys, meta, _, _ = self.mix[idx] ys = torch.from_numpy(ys) Ys = torchaudio.functional.spectrogram(waveform=torch.transpose( ys, 0, 1), pad=0, window=torch.hann_window(400), n_fft=512, hop_length=256, win_length=400, power=None, normalized=False) taus = BIRD.getTDOA(meta) taus = torch.tensor(taus[0:2]) return Ys, taus