Example #1
0
    def test_output_is_correct(self):
        processor = processors.Add(name='add')
        x = tf.zeros((2, 3), dtype=tf.float32) + 1.0
        y = tf.zeros((2, 3), dtype=tf.float32) + 2.0

        output = processor(x, y)

        expected = np.zeros((2, 3), dtype=np.float32) + 3.0
        self.assertAllEqual(expected, output)
Example #2
0
    def test_output_is_correct(self):
        processor = processors.Add(name='add')
        x = tf.zeros((2, 3), dtype=tf.float32) + 1.0
        y = tf.zeros((2, 3), dtype=tf.float32) + 2.0
        output = processor(x, y)

        with self.cached_session() as sess:
            actual = sess.run(output)

        expected = np.zeros((2, 3), dtype=np.float32) + 3.0

        self.assertAllEqual(expected, actual)
Example #3
0
    def setUp(self):
        """Create some dummy input data for the chain."""
        super().setUp()
        # Create inputs.
        self.n_batch = 4
        self.n_frames = 1000
        self.n_time = 64000
        rand_signal = lambda ch: np.random.randn(self.n_batch, self.n_frames,
                                                 ch)
        self.nn_outputs = {
            'amps': rand_signal(1),
            'harmonic_distribution': rand_signal(99),
            'magnitudes': rand_signal(256),
            'f0_hz': 200 + rand_signal(1),
            'target_audio': np.random.randn(self.n_batch, self.n_time)
        }

        # Create Processors.
        harmonic = synths.Harmonic(name='harmonic')
        noise = synths.FilteredNoise(name='noise')
        add = processors.Add(name='add')
        reverb = effects.Reverb(trainable=True, name='reverb')

        # Create DAG for testing.
        self.dag = [
            (harmonic, ['amps', 'harmonic_distribution', 'f0_hz']),
            (noise, ['magnitudes']),
            (add, ['noise/signal', 'harmonic/signal']),
            (reverb, ['add/signal']),
        ]
        self.expected_outputs = [
            'amps',
            'harmonic_distribution',
            'magnitudes',
            'f0_hz',
            'target_audio',
            'harmonic/signal',
            'harmonic/controls/amplitudes',
            'harmonic/controls/harmonic_distribution',
            'harmonic/controls/f0_hz',
            'noise/signal',
            'noise/controls/magnitudes',
            'add/signal',
            'reverb/signal',
            'reverb/controls/ir',
            'out/signal',
        ]