roychao19477 commited on
Commit
411fe00
·
1 Parent(s): caa9ec7

Fix spectrogram issue

Browse files
Files changed (1) hide show
  1. app.py +1 -3
app.py CHANGED
@@ -89,7 +89,6 @@ def enhance(filepath, model_name):
89
 
90
  out = torch.cat(enhanced_chunks)[:len(x)].cpu().numpy() # trim padding
91
 
92
- out_wav = out.copy()
93
  # back to original rate
94
  if orig_sr != 16000:
95
  out = librosa.resample(out, orig_sr=16000, target_sr=orig_sr)
@@ -98,7 +97,6 @@ def enhance(filepath, model_name):
98
  peak = np.max(np.abs(out))
99
  if peak > 0.05:
100
  out = out / peak * 0.85
101
- out_wav = out_wav / peak * 0.85
102
 
103
  # write file
104
  sf.write("enhanced.wav", out, orig_sr)
@@ -113,7 +111,7 @@ def enhance(filepath, model_name):
113
  axs[0].set_title("Noisy Spectrogram")
114
 
115
  # enhanced
116
- D_clean = librosa.stft(out_wav, n_fft=512, hop_length=256)
117
  S_clean = librosa.amplitude_to_db(np.abs(D_clean), ref=np.max)
118
  librosa.display.specshow(S_clean, sr=orig_sr, hop_length=256, x_axis="time", y_axis="hz", ax=axs[1], vmax=0)
119
  #librosa.display.specshow(S_clean, sr=16000, hop_length=512, x_axis="time", y_axis="hz", ax=axs[1], vmax=0)
 
89
 
90
  out = torch.cat(enhanced_chunks)[:len(x)].cpu().numpy() # trim padding
91
 
 
92
  # back to original rate
93
  if orig_sr != 16000:
94
  out = librosa.resample(out, orig_sr=16000, target_sr=orig_sr)
 
97
  peak = np.max(np.abs(out))
98
  if peak > 0.05:
99
  out = out / peak * 0.85
 
100
 
101
  # write file
102
  sf.write("enhanced.wav", out, orig_sr)
 
111
  axs[0].set_title("Noisy Spectrogram")
112
 
113
  # enhanced
114
+ D_clean = librosa.stft(out, n_fft=512, hop_length=256)
115
  S_clean = librosa.amplitude_to_db(np.abs(D_clean), ref=np.max)
116
  librosa.display.specshow(S_clean, sr=orig_sr, hop_length=256, x_axis="time", y_axis="hz", ax=axs[1], vmax=0)
117
  #librosa.display.specshow(S_clean, sr=16000, hop_length=512, x_axis="time", y_axis="hz", ax=axs[1], vmax=0)