tee342 commited on
Commit
bf7d84f
·
verified ·
1 Parent(s): ef2567b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -9
app.py CHANGED
@@ -97,15 +97,24 @@ def apply_vocal_isolation(audio_path):
97
 
98
  # === Preset Loader ===
99
  def load_presets():
100
- preset_files = [f for f in os.listdir("presets") if f.endswith(".json")]
101
- presets = {}
102
- for f in preset_files:
103
- with open(os.path.join("presets", f)) as infile:
104
- data = json.load(infile)
105
- presets[data["name"]] = data["effects"]
106
- return presets
107
-
108
- preset_choices = load_presets()
 
 
 
 
 
 
 
 
 
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):