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:
George 2021-10-29 17:28:55 +01:00 committed by GitHub
parent 7293abada2
commit 37eaefc085
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -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

View File

@ -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