Beispiel #1
0
    def test_result_equal(self):
        import time

        F = 513

        phi_XX = pos_def_hermitian(F, 6, 6)
        phi_NN = pos_def_hermitian(F, 6, 6)
        t = time.time()
        beamforming_vector = np.empty((F, 6), dtype=np.complex128)
        eigenvals = np.empty((F, 6), dtype=np.complex128)
        eigenvecs = np.empty((F, 6, 6), dtype=np.complex128)
        for f in range(F):
            eigenvals[f], eigenvecs[f] = eig(
                phi_XX[f, :, :], phi_NN[f, :, :]
            )
            beamforming_vector[f, :] = eigenvecs[f, :, np.argmax(eigenvals[f])]
        elapsed_time_python = time.time() - t

        t = time.time()
        eigenvals_c, eigenvecs_c = _cythonized_eig(phi_XX, phi_NN)
        beamforming_vector_cython = eigenvecs_c[range(F), :,
                                    np.argmax(eigenvals_c, axis=1)]
        elapsed_time_cython1 = time.time() - t

        tc.assert_allclose(
            cos_similarity(beamforming_vector, beamforming_vector_cython),
            1.0, atol=1e-6)

        # assume speedup is bigger than 4
        assert elapsed_time_python / elapsed_time_cython1 > 4
Beispiel #2
0
 def test_gev_ban_dimensions(self):
     output = blind_analytic_normalization(get_gev_vector(
         pos_def_hermitian(
             self.shape_psd), pos_def_hermitian(
             self.shape_psd)), pos_def_hermitian(
             self.shape_psd)
     )
     tc.assert_equal(output.shape, self.shape_vector)
Beispiel #3
0
    def test_result_equal(self):
        import time

        F = 513

        phi_XX = pos_def_hermitian(F, 6, 6)
        phi_NN = pos_def_hermitian(F, 6, 6)
        t = time.time()
        python_gev = _get_gev_vector(phi_XX, phi_NN)
        elapsed_time_python = time.time() - t

        t = time.time()
        cython_gev = get_gev_vector(phi_XX, phi_NN, True)
        elapsed_time_cython1 = time.time() - t

        tc.assert_allclose(cos_similarity(python_gev, cython_gev),
                           1.0, atol=1e-6)

        # assume speedup is bigger than 4
        # azure has problems to get the speedup of 4 -> 3
        assert elapsed_time_python/elapsed_time_cython1 > 3
 def setUpClass(self):
     sensors, bins, num_spk = 5, 128, 2
     self.num_spk = num_spk
     self.target_psd = pos_def_hermitian(bins, sensors, sensors)
     self.noise_psd = pos_def_hermitian(bins, sensors, sensors)
     self.output_shape = (bins, sensors)
Beispiel #5
0
 def test_wmwf_dimensions_frequency_dependent_distortion_weight(self):
     output = get_wmwf_vector(
         pos_def_hermitian(self.shape_psd),
         pos_def_hermitian(self.shape_psd),
         reference_channel=1, distortion_weight='frequency_dependent')
     tc.assert_equal(output.shape, self.shape_vector)
Beispiel #6
0
 def test_wmwf_dimensions(self):
     output = get_wmwf_vector(
         pos_def_hermitian(self.shape_psd),
         pos_def_hermitian(self.shape_psd),
         reference_channel=1)
     tc.assert_equal(output.shape, self.shape_vector)
Beispiel #7
0
 def test_mvdr_souden_dimensions_with_ref_channel(self):
     output = get_mvdr_vector_souden(
         pos_def_hermitian(
             self.shape_psd), pos_def_hermitian(
             self.shape_psd), ref_channel=1)
     tc.assert_equal(output.shape, self.shape_vector)
Beispiel #8
0
 def test_mvdr_souden_dimensions(self):
     output = get_mvdr_vector_souden(
         pos_def_hermitian(
             self.shape_psd), pos_def_hermitian(
             self.shape_psd))
     tc.assert_equal(output.shape, self.shape_vector)
Beispiel #9
0
 def test_gev_dimensions(self):
     output = get_gev_vector(
         pos_def_hermitian(
             self.shape_psd), pos_def_hermitian(
             self.shape_psd))
     tc.assert_equal(output.shape, self.shape_vector)