roychao19477 commited on
Commit
9d66cc0
·
1 Parent(s): 3af0ebe
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -50,7 +50,7 @@ def enhance(filepath):
50
  # load & resample
51
  wav, orig_sr = librosa.load(filepath, sr=None)
52
  if orig_sr != 16000:
53
- wav = librosa.resample(wav, orig_sr, 16000)
54
  x = torch.from_numpy(wav).float().to(device)
55
  norm = torch.sqrt(len(x)/torch.sum(x**2))
56
  x = (x * norm).unsqueeze(0)
@@ -63,7 +63,7 @@ def enhance(filepath):
63
 
64
  # back to original rate
65
  if orig_sr != 16000:
66
- out = librosa.resample(out, 16000, orig_sr)
67
 
68
  # write file
69
  sf.write("enhanced.wav", out, orig_sr)
 
50
  # load & resample
51
  wav, orig_sr = librosa.load(filepath, sr=None)
52
  if orig_sr != 16000:
53
+ wav = librosa.resample(wav, orig_sr=orig_sr, target_sr=16000)
54
  x = torch.from_numpy(wav).float().to(device)
55
  norm = torch.sqrt(len(x)/torch.sum(x**2))
56
  x = (x * norm).unsqueeze(0)
 
63
 
64
  # back to original rate
65
  if orig_sr != 16000:
66
+ out = librosa.resample(out, orig_sr=16000, target_sr=orig_sr)
67
 
68
  # write file
69
  sf.write("enhanced.wav", out, orig_sr)