예제 #1
0
    def test_indivisible_rates_raises_error_compute_af(self, sample_rate,
                                                       audio_len_sec):
        audio_sin = gen_np_sinusoid(self.frequency, self.amp, sample_rate,
                                    audio_len_sec)

        with self.assertRaises(ValueError):
            ddsp_metrics.compute_audio_features(audio_sin,
                                                sample_rate=sample_rate,
                                                frame_rate=self.frame_rate)
예제 #2
0
 def gen_batch_of_features(self, batch_of_audio):
     batch_size = batch_of_audio.shape[0]
     audio = batch_of_audio[0]
     feats = ddsp_metrics.compute_audio_features(
         audio, sample_rate=self.sample_rate, frame_rate=self.frame_rate)
     for k, v in feats.items():
         feats[k] = np.tile(v[np.newaxis, :], [batch_size, 1])
     return feats
예제 #3
0
    def test_correct_shape_compute_af_at_sample_rate(self, sample_rate,
                                                     audio_len_sec):
        audio_sin = gen_np_sinusoid(self.frequency, self.amp, sample_rate,
                                    audio_len_sec)
        audio_features = ddsp_metrics.compute_audio_features(
            audio_sin, sample_rate=sample_rate, frame_rate=self.frame_rate)

        expected_f0_and_loudness_length = int(audio_len_sec * self.frame_rate)
        self.validate_output_shapes(
            audio_features, {
                'audio': audio_len_sec * sample_rate,
                'f0_hz': expected_f0_and_loudness_length,
                'f0_confidence': expected_f0_and_loudness_length,
                'loudness_db': expected_f0_and_loudness_length,
            })