Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -97,15 +97,24 @@ def apply_vocal_isolation(audio_path):
|
|
97 |
|
98 |
# === Preset Loader ===
|
99 |
def load_presets():
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
# === Main Processing Function ===
|
111 |
def process_audio(audio_file, selected_effects, isolate_vocals, preset_name):
|
|
|
97 |
|
98 |
# === Preset Loader ===
|
99 |
def load_presets():
|
100 |
+
try:
|
101 |
+
preset_files = [f for f in os.listdir("presets") if f.endswith(".json")]
|
102 |
+
presets = {}
|
103 |
+
for f in preset_files:
|
104 |
+
path = os.path.join("presets", f)
|
105 |
+
try:
|
106 |
+
with open(path, "r") as infile:
|
107 |
+
data = json.load(infile)
|
108 |
+
if "name" in data and "effects" in data:
|
109 |
+
presets[data["name"]] = data["effects"]
|
110 |
+
else:
|
111 |
+
print(f"Invalid format in {f}")
|
112 |
+
except json.JSONDecodeError:
|
113 |
+
print(f"Failed to parse {f} — invalid JSON")
|
114 |
+
return presets
|
115 |
+
except FileNotFoundError:
|
116 |
+
print("Presets folder not found")
|
117 |
+
return {}
|
118 |
|
119 |
# === Main Processing Function ===
|
120 |
def process_audio(audio_file, selected_effects, isolate_vocals, preset_name):
|