Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,9 +18,8 @@ import librosa
|
|
| 18 |
import warnings
|
| 19 |
from faster_whisper import WhisperModel
|
| 20 |
from TTS.api import TTS
|
| 21 |
-
import base64
|
| 22 |
import pickle
|
| 23 |
-
import
|
| 24 |
|
| 25 |
# Suppress warnings
|
| 26 |
warnings.filterwarnings("ignore")
|
|
@@ -303,23 +302,22 @@ preset_choices = {
|
|
| 303 |
preset_names = list(preset_choices.keys())
|
| 304 |
|
| 305 |
# === Preset Cards Gallery ===
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
return name, preset_choices[name]
|
| 317 |
|
| 318 |
# === Logo Embedding (Base64 or file) ===
|
| 319 |
def get_logo():
|
| 320 |
-
return "
|
| 321 |
|
| 322 |
-
# === Main UI ===
|
| 323 |
with gr.Blocks(title="AI Audio Studio", css="style.css") as demo:
|
| 324 |
gr.HTML(f'<div class="studio-header"><img src="{get_logo()}" width="400" /></div>')
|
| 325 |
gr.Markdown("### Upload, edit, export β powered by AI!")
|
|
@@ -378,25 +376,18 @@ with gr.Blocks(title="AI Audio Studio", css="style.css") as demo:
|
|
| 378 |
# --- Preset Cards Gallery ===
|
| 379 |
with gr.Tab("π Preset Gallery"):
|
| 380 |
gr.Markdown("### Select a preset visually")
|
| 381 |
-
|
| 382 |
-
preset_images = [
|
| 383 |
-
("https://via.placeholder.com/150x100?text=Pop", "Pop"),
|
| 384 |
-
("https://via.placeholder.com/150x100?text=EDM", "EDM"),
|
| 385 |
-
("https://via.placeholder.com/150x100?text=Rock", "Rock"),
|
| 386 |
-
("https://via.placeholder.com/150x100?text=Hip-Hop", "Hip-Hop"),
|
| 387 |
-
("https://via.placeholder.com/150x100?text=Acoustic", "Acoustic"),
|
| 388 |
-
("https://via.placeholder.com/150x100?text=Tube", "Tube"),
|
| 389 |
-
("https://via.placeholder.com/150x100?text=Stage+Mode", "Stage Mode"),
|
| 390 |
-
("https://via.placeholder.com/150x100?text=Vocal+Distortion", "Vocal Distortion")
|
| 391 |
-
]
|
| 392 |
-
|
| 393 |
-
preset_gallery = gr.Gallery(value=preset_images, label="Preset Cards", columns=4, height="auto")
|
| 394 |
preset_name_out = gr.Dropdown(choices=preset_names, label="Selected Preset")
|
| 395 |
preset_effects_out = gr.CheckboxGroup(choices=list(preset_choices.keys())[0:], label="Effects")
|
| 396 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
preset_gallery.select(fn=load_preset_by_card, inputs=[], outputs=[preset_name_out, preset_effects_out])
|
| 398 |
|
| 399 |
-
# --- Vocal Doubler / Harmonizer ===
|
| 400 |
with gr.Tab("π§ Vocal Doubler / Harmonizer"):
|
| 401 |
gr.Interface(
|
| 402 |
fn=lambda x: apply_harmony(x),
|
|
@@ -429,7 +420,7 @@ with gr.Blocks(title="AI Audio Studio", css="style.css") as demo:
|
|
| 429 |
fn=batch_process_audio,
|
| 430 |
inputs=[
|
| 431 |
gr.File(label="Upload Multiple Files", file_count="multiple"),
|
| 432 |
-
gr.CheckboxGroup(choices=
|
| 433 |
gr.Checkbox(label="Isolate Vocals After Effects"),
|
| 434 |
gr.Dropdown(choices=preset_names, label="Select Preset", value=preset_names[0]),
|
| 435 |
gr.Dropdown(choices=["MP3", "WAV"], label="Export Format", value="MP3")
|
|
@@ -498,41 +489,7 @@ with gr.Blocks(title="AI Audio Studio", css="style.css") as demo:
|
|
| 498 |
description="Ensure consistent volume using EBU R128 standard"
|
| 499 |
)
|
| 500 |
|
| 501 |
-
# --- Stereo Imaging Tool ===
|
| 502 |
-
def stereo_imaging(audio, mid_side_balance=0.5, stereo_spread=1.0):
|
| 503 |
-
samples, sr = audiosegment_to_array(AudioSegment.from_file(audio))
|
| 504 |
-
return array_to_audiosegment(samples, sr)
|
| 505 |
-
|
| 506 |
-
with gr.Tab("π Stereo Imaging"):
|
| 507 |
-
gr.Interface(
|
| 508 |
-
fn=stereo_imaging,
|
| 509 |
-
inputs=[
|
| 510 |
-
gr.Audio(label="Upload Track", type="filepath"),
|
| 511 |
-
gr.Slider(minimum=0.0, maximum=1.0, value=0.5, label="Mid-Side Balance"),
|
| 512 |
-
gr.Slider(minimum=0.0, maximum=2.0, value=1.0, label="Stereo Spread")
|
| 513 |
-
],
|
| 514 |
-
outputs=gr.Audio(label="Imaged Output", type="filepath"),
|
| 515 |
-
title="Adjust Stereo Field",
|
| 516 |
-
description="Control mid-side balance and widen stereo spread."
|
| 517 |
-
)
|
| 518 |
-
|
| 519 |
# --- Save/Load Mix Session (.aiproj) ===
|
| 520 |
-
def save_project(audio, preset, effects):
|
| 521 |
-
project_data = {
|
| 522 |
-
"audio": AudioSegment.from_file(audio).raw_data,
|
| 523 |
-
"preset": preset,
|
| 524 |
-
"effects": effects
|
| 525 |
-
}
|
| 526 |
-
out_path = os.path.join(tempfile.gettempdir(), "project.aiproj")
|
| 527 |
-
with open(out_path, "wb") as f:
|
| 528 |
-
pickle.dump(project_data, f)
|
| 529 |
-
return out_path
|
| 530 |
-
|
| 531 |
-
def load_project(project_file):
|
| 532 |
-
with open(project_file.name, "rb") as f:
|
| 533 |
-
data = pickle.load(f)
|
| 534 |
-
return data["preset"], data["effects"]
|
| 535 |
-
|
| 536 |
with gr.Tab("π Save/Load Project"):
|
| 537 |
gr.Interface(
|
| 538 |
fn=save_project,
|
|
|
|
| 18 |
import warnings
|
| 19 |
from faster_whisper import WhisperModel
|
| 20 |
from TTS.api import TTS
|
|
|
|
| 21 |
import pickle
|
| 22 |
+
import base64
|
| 23 |
|
| 24 |
# Suppress warnings
|
| 25 |
warnings.filterwarnings("ignore")
|
|
|
|
| 302 |
preset_names = list(preset_choices.keys())
|
| 303 |
|
| 304 |
# === Preset Cards Gallery ===
|
| 305 |
+
preset_cards = [
|
| 306 |
+
("images/pop_card.png", "Pop"),
|
| 307 |
+
("images/edm_card.png", "EDM"),
|
| 308 |
+
("images/rock_card.png", "Rock"),
|
| 309 |
+
("images/hiphop_card.png", "Hip-Hop"),
|
| 310 |
+
("images/acoustic_card.png", "Acoustic"),
|
| 311 |
+
("images/stage_mode_card.png", "Stage Mode"),
|
| 312 |
+
("images/vocal_distortion_card.png", "Vocal Distortion"),
|
| 313 |
+
("images/tube_saturation_card.png", "Tube Saturation")
|
| 314 |
+
]
|
|
|
|
| 315 |
|
| 316 |
# === Logo Embedding (Base64 or file) ===
|
| 317 |
def get_logo():
|
| 318 |
+
return "logo.png"
|
| 319 |
|
| 320 |
+
# === Main UI ===
|
| 321 |
with gr.Blocks(title="AI Audio Studio", css="style.css") as demo:
|
| 322 |
gr.HTML(f'<div class="studio-header"><img src="{get_logo()}" width="400" /></div>')
|
| 323 |
gr.Markdown("### Upload, edit, export β powered by AI!")
|
|
|
|
| 376 |
# --- Preset Cards Gallery ===
|
| 377 |
with gr.Tab("π Preset Gallery"):
|
| 378 |
gr.Markdown("### Select a preset visually")
|
| 379 |
+
preset_gallery = gr.Gallery(value=preset_cards, label="Preset Cards", columns=4, height="auto")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 380 |
preset_name_out = gr.Dropdown(choices=preset_names, label="Selected Preset")
|
| 381 |
preset_effects_out = gr.CheckboxGroup(choices=list(preset_choices.keys())[0:], label="Effects")
|
| 382 |
|
| 383 |
+
def load_preset_by_card(evt: gr.SelectData):
|
| 384 |
+
index = evt.index % len(preset_names)
|
| 385 |
+
name = preset_names[index]
|
| 386 |
+
return name, preset_choices[name]
|
| 387 |
+
|
| 388 |
preset_gallery.select(fn=load_preset_by_card, inputs=[], outputs=[preset_name_out, preset_effects_out])
|
| 389 |
|
| 390 |
+
# --- Vocal Doubler / Harmonizer ===
|
| 391 |
with gr.Tab("π§ Vocal Doubler / Harmonizer"):
|
| 392 |
gr.Interface(
|
| 393 |
fn=lambda x: apply_harmony(x),
|
|
|
|
| 420 |
fn=batch_process_audio,
|
| 421 |
inputs=[
|
| 422 |
gr.File(label="Upload Multiple Files", file_count="multiple"),
|
| 423 |
+
gr.CheckboxGroup(choices=preset_choices["Default"], label="Apply Effects in Order"),
|
| 424 |
gr.Checkbox(label="Isolate Vocals After Effects"),
|
| 425 |
gr.Dropdown(choices=preset_names, label="Select Preset", value=preset_names[0]),
|
| 426 |
gr.Dropdown(choices=["MP3", "WAV"], label="Export Format", value="MP3")
|
|
|
|
| 489 |
description="Ensure consistent volume using EBU R128 standard"
|
| 490 |
)
|
| 491 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 492 |
# --- Save/Load Mix Session (.aiproj) ===
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 493 |
with gr.Tab("π Save/Load Project"):
|
| 494 |
gr.Interface(
|
| 495 |
fn=save_project,
|