mirror of https://github.com/coqui-ai/TTS.git
Optional silence trimming during inference and find_endpoint() fix (#898)
* Set find_endpoint db threshold in config.json * Optional silence trimming during inference * Make trim_db value negative
This commit is contained in:
parent
7293abada2
commit
37eaefc085
|
@ -674,7 +674,7 @@ class AudioProcessor(object):
|
|||
return f0
|
||||
|
||||
### Audio Processing ###
|
||||
def find_endpoint(self, wav: np.ndarray, threshold_db=-40, min_silence_sec=0.8) -> int:
|
||||
def find_endpoint(self, wav: np.ndarray, min_silence_sec=0.8) -> int:
|
||||
"""Find the last point without silence at the end of a audio signal.
|
||||
|
||||
Args:
|
||||
|
@ -687,7 +687,7 @@ class AudioProcessor(object):
|
|||
"""
|
||||
window_length = int(self.sample_rate * min_silence_sec)
|
||||
hop_length = int(window_length / 4)
|
||||
threshold = self._db_to_amp(threshold_db)
|
||||
threshold = self._db_to_amp(-self.trim_db)
|
||||
for x in range(hop_length, len(wav) - window_length, hop_length):
|
||||
if np.max(wav[x : x + window_length]) < threshold:
|
||||
return x + hop_length
|
||||
|
|
|
@ -265,7 +265,8 @@ class Synthesizer(object):
|
|||
waveform = waveform.squeeze()
|
||||
|
||||
# trim silence
|
||||
waveform = trim_silence(waveform, self.ap)
|
||||
if self.tts_config.audio["do_trim_silence"] is True:
|
||||
waveform = trim_silence(waveform, self.ap)
|
||||
|
||||
wavs += list(waveform)
|
||||
wavs += [0] * 10000
|
||||
|
|
Loading…
Reference in New Issue