Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,27 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from voicefixer import VoiceFixer
|
| 3 |
import os
|
| 4 |
import torch
|
| 5 |
|
| 6 |
-
# --- 1. Setup Logic ---
|
| 7 |
-
|
| 8 |
-
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
| 15 |
|
| 16 |
def fix_audio_ts(audio_path):
|
| 17 |
if audio_path is None:
|
| 18 |
return None
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
output_file = "ts_studio_enhanced.wav"
|
| 21 |
|
| 22 |
# Mode 0: Cleaning + Restoration
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
import os
|
| 3 |
import torch
|
| 4 |
|
| 5 |
+
# --- 1. Setup Logic (Lazy Loading) ---
|
| 6 |
+
# Hum model ko globally load nahi karenge taaki app turant start ho jaye
|
| 7 |
+
vf_model = None
|
| 8 |
|
| 9 |
+
def get_model():
|
| 10 |
+
global vf_model
|
| 11 |
+
if vf_model is None:
|
| 12 |
+
print("Loading VoiceFixer Model...")
|
| 13 |
+
from voicefixer import VoiceFixer
|
| 14 |
+
vf_model = VoiceFixer()
|
| 15 |
+
return vf_model
|
| 16 |
|
| 17 |
def fix_audio_ts(audio_path):
|
| 18 |
if audio_path is None:
|
| 19 |
return None
|
| 20 |
|
| 21 |
+
# Model load karo (agar pehle se loaded nahi hai)
|
| 22 |
+
vf = get_model()
|
| 23 |
+
|
| 24 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 25 |
output_file = "ts_studio_enhanced.wav"
|
| 26 |
|
| 27 |
# Mode 0: Cleaning + Restoration
|