Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,22 +3,25 @@ from df.enhance import enhance, init_df, load_audio, save_audio
|
|
| 3 |
import torch
|
| 4 |
import tempfile
|
| 5 |
|
| 6 |
-
# Model
|
| 7 |
model, df_state, _ = init_df()
|
| 8 |
|
| 9 |
def clean_audio(audio_path):
|
| 10 |
if audio_path is None:
|
| 11 |
return None
|
| 12 |
try:
|
|
|
|
| 13 |
audio, _ = load_audio(audio_path, sr=df_state.sr())
|
|
|
|
| 14 |
enhanced_audio = enhance(model, df_state, audio)
|
|
|
|
| 15 |
output_file = tempfile.NamedTemporaryFile(suffix=".wav", delete=False).name
|
| 16 |
save_audio(output_file, enhanced_audio, df_state.sr())
|
| 17 |
return output_file
|
| 18 |
except Exception as e:
|
| 19 |
-
print(f"Error: {e}")
|
| 20 |
return None
|
| 21 |
|
|
|
|
| 22 |
iface = gr.Interface(
|
| 23 |
fn=clean_audio,
|
| 24 |
inputs=gr.Audio(type="filepath", label="Upload Audio"),
|
|
|
|
| 3 |
import torch
|
| 4 |
import tempfile
|
| 5 |
|
| 6 |
+
# Model ko initialize karein
|
| 7 |
model, df_state, _ = init_df()
|
| 8 |
|
| 9 |
def clean_audio(audio_path):
|
| 10 |
if audio_path is None:
|
| 11 |
return None
|
| 12 |
try:
|
| 13 |
+
# Audio load karein
|
| 14 |
audio, _ = load_audio(audio_path, sr=df_state.sr())
|
| 15 |
+
# Enhance (Clean) karein
|
| 16 |
enhanced_audio = enhance(model, df_state, audio)
|
| 17 |
+
# Save karein
|
| 18 |
output_file = tempfile.NamedTemporaryFile(suffix=".wav", delete=False).name
|
| 19 |
save_audio(output_file, enhanced_audio, df_state.sr())
|
| 20 |
return output_file
|
| 21 |
except Exception as e:
|
|
|
|
| 22 |
return None
|
| 23 |
|
| 24 |
+
# Interface
|
| 25 |
iface = gr.Interface(
|
| 26 |
fn=clean_audio,
|
| 27 |
inputs=gr.Audio(type="filepath", label="Upload Audio"),
|