Spaces:
Running
on
Zero
Running
on
Zero
Commit
Β·
a9d7ba1
1
Parent(s):
7096e70
melodyflow fixes
Browse files
app.py
CHANGED
|
@@ -145,10 +145,24 @@ def transform_with_melodyflow_api(audio_path, variation, custom_prompt="", solve
|
|
| 145 |
if audio_path is None:
|
| 146 |
return None, "β No audio file provided"
|
| 147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
try:
|
| 149 |
# Initialize client for Facebook MelodyFlow space
|
| 150 |
client = Client("facebook/MelodyFlow")
|
| 151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
# Determine the prompt to use
|
| 153 |
if custom_prompt.strip():
|
| 154 |
prompt_text = custom_prompt.strip()
|
|
@@ -157,16 +171,6 @@ def transform_with_melodyflow_api(audio_path, variation, custom_prompt="", solve
|
|
| 157 |
prompt_text = VARIATION_PROMPTS.get(variation, f"transform this audio to {variation} style")
|
| 158 |
status_msg = f"β
Transformed with {variation} style (flowstep: {flowstep}, {effective_steps} steps)"
|
| 159 |
|
| 160 |
-
# Set steps based on solver and the fact we're doing editing
|
| 161 |
-
# Facebook's space automatically reduces steps for editing:
|
| 162 |
-
# EULER: divides by 5, MIDPOINT: divides by 2
|
| 163 |
-
if solver == "midpoint":
|
| 164 |
-
base_steps = 128
|
| 165 |
-
effective_steps = base_steps // 2 # 64 effective steps
|
| 166 |
-
else: # euler
|
| 167 |
-
base_steps = 125
|
| 168 |
-
effective_steps = base_steps // 5 # 25 effective steps
|
| 169 |
-
|
| 170 |
# Call the MelodyFlow API with the base steps (it will auto-reduce)
|
| 171 |
result = client.predict(
|
| 172 |
model="facebook/melodyflow-t24-30secs",
|
|
|
|
| 145 |
if audio_path is None:
|
| 146 |
return None, "β No audio file provided"
|
| 147 |
|
| 148 |
+
# Initialize variables first to avoid scope issues
|
| 149 |
+
base_steps = 125
|
| 150 |
+
effective_steps = 25
|
| 151 |
+
|
| 152 |
try:
|
| 153 |
# Initialize client for Facebook MelodyFlow space
|
| 154 |
client = Client("facebook/MelodyFlow")
|
| 155 |
|
| 156 |
+
# Set steps based on solver and the fact we're doing editing
|
| 157 |
+
# Facebook's space automatically reduces steps for editing:
|
| 158 |
+
# EULER: divides by 5, MIDPOINT: divides by 2
|
| 159 |
+
if solver == "midpoint":
|
| 160 |
+
base_steps = 128
|
| 161 |
+
effective_steps = 64 # 128 // 2
|
| 162 |
+
else: # euler (default)
|
| 163 |
+
base_steps = 125
|
| 164 |
+
effective_steps = 25 # 125 // 5
|
| 165 |
+
|
| 166 |
# Determine the prompt to use
|
| 167 |
if custom_prompt.strip():
|
| 168 |
prompt_text = custom_prompt.strip()
|
|
|
|
| 171 |
prompt_text = VARIATION_PROMPTS.get(variation, f"transform this audio to {variation} style")
|
| 172 |
status_msg = f"β
Transformed with {variation} style (flowstep: {flowstep}, {effective_steps} steps)"
|
| 173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
# Call the MelodyFlow API with the base steps (it will auto-reduce)
|
| 175 |
result = client.predict(
|
| 176 |
model="facebook/melodyflow-t24-30secs",
|