mirror of https://github.com/coqui-ai/TTS.git
refactor(audio.processor): use find_endpoint from numpy_transforms
This commit is contained in:
parent
5232bf9e36
commit
842a632cd5
|
@ -14,6 +14,7 @@ from TTS.utils.audio.numpy_transforms import (
|
||||||
compute_f0,
|
compute_f0,
|
||||||
db_to_amp,
|
db_to_amp,
|
||||||
deemphasis,
|
deemphasis,
|
||||||
|
find_endpoint,
|
||||||
griffin_lim,
|
griffin_lim,
|
||||||
mel_to_spec,
|
mel_to_spec,
|
||||||
millisec_to_length,
|
millisec_to_length,
|
||||||
|
@ -527,13 +528,14 @@ class AudioProcessor(object):
|
||||||
Returns:
|
Returns:
|
||||||
int: Last point without silence.
|
int: Last point without silence.
|
||||||
"""
|
"""
|
||||||
window_length = int(self.sample_rate * min_silence_sec)
|
return find_endpoint(
|
||||||
hop_length = int(window_length / 4)
|
wav=wav,
|
||||||
threshold = db_to_amp(x=-self.trim_db, gain=self.spec_gain, base=self.base)
|
trim_db=self.trim_db,
|
||||||
for x in range(hop_length, len(wav) - window_length, hop_length):
|
sample_rate=self.sample_rate,
|
||||||
if np.max(wav[x : x + window_length]) < threshold:
|
min_silence_sec=min_silence_sec,
|
||||||
return x + hop_length
|
gain=self.spec_gain,
|
||||||
return len(wav)
|
base=self.base,
|
||||||
|
)
|
||||||
|
|
||||||
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"""
|
||||||
|
|
Loading…
Reference in New Issue