Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
8a4f7ba
1
Parent(s):
026f6aa
musicgen why not
Browse files
app.py
CHANGED
@@ -416,6 +416,17 @@ def extend_with_musicgen_api(audio_path, prompt_duration, musicgen_model, output
|
|
416 |
|
417 |
except Exception as e:
|
418 |
return None, f"❌ MusicGen API error: {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
"""Calculate optimal bar count for given BPM to fit in ~10s"""
|
420 |
seconds_per_beat = 60.0 / bpm
|
421 |
seconds_per_bar = seconds_per_beat * 4
|
|
|
416 |
|
417 |
except Exception as e:
|
418 |
return None, f"❌ MusicGen API error: {str(e)}"
|
419 |
+
|
420 |
+
def calculate_optimal_bars(bpm):
|
421 |
+
"""Calculate optimal bar count for given BPM to fit in ~10s"""
|
422 |
+
seconds_per_beat = 60.0 / bpm
|
423 |
+
seconds_per_bar = seconds_per_beat * 4
|
424 |
+
max_duration = 10.0
|
425 |
+
|
426 |
+
for bars in [8, 4, 2, 1]:
|
427 |
+
if seconds_per_bar * bars <= max_duration:
|
428 |
+
return bars
|
429 |
+
return 1
|
430 |
"""Calculate optimal bar count for given BPM to fit in ~10s"""
|
431 |
seconds_per_beat = 60.0 / bpm
|
432 |
seconds_per_bar = seconds_per_beat * 4
|