Fix: prevent exponential growth in augmentation

#2
by KyungsuKim - opened
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -41,16 +41,18 @@ class LatentGranularSynthesis:
41
  y = librosa.util.normalize(y)
42
 
43
  if aug_checkbox:
 
44
  # Apply volume augmentation
45
  for vol in self.vol_aug:
46
  y_vol = y * vol
47
- y = np.hstack((y, y_vol))
48
 
49
  # Apply pitch augmentation
50
  for pitch in self.pitch_aug:
51
  y_pitch = librosa.effects.pitch_shift(y, sr=sr, n_steps=pitch)
52
- y = np.hstack((y, y_pitch))
53
-
 
54
  # Encode audio
55
  latent = self.encdec.encode(y, max_waveform_length=44100*1).cpu()
56
  self.codedb = torch.cat((self.codedb, latent), dim=-1)
 
41
  y = librosa.util.normalize(y)
42
 
43
  if aug_checkbox:
44
+ y_augmented = y
45
  # Apply volume augmentation
46
  for vol in self.vol_aug:
47
  y_vol = y * vol
48
+ y_augmented = np.hstack((y_augmented, y_vol))
49
 
50
  # Apply pitch augmentation
51
  for pitch in self.pitch_aug:
52
  y_pitch = librosa.effects.pitch_shift(y, sr=sr, n_steps=pitch)
53
+ y_augmented = np.hstack((y_augmented, y_pitch))
54
+ y = y_augmented
55
+
56
  # Encode audio
57
  latent = self.encdec.encode(y, max_waveform_length=44100*1).cpu()
58
  self.codedb = torch.cat((self.codedb, latent), dim=-1)