def func(tensor): sample_rate = 44100 center_freq = 300. gain = 1. q = 0.707 return F.equalizer_biquad(tensor, sample_rate, center_freq, gain, q)
def test_equalizer(self): """ Test biquad peaking equalizer filter, compare to SoX implementation """ CENTER_FREQ = 300 Q = 0.707 GAIN = 1 noise_filepath = os.path.join(self.test_dirpath, "assets", "whitenoise.wav") E = torchaudio.sox_effects.SoxEffectsChain() E.set_input_file(noise_filepath) E.append_effect_to_chain("equalizer", [CENTER_FREQ, Q, GAIN]) sox_output_waveform, sr = E.sox_build_flow_effects() waveform, sample_rate = torchaudio.load(noise_filepath, normalization=True) output_waveform = F.equalizer_biquad(waveform, sample_rate, CENTER_FREQ, GAIN, Q) torch.testing.assert_allclose(output_waveform, sox_output_waveform, atol=1e-4, rtol=1e-5)
def test_equalizer(self): center_freq = 300 q = 0.707 gain = 1 sample_rate = 8000 data, path = self.get_whitenoise(sample_rate) result = F.equalizer_biquad(data, sample_rate, center_freq, gain, q) self.assert_sox_effect(result, path, ['equalizer', center_freq, q, gain])
def test_equalizer(self): """ Test biquad peaking equalizer filter, compare to SoX implementation """ center_freq = 300 q = 0.707 gain = 1 noise_filepath = common_utils.get_asset_path('whitenoise.wav') E = torchaudio.sox_effects.SoxEffectsChain() E.set_input_file(noise_filepath) E.append_effect_to_chain("equalizer", [center_freq, q, gain]) sox_output_waveform, sr = E.sox_build_flow_effects() waveform, sample_rate = torchaudio.load(noise_filepath, normalization=True) output_waveform = F.equalizer_biquad(waveform, sample_rate, center_freq, gain, q) self.assertEqual(output_waveform, sox_output_waveform, atol=1e-4, rtol=1e-5)
def test_equalizer(self): """ Test biquad peaking equalizer filter, compare to SoX implementation """ center_freq = 300 q = 0.707 gain = 1 E = torchaudio.sox_effects.SoxEffectsChain() E.set_input_file(self.noise_filepath) E.append_effect_to_chain("equalizer", [center_freq, q, gain]) sox_output_waveform, sr = E.sox_build_flow_effects() output_waveform = F.equalizer_biquad(self.noise_waveform, self.NOISE_SAMPLE_RATE, center_freq, gain, q) self.assertEqual(output_waveform, sox_output_waveform, atol=1e-4, rtol=1e-5)