| 101 | return outputs |
| 102 | |
| 103 | def test_fft(): |
| 104 | torch.manual_seed(20) |
| 105 | win_len = 320 |
| 106 | win_inc = 160 |
| 107 | fft_len = 512 |
| 108 | inputs = torch.randn([1, 1, 16000*4]) |
| 109 | fft = ConvSTFT(win_len, win_inc, fft_len, win_type='hanning', feature_type='real') |
| 110 | import librosa |
| 111 | |
| 112 | outputs1 = fft(inputs)[0] |
| 113 | outputs1 = outputs1.numpy()[0] |
| 114 | np_inputs = inputs.numpy().reshape([-1]) |
| 115 | librosa_stft = librosa.stft(np_inputs, win_length=win_len, n_fft=fft_len, hop_length=win_inc, center=False) |
| 116 | print(np.mean((outputs1 - np.abs(librosa_stft))**2)) |
| 117 | |
| 118 | def test_fft(): |
| 119 | torch.manual_seed(20) |