Esempio n. 1
0
    def test_output_shape_is_correct(self):
        synthesizer = synths.FilteredNoise(n_samples=16000)
        filter_bank_magnitudes = tf.zeros(
            (3, 16000, 100), dtype=tf.float32) + 3.0
        output = synthesizer(filter_bank_magnitudes)

        self.assertAllEqual([3, 16000], output.shape.as_list())
Esempio n. 2
0
    def __init__(self,
                 trainable=False,
                 reverb_length=48000,
                 window_size=257,
                 n_frames=1000,
                 n_filter_banks=16,
                 scale_fn=core.exp_sigmoid,
                 initial_bias=-3.0,
                 add_dry=True,
                 name='filtered_noise_reverb'):
        """Constructor.

    Args:
      trainable: Learn the impulse_response as a single variable for the entire
        dataset.
      reverb_length: Length of the impulse response.
      window_size: Window size for filtered noise synthesizer.
      n_frames: Time resolution of magnitudes coefficients. Only used if
        trainable=True.
      n_filter_banks: Frequency resolution of magnitudes coefficients. Only used
        if trainable=True.
      scale_fn: Function by which to scale the magnitudes.
      initial_bias: Shift the filtered noise synth inputs by this amount
        (before scale_fn) to start generating noise in a resonable range when
        given magnitudes centered around 0.
      add_dry: Add dry signal to reverberated signal on output.
      name: Name of processor module.
    """
        super().__init__(name=name, add_dry=add_dry, trainable=trainable)
        self._n_frames = n_frames
        self._n_filter_banks = n_filter_banks
        self._synth = synths.FilteredNoise(n_samples=reverb_length,
                                           window_size=window_size,
                                           scale_fn=scale_fn,
                                           initial_bias=initial_bias)
Esempio n. 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',
        ]