Update app.py
Browse files
app.py
CHANGED
|
@@ -74,43 +74,39 @@ def check_vram_availability(required_gb=3.5):
|
|
| 74 |
return available_vram >= required_gb
|
| 75 |
|
| 76 |
# 4) GENRE PROMPT FUNCTIONS
|
| 77 |
-
def set_red_hot_chili_peppers_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 78 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("strong rhythmic steps" if bpm > 120 else "groovy rhythmic flow")
|
| 79 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 80 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 81 |
bass = f", {bass_style}" if bass_style != "none" else ", groovy basslines"
|
| 82 |
guitar = f", {guitar_style} guitar riffs" if guitar_style != "none" else ", syncopated guitar riffs"
|
| 83 |
-
|
| 84 |
-
return f"Funk rock{bass}{guitar}{drum}{synth}{vocal}, Red Hot Chili Peppers-inspired vibe with dynamic energy and funky breakdowns, {rhythm} at {bpm} BPM."
|
| 85 |
|
| 86 |
-
def set_nirvana_grunge_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 87 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("intense rhythmic steps" if bpm > 120 else "grungy rhythmic pulse")
|
| 88 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 89 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 90 |
bass = f", {bass_style}" if bass_style != "none" else ", melodic basslines"
|
| 91 |
guitar = f", {guitar_style} guitar riffs" if guitar_style != "none" else ", raw distorted guitar riffs"
|
| 92 |
-
|
| 93 |
-
return f"Grunge{bass}{guitar}{drum}{synth}{vocal}, Nirvana-inspired angst-filled sound with quiet-loud dynamics, {rhythm} at {bpm} BPM."
|
| 94 |
|
| 95 |
-
def set_pearl_jam_grunge_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 96 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("soulful rhythmic steps" if bpm > 120 else "driving rhythmic flow")
|
| 97 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 98 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 99 |
bass = f", {bass_style}" if bass_style != "none" else ", deep bass"
|
| 100 |
guitar = f", {guitar_style} guitar leads" if guitar_style != "none" else ", soulful guitar leads"
|
| 101 |
-
|
| 102 |
-
return f"Grunge{bass}{guitar}{drum}{synth}{vocal}, Pearl Jam-inspired emotional intensity with soaring choruses, {rhythm} at {bpm} BPM."
|
| 103 |
|
| 104 |
-
def set_soundgarden_grunge_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 105 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("heavy rhythmic steps" if bpm > 120 else "sludgy rhythmic groove")
|
| 106 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 107 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 108 |
bass = f", {bass_style}" if bass_style != "none" else ""
|
| 109 |
guitar = f", {guitar_style} guitar riffs" if guitar_style != "none" else ", heavy sludgy guitar riffs"
|
| 110 |
-
|
| 111 |
-
return f"Grunge{bass}{guitar}{drum}{synth}{vocal}, Soundgarden-inspired dark, psychedelic edge with powerful vocals, {rhythm} at {bpm} BPM."
|
| 112 |
|
| 113 |
-
def set_foo_fighters_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 114 |
styles = ["anthemic", "gritty", "melodic", "fast-paced", "driving"]
|
| 115 |
tempos = ["upbeat", "mid-tempo", "high-energy"]
|
| 116 |
moods = ["energetic", "introspective", "rebellious", "uplifting"]
|
|
@@ -121,90 +117,80 @@ def set_foo_fighters_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_st
|
|
| 121 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 122 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 123 |
bass = f", {bass_style}" if bass_style != "none" else ""
|
| 124 |
-
guitar = f", {guitar_style} guitar riffs" if guitar_style != "none" else ", {style} guitar riffs"
|
| 125 |
-
|
| 126 |
-
return f"Alternative rock{bass}{guitar}{drum}{synth}{vocal}, Foo Fighters-inspired {mood} vibe with powerful choruses, {rhythm} at {bpm} BPM."
|
| 127 |
|
| 128 |
-
def set_smashing_pumpkins_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 129 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("dynamic rhythmic steps" if bpm > 120 else "dreamy rhythmic flow")
|
| 130 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 131 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 132 |
bass = f", {bass_style}" if bass_style != "none" else ""
|
| 133 |
guitar = f", {guitar_style} guitar textures" if guitar_style != "none" else ", dreamy guitar textures"
|
| 134 |
-
|
| 135 |
-
return f"Alternative rock{bass}{guitar}{drum}{synth}{vocal}, Smashing Pumpkins-inspired blend of melancholy and aggression, {rhythm} at {bpm} BPM."
|
| 136 |
|
| 137 |
-
def set_radiohead_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 138 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("complex rhythmic steps" if bpm > 120 else "intricate rhythmic pulse")
|
| 139 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 140 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ", atmospheric synths"
|
| 141 |
bass = f", {bass_style}" if bass_style != "none" else ""
|
| 142 |
guitar = f", {guitar_style} guitar layers" if guitar_style != "none" else ", intricate guitar layers"
|
| 143 |
-
|
| 144 |
-
return f"Experimental rock{bass}{guitar}{drum}{synth}{vocal}, Radiohead-inspired blend of introspective and innovative soundscapes, {rhythm} at {bpm} BPM."
|
| 145 |
|
| 146 |
-
def set_classic_rock_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 147 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("bluesy rhythmic steps" if bpm > 120 else "steady rhythmic groove")
|
| 148 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 149 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 150 |
bass = f", {bass_style}" if bass_style != "none" else ", groovy bass"
|
| 151 |
guitar = f", {guitar_style} electric guitars" if guitar_style != "none" else ", bluesy electric guitars"
|
| 152 |
-
|
| 153 |
-
return f"Classic rock{bass}{guitar}{drum}{synth}{vocal}, Led Zeppelin-inspired raw energy with dynamic solos, {rhythm} at {bpm} BPM."
|
| 154 |
|
| 155 |
-
def set_alternative_rock_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 156 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("quirky rhythmic steps" if bpm > 120 else "energetic rhythmic flow")
|
| 157 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 158 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 159 |
bass = f", {bass_style}" if bass_style != "none" else ", melodic basslines"
|
| 160 |
guitar = f", {guitar_style} guitar riffs" if guitar_style != "none" else ", distorted guitar riffs"
|
| 161 |
-
|
| 162 |
-
return f"Alternative rock{bass}{guitar}{drum}{synth}{vocal}, Pixies-inspired quirky, energetic vibe, {rhythm} at {bpm} BPM."
|
| 163 |
|
| 164 |
-
def set_post_punk_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 165 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("sharp rhythmic steps" if bpm > 120 else "moody rhythmic pulse")
|
| 166 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 167 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 168 |
bass = f", {bass_style}" if bass_style != "none" else ", driving basslines"
|
| 169 |
guitar = f", {guitar_style} guitars" if guitar_style != "none" else ", jangly guitars"
|
| 170 |
-
|
| 171 |
-
return f"Post-punk{bass}{guitar}{drum}{synth}{vocal}, Joy Division-inspired moody, atmospheric sound, {rhythm} at {bpm} BPM."
|
| 172 |
|
| 173 |
-
def set_indie_rock_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 174 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("catchy rhythmic steps" if bpm > 120 else "jangly rhythmic flow")
|
| 175 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 176 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 177 |
bass = f", {bass_style}" if bass_style != "none" else ""
|
| 178 |
guitar = f", {guitar_style} guitars" if guitar_style != "none" else ", jangly guitars"
|
| 179 |
-
|
| 180 |
-
return f"Indie rock{bass}{guitar}{drum}{synth}{vocal}, Arctic Monkeys-inspired blend of witty lyrics and catchy riffs, {rhythm} at {bpm} BPM."
|
| 181 |
|
| 182 |
-
def set_funk_rock_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 183 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("aggressive rhythmic steps" if bpm > 120 else "funky rhythmic groove")
|
| 184 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 185 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 186 |
bass = f", {bass_style}" if bass_style != "none" else ", slap bass"
|
| 187 |
guitar = f", {guitar_style} guitar chords" if guitar_style != "none" else ", funky guitar chords"
|
| 188 |
-
|
| 189 |
-
return f"Funk rock{bass}{guitar}{drum}{synth}{vocal}, Rage Against the Machine-inspired mix of groove and aggression, {rhythm} at {bpm} BPM."
|
| 190 |
|
| 191 |
-
def set_detroit_techno_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 192 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("pulsing rhythmic steps" if bpm > 120 else "deep rhythmic groove")
|
| 193 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ", crisp hi-hats"
|
| 194 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ", deep pulsing synths"
|
| 195 |
bass = f", {bass_style}" if bass_style != "none" else ", driving basslines"
|
| 196 |
guitar = f", {guitar_style} guitars" if guitar_style != "none" else ""
|
| 197 |
-
|
| 198 |
-
return f"Detroit techno{bass}{guitar}{drum}{synth}{vocal}, Juan Atkins-inspired rhythmic groove, {rhythm} at {bpm} BPM."
|
| 199 |
|
| 200 |
-
def set_deep_house_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 201 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("soulful rhythmic steps" if bpm > 120 else "laid-back rhythmic flow")
|
| 202 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 203 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ", warm analog synth chords"
|
| 204 |
bass = f", {bass_style}" if bass_style != "none" else ", deep basslines"
|
| 205 |
guitar = f", {guitar_style} guitars" if guitar_style != "none" else ""
|
| 206 |
-
|
| 207 |
-
return f"Deep house{bass}{guitar}{drum}{synth}{vocal}, Larry Heard-inspired laid-back groove, {rhythm} at {bpm} BPM."
|
| 208 |
|
| 209 |
# 5) AUDIO PROCESSING FUNCTIONS
|
| 210 |
def apply_eq(segment):
|
|
@@ -218,13 +204,13 @@ def apply_fade(segment, fade_in_duration=1000, fade_out_duration=1000):
|
|
| 218 |
return segment
|
| 219 |
|
| 220 |
# 6) GENERATION & I/O FUNCTIONS
|
| 221 |
-
def generate_music(instrumental_prompt: str, cfg_scale: float, total_duration: int, chunk_duration: int, crossfade_duration: int, bpm: int, drum_beat: str, synthesizer: str, rhythmic_steps: str, bass_style: str, guitar_style: str
|
| 222 |
global musicgen_model
|
| 223 |
if not instrumental_prompt.strip():
|
| 224 |
return None, "β οΈ Please enter a valid instrumental prompt!"
|
| 225 |
try:
|
| 226 |
start_time = time.time()
|
| 227 |
-
total_duration =
|
| 228 |
chunk_duration = min(max(chunk_duration, 5), 15)
|
| 229 |
num_chunks = max(1, total_duration // chunk_duration)
|
| 230 |
chunk_duration = total_duration / num_chunks
|
|
@@ -247,9 +233,9 @@ def generate_music(instrumental_prompt: str, cfg_scale: float, total_duration: i
|
|
| 247 |
musicgen_model.set_generation_params(
|
| 248 |
duration=generation_duration,
|
| 249 |
use_sampling=True,
|
| 250 |
-
top_k=
|
| 251 |
-
top_p=
|
| 252 |
-
temperature=
|
| 253 |
cfg_coef=cfg_scale
|
| 254 |
)
|
| 255 |
|
|
@@ -312,7 +298,7 @@ def generate_music(instrumental_prompt: str, cfg_scale: float, total_duration: i
|
|
| 312 |
print_resource_usage("After Final Generation")
|
| 313 |
print(f"Total Generation Time: {time.time() - start_time:.2f} seconds")
|
| 314 |
|
| 315 |
-
return mp3_path, "β
Done! Generated audio."
|
| 316 |
except Exception as e:
|
| 317 |
return None, f"β Generation failed: {e}"
|
| 318 |
finally:
|
|
@@ -323,7 +309,7 @@ def generate_music(instrumental_prompt: str, cfg_scale: float, total_duration: i
|
|
| 323 |
|
| 324 |
# Function to clear inputs
|
| 325 |
def clear_inputs():
|
| 326 |
-
return "", 3.0,
|
| 327 |
|
| 328 |
# 7) CUSTOM CSS
|
| 329 |
css = """
|
|
@@ -376,6 +362,15 @@ p {
|
|
| 376 |
padding: 10px 20px;
|
| 377 |
border-radius: 5px;
|
| 378 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
@keyframes glitch-ghost {
|
| 380 |
0% { transform: translate(0, 0); opacity: 1; }
|
| 381 |
20% { transform: translate(-5px, 2px); opacity: 0.8; }
|
|
@@ -397,142 +392,166 @@ with gr.Blocks(css=css) as demo:
|
|
| 397 |
gr.Markdown("""
|
| 398 |
<div class="header-container">
|
| 399 |
<div id="ghost-logo">π»</div>
|
| 400 |
-
<h1>GhostAI Music Generator
|
| 401 |
<p>Summon the Sound of the Unknown</p>
|
| 402 |
</div>
|
| 403 |
""")
|
| 404 |
|
| 405 |
with gr.Column(elem_classes="input-container"):
|
|
|
|
| 406 |
instrumental_prompt = gr.Textbox(
|
| 407 |
-
label="Instrumental Prompt",
|
| 408 |
-
placeholder="Click a genre button or type your own prompt",
|
| 409 |
lines=4,
|
| 410 |
elem_classes="textbox"
|
| 411 |
)
|
| 412 |
with gr.Row(elem_classes="genre-buttons"):
|
| 413 |
-
rhcp_btn = gr.Button("Red Hot Chili Peppers", elem_classes="genre-btn")
|
| 414 |
-
nirvana_btn = gr.Button("Nirvana Grunge", elem_classes="genre-btn")
|
| 415 |
-
pearl_jam_btn = gr.Button("Pearl Jam Grunge", elem_classes="genre-btn")
|
| 416 |
-
soundgarden_btn = gr.Button("Soundgarden Grunge", elem_classes="genre-btn")
|
| 417 |
-
foo_fighters_btn = gr.Button("Foo Fighters", elem_classes="genre-btn")
|
| 418 |
-
smashing_pumpkins_btn = gr.Button("Smashing Pumpkins", elem_classes="genre-btn")
|
| 419 |
-
radiohead_btn = gr.Button("Radiohead", elem_classes="genre-btn")
|
| 420 |
-
classic_rock_btn = gr.Button("Classic Rock", elem_classes="genre-btn")
|
| 421 |
-
alternative_rock_btn = gr.Button("Alternative Rock", elem_classes="genre-btn")
|
| 422 |
-
post_punk_btn = gr.Button("Post-Punk", elem_classes="genre-btn")
|
| 423 |
-
indie_rock_btn = gr.Button("Indie Rock", elem_classes="genre-btn")
|
| 424 |
-
funk_rock_btn = gr.Button("Funk Rock", elem_classes="genre-btn")
|
| 425 |
-
detroit_techno_btn = gr.Button("Detroit Techno", elem_classes="genre-btn")
|
| 426 |
-
deep_house_btn = gr.Button("Deep House", elem_classes="genre-btn")
|
| 427 |
|
| 428 |
with gr.Column(elem_classes="settings-container"):
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
)
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 505 |
with gr.Row(elem_classes="action-buttons"):
|
| 506 |
-
gen_btn = gr.Button("Generate Music")
|
| 507 |
-
clr_btn = gr.Button("Clear Inputs")
|
| 508 |
|
| 509 |
with gr.Column(elem_classes="output-container"):
|
| 510 |
-
|
| 511 |
-
|
|
|
|
| 512 |
|
| 513 |
-
rhcp_btn.click(set_red_hot_chili_peppers_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 514 |
-
nirvana_btn.click(set_nirvana_grunge_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 515 |
-
pearl_jam_btn.click(set_pearl_jam_grunge_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 516 |
-
soundgarden_btn.click(set_soundgarden_grunge_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 517 |
-
foo_fighters_btn.click(set_foo_fighters_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 518 |
-
smashing_pumpkins_btn.click(set_smashing_pumpkins_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 519 |
-
radiohead_btn.click(set_radiohead_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 520 |
-
classic_rock_btn.click(set_classic_rock_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 521 |
-
alternative_rock_btn.click(set_alternative_rock_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 522 |
-
post_punk_btn.click(set_post_punk_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 523 |
-
indie_rock_btn.click(set_indie_rock_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 524 |
-
funk_rock_btn.click(set_funk_rock_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 525 |
-
detroit_techno_btn.click(set_detroit_techno_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 526 |
-
deep_house_btn.click(set_deep_house_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 527 |
gen_btn.click(
|
| 528 |
generate_music,
|
| 529 |
-
inputs=[instrumental_prompt, cfg_scale, total_duration, chunk_duration, crossfade_duration, bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 530 |
outputs=[out_audio, status]
|
| 531 |
)
|
| 532 |
clr_btn.click(
|
| 533 |
clear_inputs,
|
| 534 |
inputs=None,
|
| 535 |
-
outputs=[instrumental_prompt, cfg_scale, total_duration, chunk_duration, crossfade_duration, bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style
|
| 536 |
)
|
| 537 |
|
| 538 |
# 9) TURN OFF OPENAPI/DOCS
|
|
|
|
| 74 |
return available_vram >= required_gb
|
| 75 |
|
| 76 |
# 4) GENRE PROMPT FUNCTIONS
|
| 77 |
+
def set_red_hot_chili_peppers_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style):
|
| 78 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("strong rhythmic steps" if bpm > 120 else "groovy rhythmic flow")
|
| 79 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 80 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 81 |
bass = f", {bass_style}" if bass_style != "none" else ", groovy basslines"
|
| 82 |
guitar = f", {guitar_style} guitar riffs" if guitar_style != "none" else ", syncopated guitar riffs"
|
| 83 |
+
return f"Instrumental funk rock{bass}{guitar}{drum}{synth}, Red Hot Chili Peppers-inspired vibe with dynamic energy and funky breakdowns, {rhythm} at {bpm} BPM."
|
|
|
|
| 84 |
|
| 85 |
+
def set_nirvana_grunge_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style):
|
| 86 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("intense rhythmic steps" if bpm > 120 else "grungy rhythmic pulse")
|
| 87 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 88 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 89 |
bass = f", {bass_style}" if bass_style != "none" else ", melodic basslines"
|
| 90 |
guitar = f", {guitar_style} guitar riffs" if guitar_style != "none" else ", raw distorted guitar riffs"
|
| 91 |
+
return f"Instrumental grunge{bass}{guitar}{drum}{synth}, Nirvana-inspired angst-filled sound with quiet-loud dynamics, {rhythm} at {bpm} BPM."
|
|
|
|
| 92 |
|
| 93 |
+
def set_pearl_jam_grunge_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style):
|
| 94 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("soulful rhythmic steps" if bpm > 120 else "driving rhythmic flow")
|
| 95 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 96 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 97 |
bass = f", {bass_style}" if bass_style != "none" else ", deep bass"
|
| 98 |
guitar = f", {guitar_style} guitar leads" if guitar_style != "none" else ", soulful guitar leads"
|
| 99 |
+
return f"Instrumental grunge{bass}{guitar}{drum}{synth}, Pearl Jam-inspired emotional intensity with soaring choruses, {rhythm} at {bpm} BPM."
|
|
|
|
| 100 |
|
| 101 |
+
def set_soundgarden_grunge_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style):
|
| 102 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("heavy rhythmic steps" if bpm > 120 else "sludgy rhythmic groove")
|
| 103 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 104 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 105 |
bass = f", {bass_style}" if bass_style != "none" else ""
|
| 106 |
guitar = f", {guitar_style} guitar riffs" if guitar_style != "none" else ", heavy sludgy guitar riffs"
|
| 107 |
+
return f"Instrumental grunge{bass}{guitar}{drum}{synth}, Soundgarden-inspired dark, psychedelic edge, {rhythm} at {bpm} BPM."
|
|
|
|
| 108 |
|
| 109 |
+
def set_foo_fighters_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style):
|
| 110 |
styles = ["anthemic", "gritty", "melodic", "fast-paced", "driving"]
|
| 111 |
tempos = ["upbeat", "mid-tempo", "high-energy"]
|
| 112 |
moods = ["energetic", "introspective", "rebellious", "uplifting"]
|
|
|
|
| 117 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 118 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 119 |
bass = f", {bass_style}" if bass_style != "none" else ""
|
| 120 |
+
guitar = f", {guitar_style} guitar riffs" if guitar_style != "none" else f", {style} guitar riffs"
|
| 121 |
+
return f"Instrumental alternative rock{bass}{guitar}{drum}{synth}, Foo Fighters-inspired {mood} vibe with powerful choruses, {rhythm} at {bpm} BPM."
|
|
|
|
| 122 |
|
| 123 |
+
def set_smashing_pumpkins_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style):
|
| 124 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("dynamic rhythmic steps" if bpm > 120 else "dreamy rhythmic flow")
|
| 125 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 126 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 127 |
bass = f", {bass_style}" if bass_style != "none" else ""
|
| 128 |
guitar = f", {guitar_style} guitar textures" if guitar_style != "none" else ", dreamy guitar textures"
|
| 129 |
+
return f"Instrumental alternative rock{bass}{guitar}{drum}{synth}, Smashing Pumpkins-inspired blend of melancholy and aggression, {rhythm} at {bpm} BPM."
|
|
|
|
| 130 |
|
| 131 |
+
def set_radiohead_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style):
|
| 132 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("complex rhythmic steps" if bpm > 120 else "intricate rhythmic pulse")
|
| 133 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 134 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ", atmospheric synths"
|
| 135 |
bass = f", {bass_style}" if bass_style != "none" else ""
|
| 136 |
guitar = f", {guitar_style} guitar layers" if guitar_style != "none" else ", intricate guitar layers"
|
| 137 |
+
return f"Instrumental experimental rock{bass}{guitar}{drum}{synth}, Radiohead-inspired blend of introspective and innovative soundscapes, {rhythm} at {bpm} BPM."
|
|
|
|
| 138 |
|
| 139 |
+
def set_classic_rock_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style):
|
| 140 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("bluesy rhythmic steps" if bpm > 120 else "steady rhythmic groove")
|
| 141 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 142 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 143 |
bass = f", {bass_style}" if bass_style != "none" else ", groovy bass"
|
| 144 |
guitar = f", {guitar_style} electric guitars" if guitar_style != "none" else ", bluesy electric guitars"
|
| 145 |
+
return f"Instrumental classic rock{bass}{guitar}{drum}{synth}, Led Zeppelin-inspired raw energy with dynamic solos, {rhythm} at {bpm} BPM."
|
|
|
|
| 146 |
|
| 147 |
+
def set_alternative_rock_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style):
|
| 148 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("quirky rhythmic steps" if bpm > 120 else "energetic rhythmic flow")
|
| 149 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 150 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 151 |
bass = f", {bass_style}" if bass_style != "none" else ", melodic basslines"
|
| 152 |
guitar = f", {guitar_style} guitar riffs" if guitar_style != "none" else ", distorted guitar riffs"
|
| 153 |
+
return f"Instrumental alternative rock{bass}{guitar}{drum}{synth}, Pixies-inspired quirky, energetic vibe, {rhythm} at {bpm} BPM."
|
|
|
|
| 154 |
|
| 155 |
+
def set_post_punk_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style):
|
| 156 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("sharp rhythmic steps" if bpm > 120 else "moody rhythmic pulse")
|
| 157 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 158 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 159 |
bass = f", {bass_style}" if bass_style != "none" else ", driving basslines"
|
| 160 |
guitar = f", {guitar_style} guitars" if guitar_style != "none" else ", jangly guitars"
|
| 161 |
+
return f"Instrumental post-punk{bass}{guitar}{drum}{synth}, Joy Division-inspired moody, atmospheric sound, {rhythm} at {bpm} BPM."
|
|
|
|
| 162 |
|
| 163 |
+
def set_indie_rock_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style):
|
| 164 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("catchy rhythmic steps" if bpm > 120 else "jangly rhythmic flow")
|
| 165 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 166 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 167 |
bass = f", {bass_style}" if bass_style != "none" else ""
|
| 168 |
guitar = f", {guitar_style} guitars" if guitar_style != "none" else ", jangly guitars"
|
| 169 |
+
return f"Instrumental indie rock{bass}{guitar}{drum}{synth}, Arctic Monkeys-inspired blend of catchy riffs, {rhythm} at {bpm} BPM."
|
|
|
|
| 170 |
|
| 171 |
+
def set_funk_rock_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style):
|
| 172 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("aggressive rhythmic steps" if bpm > 120 else "funky rhythmic groove")
|
| 173 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 174 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ""
|
| 175 |
bass = f", {bass_style}" if bass_style != "none" else ", slap bass"
|
| 176 |
guitar = f", {guitar_style} guitar chords" if guitar_style != "none" else ", funky guitar chords"
|
| 177 |
+
return f"Instrumental funk rock{bass}{guitar}{drum}{synth}, Rage Against the Machine-inspired mix of groove and aggression, {rhythm} at {bpm} BPM."
|
|
|
|
| 178 |
|
| 179 |
+
def set_detroit_techno_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style):
|
| 180 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("pulsing rhythmic steps" if bpm > 120 else "deep rhythmic groove")
|
| 181 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ", crisp hi-hats"
|
| 182 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ", deep pulsing synths"
|
| 183 |
bass = f", {bass_style}" if bass_style != "none" else ", driving basslines"
|
| 184 |
guitar = f", {guitar_style} guitars" if guitar_style != "none" else ""
|
| 185 |
+
return f"Instrumental Detroit techno{bass}{guitar}{drum}{synth}, Juan Atkins-inspired rhythmic groove, {rhythm} at {bpm} BPM."
|
|
|
|
| 186 |
|
| 187 |
+
def set_deep_house_prompt(bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style):
|
| 188 |
rhythm = f" with {rhythmic_steps}" if rhythmic_steps != "none" else ("soulful rhythmic steps" if bpm > 120 else "laid-back rhythmic flow")
|
| 189 |
drum = f", {drum_beat} drums" if drum_beat != "none" else ""
|
| 190 |
synth = f", {synthesizer} accents" if synthesizer != "none" else ", warm analog synth chords"
|
| 191 |
bass = f", {bass_style}" if bass_style != "none" else ", deep basslines"
|
| 192 |
guitar = f", {guitar_style} guitars" if guitar_style != "none" else ""
|
| 193 |
+
return f"Instrumental deep house{bass}{guitar}{drum}{synth}, Larry Heard-inspired laid-back groove, {rhythm} at {bpm} BPM."
|
|
|
|
| 194 |
|
| 195 |
# 5) AUDIO PROCESSING FUNCTIONS
|
| 196 |
def apply_eq(segment):
|
|
|
|
| 204 |
return segment
|
| 205 |
|
| 206 |
# 6) GENERATION & I/O FUNCTIONS
|
| 207 |
+
def generate_music(instrumental_prompt: str, cfg_scale: float, top_k: int, top_p: float, temperature: float, total_duration: int, chunk_duration: int, crossfade_duration: int, bpm: int, drum_beat: str, synthesizer: str, rhythmic_steps: str, bass_style: str, guitar_style: str):
|
| 208 |
global musicgen_model
|
| 209 |
if not instrumental_prompt.strip():
|
| 210 |
return None, "β οΈ Please enter a valid instrumental prompt!"
|
| 211 |
try:
|
| 212 |
start_time = time.time()
|
| 213 |
+
total_duration = total_duration # Validated by radio button (30, 60, 90, 120)
|
| 214 |
chunk_duration = min(max(chunk_duration, 5), 15)
|
| 215 |
num_chunks = max(1, total_duration // chunk_duration)
|
| 216 |
chunk_duration = total_duration / num_chunks
|
|
|
|
| 233 |
musicgen_model.set_generation_params(
|
| 234 |
duration=generation_duration,
|
| 235 |
use_sampling=True,
|
| 236 |
+
top_k=top_k,
|
| 237 |
+
top_p=top_p,
|
| 238 |
+
temperature=temperature,
|
| 239 |
cfg_coef=cfg_scale
|
| 240 |
)
|
| 241 |
|
|
|
|
| 298 |
print_resource_usage("After Final Generation")
|
| 299 |
print(f"Total Generation Time: {time.time() - start_time:.2f} seconds")
|
| 300 |
|
| 301 |
+
return mp3_path, "β
Done! Generated instrumental audio."
|
| 302 |
except Exception as e:
|
| 303 |
return None, f"β Generation failed: {e}"
|
| 304 |
finally:
|
|
|
|
| 309 |
|
| 310 |
# Function to clear inputs
|
| 311 |
def clear_inputs():
|
| 312 |
+
return "", 3.0, 250, 0.9, 1.0, 30, 10, 1000, 120, "none", "none", "none", "none", "none"
|
| 313 |
|
| 314 |
# 7) CUSTOM CSS
|
| 315 |
css = """
|
|
|
|
| 362 |
padding: 10px 20px;
|
| 363 |
border-radius: 5px;
|
| 364 |
}
|
| 365 |
+
.gradio-container {
|
| 366 |
+
padding: 20px;
|
| 367 |
+
}
|
| 368 |
+
.group-container {
|
| 369 |
+
margin-bottom: 20px;
|
| 370 |
+
padding: 15px;
|
| 371 |
+
border: 1px solid #00FF9F;
|
| 372 |
+
border-radius: 8px;
|
| 373 |
+
}
|
| 374 |
@keyframes glitch-ghost {
|
| 375 |
0% { transform: translate(0, 0); opacity: 1; }
|
| 376 |
20% { transform: translate(-5px, 2px); opacity: 0.8; }
|
|
|
|
| 392 |
gr.Markdown("""
|
| 393 |
<div class="header-container">
|
| 394 |
<div id="ghost-logo">π»</div>
|
| 395 |
+
<h1>GhostAI Music Generator πΉ</h1>
|
| 396 |
<p>Summon the Sound of the Unknown</p>
|
| 397 |
</div>
|
| 398 |
""")
|
| 399 |
|
| 400 |
with gr.Column(elem_classes="input-container"):
|
| 401 |
+
gr.Markdown("### πΈ Prompt Settings")
|
| 402 |
instrumental_prompt = gr.Textbox(
|
| 403 |
+
label="Instrumental Prompt βοΈ",
|
| 404 |
+
placeholder="Click a genre button or type your own instrumental prompt",
|
| 405 |
lines=4,
|
| 406 |
elem_classes="textbox"
|
| 407 |
)
|
| 408 |
with gr.Row(elem_classes="genre-buttons"):
|
| 409 |
+
rhcp_btn = gr.Button("Red Hot Chili Peppers πΆοΈ", elem_classes="genre-btn")
|
| 410 |
+
nirvana_btn = gr.Button("Nirvana Grunge πΈ", elem_classes="genre-btn")
|
| 411 |
+
pearl_jam_btn = gr.Button("Pearl Jam Grunge π¦ͺ", elem_classes="genre-btn")
|
| 412 |
+
soundgarden_btn = gr.Button("Soundgarden Grunge π", elem_classes="genre-btn")
|
| 413 |
+
foo_fighters_btn = gr.Button("Foo Fighters π€", elem_classes="genre-btn")
|
| 414 |
+
smashing_pumpkins_btn = gr.Button("Smashing Pumpkins π", elem_classes="genre-btn")
|
| 415 |
+
radiohead_btn = gr.Button("Radiohead π§ ", elem_classes="genre-btn")
|
| 416 |
+
classic_rock_btn = gr.Button("Classic Rock πΈ", elem_classes="genre-btn")
|
| 417 |
+
alternative_rock_btn = gr.Button("Alternative Rock π΅", elem_classes="genre-btn")
|
| 418 |
+
post_punk_btn = gr.Button("Post-Punk π€", elem_classes="genre-btn")
|
| 419 |
+
indie_rock_btn = gr.Button("Indie Rock π€", elem_classes="genre-btn")
|
| 420 |
+
funk_rock_btn = gr.Button("Funk Rock πΊ", elem_classes="genre-btn")
|
| 421 |
+
detroit_techno_btn = gr.Button("Detroit Techno ποΈ", elem_classes="genre-btn")
|
| 422 |
+
deep_house_btn = gr.Button("Deep House π ", elem_classes="genre-btn")
|
| 423 |
|
| 424 |
with gr.Column(elem_classes="settings-container"):
|
| 425 |
+
gr.Markdown("### βοΈ API Settings")
|
| 426 |
+
with gr.Group(elem_classes="group-container"):
|
| 427 |
+
cfg_scale = gr.Slider(
|
| 428 |
+
label="CFG Scale π―",
|
| 429 |
+
minimum=1.0,
|
| 430 |
+
maximum=10.0,
|
| 431 |
+
value=3.0,
|
| 432 |
+
step=0.1,
|
| 433 |
+
info="Controls how closely the music follows the prompt."
|
| 434 |
+
)
|
| 435 |
+
top_k = gr.Slider(
|
| 436 |
+
label="Top-K Sampling π’",
|
| 437 |
+
minimum=10,
|
| 438 |
+
maximum=500,
|
| 439 |
+
value=250,
|
| 440 |
+
step=10,
|
| 441 |
+
info="Limits sampling to the top k most likely tokens."
|
| 442 |
+
)
|
| 443 |
+
top_p = gr.Slider(
|
| 444 |
+
label="Top-P Sampling π°",
|
| 445 |
+
minimum=0.0,
|
| 446 |
+
maximum=1.0,
|
| 447 |
+
value=0.9,
|
| 448 |
+
step=0.05,
|
| 449 |
+
info="Keeps tokens with cumulative probability above p."
|
| 450 |
+
)
|
| 451 |
+
temperature = gr.Slider(
|
| 452 |
+
label="Temperature π₯",
|
| 453 |
+
minimum=0.1,
|
| 454 |
+
maximum=2.0,
|
| 455 |
+
value=1.0,
|
| 456 |
+
step=0.1,
|
| 457 |
+
info="Controls randomness; higher values increase diversity."
|
| 458 |
+
)
|
| 459 |
+
total_duration = gr.Radio(
|
| 460 |
+
label="Song Length β³ (seconds)",
|
| 461 |
+
choices=[30, 60, 90, 120],
|
| 462 |
+
value=30,
|
| 463 |
+
info="Select the total duration of the track."
|
| 464 |
+
)
|
| 465 |
+
chunk_duration = gr.Slider(
|
| 466 |
+
label="Chunk Duration β±οΈ (seconds)",
|
| 467 |
+
minimum=5,
|
| 468 |
+
maximum=15,
|
| 469 |
+
value=10,
|
| 470 |
+
step=1,
|
| 471 |
+
info="Duration of each chunk to render (5 to 15 seconds)."
|
| 472 |
+
)
|
| 473 |
+
crossfade_duration = gr.Slider(
|
| 474 |
+
label="Crossfade Duration πΆ (ms)",
|
| 475 |
+
minimum=100,
|
| 476 |
+
maximum=2000,
|
| 477 |
+
value=1000,
|
| 478 |
+
step=100,
|
| 479 |
+
info="Crossfade duration between chunks."
|
| 480 |
+
)
|
| 481 |
+
|
| 482 |
+
gr.Markdown("### π΅ Musical Controls")
|
| 483 |
+
with gr.Group(elem_classes="group-container"):
|
| 484 |
+
bpm = gr.Slider(
|
| 485 |
+
label="Tempo π΅ (BPM)",
|
| 486 |
+
minimum=60,
|
| 487 |
+
maximum=180,
|
| 488 |
+
value=120,
|
| 489 |
+
step=1,
|
| 490 |
+
info="Beats per minute to set the track's tempo."
|
| 491 |
+
)
|
| 492 |
+
drum_beat = gr.Dropdown(
|
| 493 |
+
label="Drum Beat π₯",
|
| 494 |
+
choices=["none", "standard rock", "funk groove", "techno kick", "jazz swing"],
|
| 495 |
+
value="none",
|
| 496 |
+
info="Select a drum beat style to influence the rhythm."
|
| 497 |
+
)
|
| 498 |
+
synthesizer = gr.Dropdown(
|
| 499 |
+
label="Synthesizer πΉ",
|
| 500 |
+
choices=["none", "analog synth", "digital pad", "arpeggiated synth"],
|
| 501 |
+
value="none",
|
| 502 |
+
info="Select a synthesizer style for electronic accents."
|
| 503 |
+
)
|
| 504 |
+
rhythmic_steps = gr.Dropdown(
|
| 505 |
+
label="Rhythmic Steps π£",
|
| 506 |
+
choices=["none", "syncopated steps", "steady steps", "complex steps"],
|
| 507 |
+
value="none",
|
| 508 |
+
info="Select a rhythmic step style to enhance the beat."
|
| 509 |
+
)
|
| 510 |
+
bass_style = gr.Dropdown(
|
| 511 |
+
label="Bass Style πΈ",
|
| 512 |
+
choices=["none", "slap bass", "deep bass", "melodic bass"],
|
| 513 |
+
value="none",
|
| 514 |
+
info="Select a bass style to shape the low end."
|
| 515 |
+
)
|
| 516 |
+
guitar_style = gr.Dropdown(
|
| 517 |
+
label="Guitar Style πΈ",
|
| 518 |
+
choices=["none", "distorted", "clean", "jangle"],
|
| 519 |
+
value="none",
|
| 520 |
+
info="Select a guitar style to define the riffs."
|
| 521 |
+
)
|
| 522 |
+
|
| 523 |
with gr.Row(elem_classes="action-buttons"):
|
| 524 |
+
gen_btn = gr.Button("Generate Music π")
|
| 525 |
+
clr_btn = gr.Button("Clear Inputs π§Ή")
|
| 526 |
|
| 527 |
with gr.Column(elem_classes="output-container"):
|
| 528 |
+
gr.Markdown("### π§ Output")
|
| 529 |
+
out_audio = gr.Audio(label="Generated Instrumental Track π΅", type="filepath")
|
| 530 |
+
status = gr.Textbox(label="Status π’", interactive=False)
|
| 531 |
|
| 532 |
+
rhcp_btn.click(set_red_hot_chili_peppers_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style], outputs=instrumental_prompt)
|
| 533 |
+
nirvana_btn.click(set_nirvana_grunge_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style], outputs=instrumental_prompt)
|
| 534 |
+
pearl_jam_btn.click(set_pearl_jam_grunge_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style], outputs=instrumental_prompt)
|
| 535 |
+
soundgarden_btn.click(set_soundgarden_grunge_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style], outputs=instrumental_prompt)
|
| 536 |
+
foo_fighters_btn.click(set_foo_fighters_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style], outputs=instrumental_prompt)
|
| 537 |
+
smashing_pumpkins_btn.click(set_smashing_pumpkins_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style], outputs=instrumental_prompt)
|
| 538 |
+
radiohead_btn.click(set_radiohead_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style], outputs=instrumental_prompt)
|
| 539 |
+
classic_rock_btn.click(set_classic_rock_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style], outputs=instrumental_prompt)
|
| 540 |
+
alternative_rock_btn.click(set_alternative_rock_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style], outputs=instrumental_prompt)
|
| 541 |
+
post_punk_btn.click(set_post_punk_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style], outputs=instrumental_prompt)
|
| 542 |
+
indie_rock_btn.click(set_indie_rock_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style], outputs=instrumental_prompt)
|
| 543 |
+
funk_rock_btn.click(set_funk_rock_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style], outputs=instrumental_prompt)
|
| 544 |
+
detroit_techno_btn.click(set_detroit_techno_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style], outputs=instrumental_prompt)
|
| 545 |
+
deep_house_btn.click(set_deep_house_prompt, inputs=[bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style], outputs=instrumental_prompt)
|
| 546 |
gen_btn.click(
|
| 547 |
generate_music,
|
| 548 |
+
inputs=[instrumental_prompt, cfg_scale, top_k, top_p, temperature, total_duration, chunk_duration, crossfade_duration, bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style],
|
| 549 |
outputs=[out_audio, status]
|
| 550 |
)
|
| 551 |
clr_btn.click(
|
| 552 |
clear_inputs,
|
| 553 |
inputs=None,
|
| 554 |
+
outputs=[instrumental_prompt, cfg_scale, top_k, top_p, temperature, total_duration, chunk_duration, crossfade_duration, bpm, drum_beat, synthesizer, rhythmic_steps, bass_style, guitar_style]
|
| 555 |
)
|
| 556 |
|
| 557 |
# 9) TURN OFF OPENAPI/DOCS
|