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

Fix spectrogram issue

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -107,16 +107,16 @@ def enhance(filepath, model_name):
107
  fig, axs = plt.subplots(1, 2, figsize=(16, 4))
108
 
109
  # noisy
110
- D_noisy = librosa.stft(noisy_wav, n_fft=1024, hop_length=512)
111
  S_noisy = librosa.amplitude_to_db(np.abs(D_noisy), ref=np.max)
112
- librosa.display.specshow(S_noisy, sr=orig_sr, hop_length=512, x_axis="time", y_axis="hz", ax=axs[0], vmax=0)
113
  axs[0].set_title("Noisy Spectrogram")
114
 
115
  # enhanced
116
- D_clean = librosa.stft(out_wav, n_fft=1024, hop_length=512)
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=512, 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)
120
  axs[1].set_title("Enhanced Spectrogram")
121
 
122
  plt.tight_layout()
 
107
  fig, axs = plt.subplots(1, 2, figsize=(16, 4))
108
 
109
  # noisy
110
+ D_noisy = librosa.stft(noisy_wav, n_fft=512, hop_length=256)
111
  S_noisy = librosa.amplitude_to_db(np.abs(D_noisy), ref=np.max)
112
+ librosa.display.specshow(S_noisy, sr=orig_sr, hop_length=256, x_axis="time", y_axis="hz", ax=axs[0], vmax=0)
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)
120
  axs[1].set_title("Enhanced Spectrogram")
121
 
122
  plt.tight_layout()