Beispiel #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)
Beispiel #2
0
    def test_compare_both_biorthogonal_window_variants(self):
        window = signal.blackman(1024)
        shift = 256

        for_result = _biorthogonal_window_loopy(window, shift)
        vec_result = _biorthogonal_window(window, shift)
        brute_force_result = _biorthogonal_window_brute_force(window, shift)

        tc.assert_equal(for_result, vec_result)
        tc.assert_allclose(for_result, brute_force_result)
        tc.assert_equal(for_result.shape, (1024, ))
Beispiel #3
0
    def test_biorthogonal_window_inverts_analysis_window_kaldi_parameter(self):
        from paderbox.array import roll_zeropad

        def inf_shift_add(analysis_window, shift):
            influence_width = ((len(analysis_window) - 1) // shift)
            influence_width *= 2  # be sure that it is high enough

            res = np.zeros_like(analysis_window)
            for i in range(-influence_width, influence_width + 1):
                res += roll_zeropad(analysis_window, shift * i)
            return res

        window = signal.blackman(400)
        shift = 160

        synthesis_window = _biorthogonal_window_brute_force(window, shift)

        s = inf_shift_add(window * synthesis_window, shift)
        tc.assert_allclose(s, 1)
Beispiel #4
0
 def test_center_frequencies(self):
     tc.assert_allclose(
         get_stft_center_frequencies(size=1024, sample_rate=16000)[0], 0)