def test_batched_wpe_step(self): with self.test_session() as sess: Y_batch, inv_power_batch = self._get_batch_data() enhanced_ref_1 = tf_wpe.wpe_step(Y_batch[0], inv_power_batch[0]) enhanced_ref_2 = tf_wpe.wpe_step( Y_batch[0, ..., :self.T - 20], inv_power_batch[0, ..., :self.T - 20]) step_enhanced = tf_wpe.batched_wpe_step( Y_batch, inv_power_batch, num_frames=tf.convert_to_tensor([self.T, self.T - 20])) enhanced, ref1, ref2 = sess.run( [step_enhanced, enhanced_ref_1, enhanced_ref_2]) np.testing.assert_allclose(enhanced[0], ref1) np.testing.assert_allclose(enhanced[1, ..., :-20], ref2)
def test_recursive_wpe(self): with self.test_session() as sess: T = 5000 D = 2 K = 1 delay = 3 Y = np.random.normal(size=(D, T)) \ + 1j * np.random.normal(size=(D, T)) Y = tf.convert_to_tensor(Y[None]) power = tf.reduce_mean(tf.real(Y)**2 + tf.imag(Y)**2, axis=1) inv_power = tf.reciprocal(power) step_enhanced = tf_wpe.wpe_step(Y, inv_power, taps=K, delay=D) recursive_enhanced = tf_wpe.recursive_wpe( tf.transpose(Y, (2, 0, 1)), tf.transpose(power), 1., taps=K, delay=D, only_use_final_filters=True) recursive_enhanced = tf.transpose(recursive_enhanced, (1, 2, 0)) recursive_enhanced, step_enhanced = sess.run( [recursive_enhanced, step_enhanced]) np.testing.assert_allclose(recursive_enhanced[..., -200:], step_enhanced[..., -200:], atol=0.01, rtol=0.2)
def test_wpe_step(self): with self.test_session() as sess: Y = tf.convert_to_tensor(self.Y[None]) enhanced, inv_power = tf_wpe.single_frequency_wpe(Y[0], iterations=3) step_enhanced = tf_wpe.wpe_step(Y, inv_power[None]) enhanced, step_enhanced = sess.run([enhanced, step_enhanced]) np.testing.assert_allclose(enhanced, step_enhanced[0])