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)
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, })