Skip to content

Commit

Permalink
Fix for gaps augmentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tilmankamp committed Apr 24, 2020
1 parent 5123cd2 commit 5e63baf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion training/deepspeech_training/util/signal_augmentations.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ def apply(self, sample, clock):
n_gaps = pick_value_from_range(self.n_gaps, clock=clock)
for _ in range(n_gaps):
size = pick_value_from_range(self.size, clock=clock)
offset = max(0, random.randint(0, len(audio) - size - 1))
size = min(size, len(audio) // 10) # a gap should never exceed 10 percent of the audio
offset = random.randint(0, max(0, len(audio) - size - 1))
audio[offset:offset + size] = 0
sample.audio = audio

Expand Down

0 comments on commit 5e63baf

Please sign in to comment.