Spaces:
Runtime error
Runtime error
Hendrik Schroeter
commited on
Print file properties
Browse files
app.py
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
|
|
| 1 |
import tempfile
|
| 2 |
-
from df.utils import resample
|
| 3 |
|
| 4 |
import gradio
|
| 5 |
import gradio.inputs
|
| 6 |
import gradio.outputs
|
| 7 |
-
import matplotlib.pyplot as plt
|
| 8 |
import markdown
|
|
|
|
| 9 |
import numpy as np
|
| 10 |
import torch
|
| 11 |
from df import config
|
| 12 |
-
import math
|
| 13 |
from df.enhance import enhance, init_df, load_audio, save_audio
|
|
|
|
| 14 |
|
| 15 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 16 |
model, df, _ = init_df()
|
|
@@ -60,14 +60,24 @@ def mix_and_denoise(speech_rec, speech_upl, noise, snr):
|
|
| 60 |
noise = "samples/dkitchen.wav"
|
| 61 |
sp_kwargs = {}
|
| 62 |
if speech_rec is None or "none" in speech_rec:
|
| 63 |
-
|
| 64 |
if speech_upl is not None and "none" not in speech_upl:
|
| 65 |
print("using speech_upl")
|
| 66 |
-
|
| 67 |
else:
|
| 68 |
-
|
| 69 |
sp_kwargs = {"frame_offset": 4800}
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
print(f"Loaded speech with shape {speech.shape}")
|
| 72 |
noise, _ = load_audio(noise, sr)
|
| 73 |
if meta.sample_rate != sr:
|
|
|
|
| 1 |
+
import math
|
| 2 |
import tempfile
|
|
|
|
| 3 |
|
| 4 |
import gradio
|
| 5 |
import gradio.inputs
|
| 6 |
import gradio.outputs
|
|
|
|
| 7 |
import markdown
|
| 8 |
+
import matplotlib.pyplot as plt
|
| 9 |
import numpy as np
|
| 10 |
import torch
|
| 11 |
from df import config
|
|
|
|
| 12 |
from df.enhance import enhance, init_df, load_audio, save_audio
|
| 13 |
+
from df.utils import resample
|
| 14 |
|
| 15 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 16 |
model, df, _ = init_df()
|
|
|
|
| 60 |
noise = "samples/dkitchen.wav"
|
| 61 |
sp_kwargs = {}
|
| 62 |
if speech_rec is None or "none" in speech_rec:
|
| 63 |
+
speech_file = "samples/p232_013_clean.wav"
|
| 64 |
if speech_upl is not None and "none" not in speech_upl:
|
| 65 |
print("using speech_upl")
|
| 66 |
+
speech_file = speech_upl
|
| 67 |
else:
|
| 68 |
+
speech_file = speech_rec
|
| 69 |
sp_kwargs = {"frame_offset": 4800}
|
| 70 |
+
try:
|
| 71 |
+
speech, meta = load_audio(speech_file, sr, **sp_kwargs)
|
| 72 |
+
except RuntimeError as e:
|
| 73 |
+
print("Could not load audio:", e)
|
| 74 |
+
import os
|
| 75 |
+
|
| 76 |
+
print(os.path.getsize(speech_file))
|
| 77 |
+
print(os.path.getmtime(speech_file))
|
| 78 |
+
print(os.path.getctime(speech_file))
|
| 79 |
+
raise e
|
| 80 |
+
|
| 81 |
print(f"Loaded speech with shape {speech.shape}")
|
| 82 |
noise, _ = load_audio(noise, sr)
|
| 83 |
if meta.sample_rate != sr:
|