Update app.py
Browse files
app.py
CHANGED
|
@@ -423,62 +423,151 @@ def optimize_model_selection(lyrics, genre):
|
|
| 423 |
return model_path, model_config[model_path], params
|
| 424 |
|
| 425 |
def main():
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 430 |
with gr.Row():
|
| 431 |
-
|
|
|
|
|
|
|
| 432 |
genre_txt = gr.Textbox(
|
| 433 |
-
label="Genre",
|
| 434 |
-
placeholder="
|
|
|
|
| 435 |
)
|
| 436 |
lyrics_txt = gr.Textbox(
|
| 437 |
-
label="Lyrics
|
| 438 |
-
placeholder="Enter
|
| 439 |
-
lines=10
|
|
|
|
| 440 |
)
|
| 441 |
|
| 442 |
-
|
| 443 |
-
num_segments = gr.Number(
|
| 444 |
-
label="Number of Song Segments (Auto-adjusted based on lyrics)",
|
| 445 |
-
value=2,
|
| 446 |
-
minimum=1,
|
| 447 |
-
maximum=4,
|
| 448 |
-
step=1,
|
| 449 |
-
interactive=False
|
| 450 |
-
)
|
| 451 |
-
max_new_tokens = gr.Slider(
|
| 452 |
-
label="Max New Tokens (Auto-adjusted based on lyrics)",
|
| 453 |
-
minimum=500,
|
| 454 |
-
maximum=32000,
|
| 455 |
-
step=500,
|
| 456 |
-
value=4000,
|
| 457 |
-
interactive=False
|
| 458 |
-
)
|
| 459 |
with gr.Row():
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
Don't let this moment fade, hold me close tonight
|
| 477 |
-
With you here beside me, everything's alright
|
| 478 |
-
Can't imagine life alone, don't want to let you go
|
| 479 |
-
Stay with me forever, let our love just flow
|
| 480 |
|
| 481 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 482 |
In the quiet of the evening, shadows start to fall
|
| 483 |
Whispers of the night wind echo through the hall
|
| 484 |
Lost within the silence, I hear your gentle voice
|
|
@@ -489,10 +578,10 @@ Don't let this moment fade, hold me close tonight
|
|
| 489 |
With you here beside me, everything's alright
|
| 490 |
Can't imagine life alone, don't want to let you go
|
| 491 |
Stay with me forever, let our love just flow"""
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
μΈμ κ° λ§μ£Όν λλΉ μμμ
|
| 497 |
|
| 498 |
[chorus]
|
|
@@ -502,26 +591,36 @@ Stay with me forever, let our love just flow"""
|
|
| 502 |
μ΄λμ΄ λ°€μ μ§λ λλ§λ€
|
| 503 |
|
| 504 |
[chorus]
|
| 505 |
-
λ€μ ν λ² λ΄κ² λ§ν΄μ€
|
| 506 |
-
|
| 507 |
-
]
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 525 |
lyrics_txt.change(
|
| 526 |
fn=update_info,
|
| 527 |
inputs=[lyrics_txt],
|
|
|
|
| 423 |
return model_path, model_config[model_path], params
|
| 424 |
|
| 425 |
def main():
|
| 426 |
+
# ν
λ§ μ€μ
|
| 427 |
+
theme = gr.themes.Soft(
|
| 428 |
+
primary_hue="indigo",
|
| 429 |
+
secondary_hue="purple",
|
| 430 |
+
neutral_hue="slate",
|
| 431 |
+
font=["Arial", "sans-serif"]
|
| 432 |
+
)
|
| 433 |
+
|
| 434 |
+
# CSS μ€νμΌ μ μ
|
| 435 |
+
custom_css = """
|
| 436 |
+
#main-container {
|
| 437 |
+
max-width: 1200px;
|
| 438 |
+
margin: auto;
|
| 439 |
+
padding: 20px;
|
| 440 |
+
}
|
| 441 |
+
#header {
|
| 442 |
+
text-align: center;
|
| 443 |
+
margin-bottom: 30px;
|
| 444 |
+
background: linear-gradient(135deg, #6366f1, #a855f7);
|
| 445 |
+
padding: 20px;
|
| 446 |
+
border-radius: 15px;
|
| 447 |
+
color: white;
|
| 448 |
+
}
|
| 449 |
+
.input-section {
|
| 450 |
+
background: #f8fafc;
|
| 451 |
+
padding: 20px;
|
| 452 |
+
border-radius: 15px;
|
| 453 |
+
margin-bottom: 20px;
|
| 454 |
+
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
|
| 455 |
+
}
|
| 456 |
+
.output-section {
|
| 457 |
+
background: #f0f9ff;
|
| 458 |
+
padding: 20px;
|
| 459 |
+
border-radius: 15px;
|
| 460 |
+
margin-bottom: 20px;
|
| 461 |
+
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
|
| 462 |
+
}
|
| 463 |
+
#generate-btn {
|
| 464 |
+
background: linear-gradient(135deg, #6366f1, #a855f7);
|
| 465 |
+
border: none;
|
| 466 |
+
padding: 15px 30px;
|
| 467 |
+
border-radius: 10px;
|
| 468 |
+
color: white;
|
| 469 |
+
font-weight: bold;
|
| 470 |
+
cursor: pointer;
|
| 471 |
+
transition: all 0.3s ease;
|
| 472 |
+
}
|
| 473 |
+
#generate-btn:hover {
|
| 474 |
+
transform: translateY(-2px);
|
| 475 |
+
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
| 476 |
+
}
|
| 477 |
+
.info-box {
|
| 478 |
+
background: #fff;
|
| 479 |
+
padding: 15px;
|
| 480 |
+
border-radius: 10px;
|
| 481 |
+
border: 1px solid #e2e8f0;
|
| 482 |
+
margin: 10px 0;
|
| 483 |
+
}
|
| 484 |
+
.examples-section {
|
| 485 |
+
background: #f8fafc;
|
| 486 |
+
padding: 20px;
|
| 487 |
+
border-radius: 15px;
|
| 488 |
+
margin-top: 20px;
|
| 489 |
+
}
|
| 490 |
+
"""
|
| 491 |
+
|
| 492 |
+
with gr.Blocks(theme=theme, css=custom_css) as demo:
|
| 493 |
+
with gr.Column(elem_id="main-container"):
|
| 494 |
+
# ν€λ μΉμ
|
| 495 |
+
with gr.Row(elem_id="header"):
|
| 496 |
+
gr.Markdown(
|
| 497 |
+
"""
|
| 498 |
+
# π΅ AI Song Creator
|
| 499 |
+
### Transform Your Lyrics into Complete Songs with Music
|
| 500 |
+
Create professional songs from your lyrics in multiple languages
|
| 501 |
+
"""
|
| 502 |
+
)
|
| 503 |
+
|
| 504 |
+
# λ©μΈ 컨ν
μΈ
|
| 505 |
with gr.Row():
|
| 506 |
+
# μ
λ ₯ μΉμ
|
| 507 |
+
with gr.Column(scale=1, elem_classes="input-section"):
|
| 508 |
+
gr.Markdown("### π Input Your Song Details")
|
| 509 |
genre_txt = gr.Textbox(
|
| 510 |
+
label="πΈ Music Genre & Style",
|
| 511 |
+
placeholder="e.g., K-pop bright energetic synth dance electronic...",
|
| 512 |
+
elem_id="genre-input"
|
| 513 |
)
|
| 514 |
lyrics_txt = gr.Textbox(
|
| 515 |
+
label="π Lyrics",
|
| 516 |
+
placeholder="Enter lyrics with section tags: [verse], [chorus], [bridge]...",
|
| 517 |
+
lines=10,
|
| 518 |
+
elem_id="lyrics-input"
|
| 519 |
)
|
| 520 |
|
| 521 |
+
# μ 보 νμ μΉμ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 522 |
with gr.Row():
|
| 523 |
+
with gr.Column(scale=1):
|
| 524 |
+
duration_info = gr.Label(
|
| 525 |
+
label="β±οΈ Estimated Duration",
|
| 526 |
+
elem_classes="info-box"
|
| 527 |
+
)
|
| 528 |
+
with gr.Column(scale=1):
|
| 529 |
+
sections_info = gr.Label(
|
| 530 |
+
label="π Section Analysis",
|
| 531 |
+
elem_classes="info-box"
|
| 532 |
+
)
|
| 533 |
+
|
| 534 |
+
submit_btn = gr.Button(
|
| 535 |
+
"πΌ Generate Music",
|
| 536 |
+
variant="primary",
|
| 537 |
+
elem_id="generate-btn"
|
| 538 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 539 |
|
| 540 |
+
# μΆλ ₯ μΉμ
|
| 541 |
+
with gr.Column(scale=1, elem_classes="output-section"):
|
| 542 |
+
gr.Markdown("### π΅ Generated Music")
|
| 543 |
+
music_out = gr.Audio(
|
| 544 |
+
label="Generated Song",
|
| 545 |
+
elem_id="music-output"
|
| 546 |
+
)
|
| 547 |
+
|
| 548 |
+
# μ§ν μν
|
| 549 |
+
with gr.Box():
|
| 550 |
+
gr.Markdown("### π Generation Status")
|
| 551 |
+
num_segments = gr.Number(
|
| 552 |
+
label="Song Segments",
|
| 553 |
+
value=2,
|
| 554 |
+
interactive=False,
|
| 555 |
+
visible=False
|
| 556 |
+
)
|
| 557 |
+
max_new_tokens = gr.Number(
|
| 558 |
+
label="Tokens",
|
| 559 |
+
value=4000,
|
| 560 |
+
interactive=False,
|
| 561 |
+
visible=False
|
| 562 |
+
)
|
| 563 |
+
|
| 564 |
+
# μμ μΉμ
|
| 565 |
+
with gr.Accordion("π Examples", open=False, elem_classes="examples-section"):
|
| 566 |
+
gr.Examples(
|
| 567 |
+
examples=[
|
| 568 |
+
[
|
| 569 |
+
"female blues airy vocal bright vocal piano sad romantic guitar jazz",
|
| 570 |
+
"""[verse]
|
| 571 |
In the quiet of the evening, shadows start to fall
|
| 572 |
Whispers of the night wind echo through the hall
|
| 573 |
Lost within the silence, I hear your gentle voice
|
|
|
|
| 578 |
With you here beside me, everything's alright
|
| 579 |
Can't imagine life alone, don't want to let you go
|
| 580 |
Stay with me forever, let our love just flow"""
|
| 581 |
+
],
|
| 582 |
+
[
|
| 583 |
+
"K-pop bright energetic synth dance electronic",
|
| 584 |
+
"""[verse]
|
| 585 |
μΈμ κ° λ§μ£Όν λλΉ μμμ
|
| 586 |
|
| 587 |
[chorus]
|
|
|
|
| 591 |
μ΄λμ΄ λ°€μ μ§λ λλ§λ€
|
| 592 |
|
| 593 |
[chorus]
|
| 594 |
+
λ€μ ν λ² λ΄κ² λ§ν΄μ€"""
|
| 595 |
+
]
|
| 596 |
+
],
|
| 597 |
+
inputs=[genre_txt, lyrics_txt]
|
| 598 |
+
)
|
| 599 |
+
|
| 600 |
+
# λμλ§ μΉμ
|
| 601 |
+
with gr.Accordion("βΉοΈ Help & Information", open=False):
|
| 602 |
+
gr.Markdown(
|
| 603 |
+
"""
|
| 604 |
+
### π΅ How to Use
|
| 605 |
+
1. **Enter Genre & Style**: Describe the musical style you want
|
| 606 |
+
2. **Input Lyrics**: Write your lyrics using section tags
|
| 607 |
+
3. **Generate**: Click the Generate button and wait for your music!
|
| 608 |
+
|
| 609 |
+
### π Supported Languages
|
| 610 |
+
- English
|
| 611 |
+
- Korean (νκ΅μ΄)
|
| 612 |
+
- Japanese (ζ₯ζ¬θͺ)
|
| 613 |
+
- Chinese (δΈζ)
|
| 614 |
+
|
| 615 |
+
### β‘ Tips for Best Results
|
| 616 |
+
- Be specific with genre descriptions
|
| 617 |
+
- Include emotion and instrument preferences
|
| 618 |
+
- Properly tag your lyrics sections
|
| 619 |
+
- Include both verse and chorus sections
|
| 620 |
+
"""
|
| 621 |
+
)
|
| 622 |
+
|
| 623 |
+
# μ΄λ²€νΈ νΈλ€λ¬ μ€μ
|
| 624 |
lyrics_txt.change(
|
| 625 |
fn=update_info,
|
| 626 |
inputs=[lyrics_txt],
|