Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -55,7 +55,7 @@ def apply_reverb(audio):
|
|
| 55 |
return audio.overlay(reverb, position=1000)
|
| 56 |
|
| 57 |
def apply_pitch_shift(audio, semitones=-2):
|
| 58 |
-
new_frame_rate = int(audio.frame_rate * (2 ** (semitones / 12))
|
| 59 |
samples = np.array(audio.get_array_of_samples())
|
| 60 |
resampled = np.interp(np.arange(0, len(samples), 2 ** (semitones / 12)), np.arange(len(samples)), samples).astype(np.int16)
|
| 61 |
return AudioSegment(resampled.tobytes(), frame_rate=new_frame_rate, sample_width=audio.sample_width, channels=audio.channels)
|
|
@@ -490,11 +490,11 @@ def apply_effects_to_stem(stem_path, selected_effects):
|
|
| 490 |
print(f"Error applying effects: {e}")
|
| 491 |
return None
|
| 492 |
|
| 493 |
-
# === Remix Mode β
|
| 494 |
def remix_individual_stem(stem_path, effects):
|
| 495 |
return apply_effects_to_stem(stem_path, effects)
|
| 496 |
|
| 497 |
-
#
|
| 498 |
with gr.Blocks(css="""
|
| 499 |
body {
|
| 500 |
font-family: 'Segoe UI', sans-serif;
|
|
@@ -521,14 +521,6 @@ with gr.Blocks(css="""
|
|
| 521 |
50% { transform: translateY(-10px); }
|
| 522 |
}
|
| 523 |
|
| 524 |
-
.gr-box, .gr-interface {
|
| 525 |
-
background-color: #161b22 !important;
|
| 526 |
-
border-radius: 12px;
|
| 527 |
-
padding: 15px;
|
| 528 |
-
box-shadow: 0 0 10px #1f7bbd44;
|
| 529 |
-
transition: all 0.3s ease;
|
| 530 |
-
}
|
| 531 |
-
|
| 532 |
.gr-button {
|
| 533 |
background-color: #2563eb !important;
|
| 534 |
color: white !important;
|
|
@@ -578,16 +570,6 @@ with gr.Blocks(css="""
|
|
| 578 |
box-shadow: 0 0 12px #2563eb44;
|
| 579 |
}
|
| 580 |
|
| 581 |
-
.gr-gallery__item-label {
|
| 582 |
-
background: rgba(0, 0, 0, 0.7);
|
| 583 |
-
backdrop-filter: blur(3px);
|
| 584 |
-
border-radius: 0 0 12px 12px;
|
| 585 |
-
padding: 10px;
|
| 586 |
-
font-size: 14px;
|
| 587 |
-
font-weight: bold;
|
| 588 |
-
text-align: center;
|
| 589 |
-
}
|
| 590 |
-
|
| 591 |
@media (max-width: 768px) {
|
| 592 |
.gr-column {
|
| 593 |
min-width: 100%;
|
|
@@ -607,7 +589,7 @@ with gr.Blocks(css="""
|
|
| 607 |
}
|
| 608 |
""") as demo:
|
| 609 |
|
| 610 |
-
# Header
|
| 611 |
gr.HTML('''
|
| 612 |
<div class="studio-header">
|
| 613 |
<img src="logo.png" width="400" />
|
|
@@ -658,7 +640,7 @@ with gr.Blocks(css="""
|
|
| 658 |
allow_flagging="never"
|
| 659 |
)
|
| 660 |
|
| 661 |
-
# --- Remix Mode β
|
| 662 |
with gr.Tab("π Remix Mode"):
|
| 663 |
with gr.Row():
|
| 664 |
with gr.Column(min_width=200):
|
|
@@ -675,6 +657,7 @@ with gr.Blocks(css="""
|
|
| 675 |
split_button.click(fn=stem_split, inputs=[input_audio_remix], outputs=stem_outputs)
|
| 676 |
|
| 677 |
gr.Markdown("#### Apply Effects to Individual Stems")
|
|
|
|
| 678 |
with gr.Row():
|
| 679 |
with gr.Column(min_width=200):
|
| 680 |
vocals_path = gr.File(label="Vocals Track")
|
|
@@ -686,10 +669,9 @@ with gr.Blocks(css="""
|
|
| 686 |
"Reverb",
|
| 687 |
"Vocal Distortion",
|
| 688 |
"Auto Gain"
|
| 689 |
-
])
|
| 690 |
btn_vocals = gr.Button("Process Vocals")
|
| 691 |
output_vocals = gr.Audio(label="Processed Vocals", type="filepath")
|
| 692 |
-
|
| 693 |
btn_vocals.click(fn=remix_individual_stem, inputs=[vocals_path, vocal_effects], outputs=output_vocals)
|
| 694 |
|
| 695 |
with gr.Column(min_width=200):
|
|
@@ -700,10 +682,9 @@ with gr.Blocks(css="""
|
|
| 700 |
"Limiter",
|
| 701 |
"Bitcrusher",
|
| 702 |
"Stereo Widening"
|
| 703 |
-
])
|
| 704 |
btn_drums = gr.Button("Process Drums")
|
| 705 |
output_drums = gr.Audio(label="Processed Drums", type="filepath")
|
| 706 |
-
|
| 707 |
btn_drums.click(fn=remix_individual_stem, inputs=[drums_path, drum_effects], outputs=output_drums)
|
| 708 |
|
| 709 |
with gr.Column(min_width=200):
|
|
@@ -712,10 +693,9 @@ with gr.Blocks(css="""
|
|
| 712 |
"Bass Boost",
|
| 713 |
"Saturation (Tape)",
|
| 714 |
"Limiter"
|
| 715 |
-
])
|
| 716 |
btn_bass = gr.Button("Process Bass")
|
| 717 |
output_bass = gr.Audio(label="Processed Bass", type="filepath")
|
| 718 |
-
|
| 719 |
btn_bass.click(fn=remix_individual_stem, inputs=[bass_path, bass_effects], outputs=output_bass)
|
| 720 |
|
| 721 |
with gr.Column(min_width=200):
|
|
@@ -724,10 +704,9 @@ with gr.Blocks(css="""
|
|
| 724 |
"Noise Gate",
|
| 725 |
"Reverb",
|
| 726 |
"Treble Boost"
|
| 727 |
-
])
|
| 728 |
btn_other = gr.Button("Process Other")
|
| 729 |
output_other = gr.Audio(label="Processed Other", type="filepath")
|
| 730 |
-
|
| 731 |
btn_other.click(fn=remix_individual_stem, inputs=[other_path, other_effects], outputs=output_other)
|
| 732 |
|
| 733 |
# --- Harmonic Saturation / Exciter β Now Included ===
|
|
|
|
| 55 |
return audio.overlay(reverb, position=1000)
|
| 56 |
|
| 57 |
def apply_pitch_shift(audio, semitones=-2):
|
| 58 |
+
new_frame_rate = int(audio.frame_rate * (2 ** (semitones / 12))) # β
Fixed parentheses
|
| 59 |
samples = np.array(audio.get_array_of_samples())
|
| 60 |
resampled = np.interp(np.arange(0, len(samples), 2 ** (semitones / 12)), np.arange(len(samples)), samples).astype(np.int16)
|
| 61 |
return AudioSegment(resampled.tobytes(), frame_rate=new_frame_rate, sample_width=audio.sample_width, channels=audio.channels)
|
|
|
|
| 490 |
print(f"Error applying effects: {e}")
|
| 491 |
return None
|
| 492 |
|
| 493 |
+
# === Remix Mode UI β Now Fixed & Working ===
|
| 494 |
def remix_individual_stem(stem_path, effects):
|
| 495 |
return apply_effects_to_stem(stem_path, effects)
|
| 496 |
|
| 497 |
+
# === Main UI β With Studio Pulse Branding ===
|
| 498 |
with gr.Blocks(css="""
|
| 499 |
body {
|
| 500 |
font-family: 'Segoe UI', sans-serif;
|
|
|
|
| 521 |
50% { transform: translateY(-10px); }
|
| 522 |
}
|
| 523 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 524 |
.gr-button {
|
| 525 |
background-color: #2563eb !important;
|
| 526 |
color: white !important;
|
|
|
|
| 570 |
box-shadow: 0 0 12px #2563eb44;
|
| 571 |
}
|
| 572 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 573 |
@media (max-width: 768px) {
|
| 574 |
.gr-column {
|
| 575 |
min-width: 100%;
|
|
|
|
| 589 |
}
|
| 590 |
""") as demo:
|
| 591 |
|
| 592 |
+
# Header
|
| 593 |
gr.HTML('''
|
| 594 |
<div class="studio-header">
|
| 595 |
<img src="logo.png" width="400" />
|
|
|
|
| 640 |
allow_flagging="never"
|
| 641 |
)
|
| 642 |
|
| 643 |
+
# --- Remix Mode β Apply Effects to Each Stem ===
|
| 644 |
with gr.Tab("π Remix Mode"):
|
| 645 |
with gr.Row():
|
| 646 |
with gr.Column(min_width=200):
|
|
|
|
| 657 |
split_button.click(fn=stem_split, inputs=[input_audio_remix], outputs=stem_outputs)
|
| 658 |
|
| 659 |
gr.Markdown("#### Apply Effects to Individual Stems")
|
| 660 |
+
|
| 661 |
with gr.Row():
|
| 662 |
with gr.Column(min_width=200):
|
| 663 |
vocals_path = gr.File(label="Vocals Track")
|
|
|
|
| 669 |
"Reverb",
|
| 670 |
"Vocal Distortion",
|
| 671 |
"Auto Gain"
|
| 672 |
+
], label="Vocal Effects")
|
| 673 |
btn_vocals = gr.Button("Process Vocals")
|
| 674 |
output_vocals = gr.Audio(label="Processed Vocals", type="filepath")
|
|
|
|
| 675 |
btn_vocals.click(fn=remix_individual_stem, inputs=[vocals_path, vocal_effects], outputs=output_vocals)
|
| 676 |
|
| 677 |
with gr.Column(min_width=200):
|
|
|
|
| 682 |
"Limiter",
|
| 683 |
"Bitcrusher",
|
| 684 |
"Stereo Widening"
|
| 685 |
+
], label="Drum Effects")
|
| 686 |
btn_drums = gr.Button("Process Drums")
|
| 687 |
output_drums = gr.Audio(label="Processed Drums", type="filepath")
|
|
|
|
| 688 |
btn_drums.click(fn=remix_individual_stem, inputs=[drums_path, drum_effects], outputs=output_drums)
|
| 689 |
|
| 690 |
with gr.Column(min_width=200):
|
|
|
|
| 693 |
"Bass Boost",
|
| 694 |
"Saturation (Tape)",
|
| 695 |
"Limiter"
|
| 696 |
+
], label="Bass Effects")
|
| 697 |
btn_bass = gr.Button("Process Bass")
|
| 698 |
output_bass = gr.Audio(label="Processed Bass", type="filepath")
|
|
|
|
| 699 |
btn_bass.click(fn=remix_individual_stem, inputs=[bass_path, bass_effects], outputs=output_bass)
|
| 700 |
|
| 701 |
with gr.Column(min_width=200):
|
|
|
|
| 704 |
"Noise Gate",
|
| 705 |
"Reverb",
|
| 706 |
"Treble Boost"
|
| 707 |
+
], label="Other Effects")
|
| 708 |
btn_other = gr.Button("Process Other")
|
| 709 |
output_other = gr.Audio(label="Processed Other", type="filepath")
|
|
|
|
| 710 |
btn_other.click(fn=remix_individual_stem, inputs=[other_path, other_effects], outputs=output_other)
|
| 711 |
|
| 712 |
# --- Harmonic Saturation / Exciter β Now Included ===
|