Example #1
0
    def test_output_shape_is_correct(self):
        loss_obj = losses.PretrainedCREPEEmbeddingLoss()

        input_audio = tf.random.uniform((3, 16000), dtype=tf.float32)
        target_audio = tf.random.uniform((3, 16000), dtype=tf.float32)

        loss = loss_obj(input_audio, target_audio)

        self.assertListEqual([], loss.shape.as_list())
Example #2
0
    def test_output_shape_is_correct(self):
        loss_obj = losses.PretrainedCREPEEmbeddingLoss()

        input_audio = tf.ones((3, 16000), dtype=tf.float32)
        target_audio = tf.ones((3, 16000), dtype=tf.float32)

        loss = loss_obj(input_audio, target_audio)

        self.assertListEqual([], loss.shape.as_list())
        self.assertTrue(np.isfinite(loss))
Example #3
0
    def setUp(self):
        """Create some dummy input data for the chain."""
        super().setUp()

        # Create a network output dictionary.
        self.nn_outputs = {
            'audio': tf.ones((3, 8000), dtype=tf.float32),
            'audio_synth': tf.ones((3, 8000), dtype=tf.float32),
            'magnitudes': tf.ones((3, 200, 2), dtype=tf.float32),
            'f0_hz': 200 + tf.ones((3, 200, 1), dtype=tf.float32),
        }

        # Create Processors.
        spectral_loss = losses.SpectralLoss()
        crepe_loss = losses.PretrainedCREPEEmbeddingLoss(name='crepe_loss')

        # Create DAG for testing.
        self.dag = [
            (spectral_loss, ['audio', 'audio_synth']),
            (crepe_loss, ['audio', 'audio_synth']),
        ]
        self.expected_outputs = ['spectral_loss', 'crepe_loss']