mirror of https://github.com/coqui-ai/TTS.git
refactor(audio.processor): use trim_silence from numpy_transforms
This commit is contained in:
parent
842a632cd5
commit
0a0e7a3bae
|
@ -22,6 +22,7 @@ from TTS.utils.audio.numpy_transforms import (
|
||||||
rms_volume_norm,
|
rms_volume_norm,
|
||||||
spec_to_mel,
|
spec_to_mel,
|
||||||
stft,
|
stft,
|
||||||
|
trim_silence,
|
||||||
)
|
)
|
||||||
|
|
||||||
# pylint: disable=too-many-public-methods
|
# pylint: disable=too-many-public-methods
|
||||||
|
@ -539,11 +540,13 @@ class AudioProcessor(object):
|
||||||
|
|
||||||
def trim_silence(self, wav):
|
def trim_silence(self, wav):
|
||||||
"""Trim silent parts with a threshold and 0.01 sec margin"""
|
"""Trim silent parts with a threshold and 0.01 sec margin"""
|
||||||
margin = int(self.sample_rate * 0.01)
|
return trim_silence(
|
||||||
wav = wav[margin:-margin]
|
wav=wav,
|
||||||
return librosa.effects.trim(wav, top_db=self.trim_db, frame_length=self.win_length, hop_length=self.hop_length)[
|
sample_rate=self.sample_rate,
|
||||||
0
|
trim_db=self.trim_db,
|
||||||
]
|
win_length=self.win_length,
|
||||||
|
hop_length=self.hop_length,
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def sound_norm(x: np.ndarray) -> np.ndarray:
|
def sound_norm(x: np.ndarray) -> np.ndarray:
|
||||||
|
|
Loading…
Reference in New Issue