Hendrik Schroeter commited on
Commit
a299dfc
1 Parent(s): bd0f589

add clipping detection

Browse files
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -44,6 +44,10 @@ def mix_at_snr(clean, noise, snr, eps=1e-10):
44
  noise = noise / K
45
  mixture = clean + noise
46
  assert torch.isfinite(mixture).all()
 
 
 
 
47
  return clean, noise, mixture
48
 
49
 
 
44
  noise = noise / K
45
  mixture = clean + noise
46
  assert torch.isfinite(mixture).all()
47
+ max_m = mixture.abs().max()
48
+ if max_m > 1:
49
+ print(f"Clipping detected during mixing. Reducing gain by {1/max_m}")
50
+ clean, noise, mixture = clean / max_m, noise / max_m, mixture / max_m
51
  return clean, noise, mixture
52
 
53