Ejemplo n.º 1
0
    def test_output_shape_is_correct(self):
        synthesizer = synths.Additive(n_samples=64000,
                                      sample_rate=16000,
                                      scale_fn=None,
                                      normalize_below_nyquist=True)
        batch_size = 3
        num_frames = 1000
        amp = tf.zeros((batch_size, num_frames, 1), dtype=tf.float32) + 1.0
        harmonic_distribution = tf.zeros(
            (batch_size, num_frames, 16), dtype=tf.float32) + 1.0 / 16
        f0_hz = tf.zeros((batch_size, num_frames, 1), dtype=tf.float32) + 16000

        output = synthesizer(amp, harmonic_distribution, f0_hz)

        self.assertAllEqual([batch_size, 64000], output.shape.as_list())
Ejemplo n.º 2
0
    def setUp(self):
        """Create some dummy input data for the chain."""
        super(ProcessorGroupTest, self).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.
        additive = synths.Additive(name='additive')
        noise = synths.FilteredNoise(name='noise')
        add = processors.Add(name='add')
        reverb = effects.Reverb(trainable=True, name='reverb')

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