refactor(audio.processor): use pre-/deemphasis from numpy_transforms

This commit is contained in:
Enno Hermann 2023-11-14 13:25:35 +01:00
parent f37cc4c028
commit 11e98d3dac
1 changed files with 4 additions and 6 deletions

View File

@ -13,9 +13,11 @@ from TTS.utils.audio.numpy_transforms import (
build_mel_basis, build_mel_basis,
compute_f0, compute_f0,
db_to_amp, db_to_amp,
deemphasis,
griffin_lim, griffin_lim,
mel_to_spec, mel_to_spec,
millisec_to_length, millisec_to_length,
preemphasis,
spec_to_mel, spec_to_mel,
stft, stft,
) )
@ -387,15 +389,11 @@ class AudioProcessor(object):
Returns: Returns:
np.ndarray: Decorrelated audio signal. np.ndarray: Decorrelated audio signal.
""" """
if self.preemphasis == 0: return preemphasis(x=x, coef=self.preemphasis)
raise RuntimeError(" [!] Preemphasis is set 0.0.")
return scipy.signal.lfilter([1, -self.preemphasis], [1], x)
def apply_inv_preemphasis(self, x: np.ndarray) -> np.ndarray: def apply_inv_preemphasis(self, x: np.ndarray) -> np.ndarray:
"""Reverse pre-emphasis.""" """Reverse pre-emphasis."""
if self.preemphasis == 0: return deemphasis(x=x, coef=self.preemphasis)
raise RuntimeError(" [!] Preemphasis is set 0.0.")
return scipy.signal.lfilter([1], [1, -self.preemphasis], x)
### SPECTROGRAMs ### ### SPECTROGRAMs ###
def spectrogram(self, y: np.ndarray) -> np.ndarray: def spectrogram(self, y: np.ndarray) -> np.ndarray: