Spaces:
Running
on
Zero
Running
on
Zero
roychao19477
commited on
Commit
·
718c79c
1
Parent(s):
20cc48b
Fix spectrogram issue
Browse files
app.py
CHANGED
@@ -60,7 +60,8 @@ def enhance(filepath, model_name):
|
|
60 |
model.eval()
|
61 |
with torch.no_grad():
|
62 |
# load & resample
|
63 |
-
|
|
|
64 |
if orig_sr != 16000:
|
65 |
wav = librosa.resample(wav, orig_sr=orig_sr, target_sr=16000)
|
66 |
x = torch.from_numpy(wav).float().to(device)
|
@@ -102,7 +103,7 @@ def enhance(filepath, model_name):
|
|
102 |
fig, axs = plt.subplots(1, 2, figsize=(16, 4))
|
103 |
|
104 |
# noisy
|
105 |
-
D_noisy = librosa.stft(
|
106 |
S_noisy = librosa.amplitude_to_db(np.abs(D_noisy), ref=np.max)
|
107 |
librosa.display.specshow(S_noisy, sr=orig_sr, hop_length=512, x_axis="time", y_axis="hz", ax=axs[0], vmax=0)
|
108 |
axs[0].set_title("Noisy Spectrogram")
|
|
|
60 |
model.eval()
|
61 |
with torch.no_grad():
|
62 |
# load & resample
|
63 |
+
noisy_wav, orig_sr = librosa.load(filepath, sr=None)
|
64 |
+
wav = noisy_wav
|
65 |
if orig_sr != 16000:
|
66 |
wav = librosa.resample(wav, orig_sr=orig_sr, target_sr=16000)
|
67 |
x = torch.from_numpy(wav).float().to(device)
|
|
|
103 |
fig, axs = plt.subplots(1, 2, figsize=(16, 4))
|
104 |
|
105 |
# noisy
|
106 |
+
D_noisy = librosa.stft(noisy_wav, n_fft=1024, hop_length=512)
|
107 |
S_noisy = librosa.amplitude_to_db(np.abs(D_noisy), ref=np.max)
|
108 |
librosa.display.specshow(S_noisy, sr=orig_sr, hop_length=512, x_axis="time", y_axis="hz", ax=axs[0], vmax=0)
|
109 |
axs[0].set_title("Noisy Spectrogram")
|