Ejemplo n.º 1
0
    def test_window_length(self):
        X = stft(self.x, 512, 160, window_length=400)
        x_hat = istft(X, 512, 160, window_length=400)

        X_ref = istft(stft(self.x, 400, 160), 400, 160)
        tc.assert_equal(X.shape, (243, 257))

        tc.assert_allclose(X_ref, x_hat, rtol=1e-6, atol=1e-6)
Ejemplo n.º 2
0
    def test_restore_time_signal_with_str_window(self):
        x = self.x
        X = stft(x, window='hann')

        tc.assert_almost_equal(
            x, istft(X, 1024, 256, window='hann', num_samples=len(x)))
        tc.assert_equal(X.shape, (154, 513))
Ejemplo n.º 3
0
 def istft(self, X):
     from paderbox.transform.module_stft import istft
     return istft(
         X,
         size=self.stft_size,
         shift=self.stft_shift,
         fading=self.stft_fading,
     )
Ejemplo n.º 4
0
 def test_restore_time_signal_from_stft_and_istft_odd_parameter(self):
     x = self.x
     import random
     kwargs = dict(
         # size=np.random.randint(100, 200),
         size=151,  # Test uneven size
         shift=np.random.randint(40, 100),
         window=random.choice(['blackman', 'hann', 'hamming']),
         fading='full',
     )
     X = stft(x, **kwargs)
     x_hat = istft(X, **kwargs, num_samples=x.shape[-1])
     assert x_hat.dtype == np.float64, (x_hat.dtype, x.dtype)
     tc.assert_almost_equal(x, x_hat, err_msg=str(kwargs))
Ejemplo n.º 5
0
    def test_restore_time_signal_from_stft_and_istft(self):
        x = self.x
        X = stft(x)

        tc.assert_almost_equal(x, istft(X, 1024, 256)[:len(x)])
        tc.assert_equal(X.shape, (154, 513))
Ejemplo n.º 6
0
    def test_restore_time_signal_from_stft_and_istft_kaldi_params(self):
        x = self.x
        X = stft(x, size=400, shift=160)

        tc.assert_almost_equal(x, istft(X, 400, 160)[:len(x)])
        tc.assert_equal(X.shape, (243, 201))
Ejemplo n.º 7
0
    def test_restore_time_signal_from_stft_and_istft_with_num_samples(self):
        x = self.x
        X = stft(x)

        tc.assert_almost_equal(x, istft(X, 1024, 256, num_samples=len(x)))
        tc.assert_equal(X.shape, (154, 513))