tee342 commited on
Commit
cb22c30
Β·
verified Β·
1 Parent(s): 3c2d581

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +129 -12
app.py CHANGED
@@ -274,7 +274,6 @@ def process_audio(audio_file, selected_effects, isolate_vocals, preset_name, exp
274
  "Normalize": apply_normalize,
275
  "Noise Gate": lambda x: apply_noise_gate(x, threshold=-50.0),
276
  "Limiter": lambda x: apply_limiter(x, limit_dB=-1),
277
- "Flanger": lambda x: apply_phaser(x, rate=1.2, depth=0.9, mix=0.7),
278
  "Bitcrusher": lambda x: apply_bitcrush(x, bit_depth=8),
279
  "Auto Gain": lambda x: apply_auto_gain(x, target_dB=-20),
280
  "Vocal Distortion": lambda x: apply_vocal_distortion(x),
@@ -413,7 +412,6 @@ def auto_tune_vocal(audio_path, target_key="C"):
413
  def visualize_spectrum(audio_path):
414
  y, sr = torchaudio.load(audio_path)
415
  y_np = y.numpy().flatten()
416
-
417
  stft = librosa.stft(y_np)
418
  db = librosa.amplitude_to_db(abs(stft))
419
 
@@ -429,12 +427,128 @@ def visualize_spectrum(audio_path):
429
  return Image.open(buf)
430
 
431
  # === Main UI – With Studio Pulse Branding ===
432
- with gr.Blocks(title="Studio Pulse AI", css="style.css") as demo:
433
- # Header with logo and tagline
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
434
  gr.HTML('''
435
- <div class="studio-header">
436
  <img src="https://via.placeholder.com/400x100/1e1e1e/1db954?text=Studio+Pulse+AI" width="400" />
437
- <h3>Where Your Audio Meets Intelligence</h3>
438
  </div>
439
  ''')
440
 
@@ -449,7 +563,7 @@ with gr.Blocks(title="Studio Pulse AI", css="style.css") as demo:
449
  preset_dropdown = gr.Dropdown(choices=preset_names, label="Select Preset", value=preset_names[0])
450
  export_format = gr.Dropdown(choices=["MP3", "WAV"], label="Export Format", value="MP3")
451
  isolate_vocals = gr.Checkbox(label="Isolate Vocals After Effects")
452
- submit_btn = gr.Button("Process Audio")
453
  with gr.Column(min_width=300):
454
  output_audio = gr.Audio(label="Processed Audio", type="filepath")
455
  waveform_img = gr.Image(label="Waveform Preview")
@@ -463,7 +577,7 @@ with gr.Blocks(title="Studio Pulse AI", css="style.css") as demo:
463
  output_audio, waveform_img, session_log_out, genre_out, status_box
464
  ])
465
 
466
- # --- AI Mastering Chain Tab – Now Fully Defined ===
467
  with gr.Tab("🎧 AI Mastering Chain"):
468
  gr.Interface(
469
  fn=ai_mastering_chain,
@@ -557,7 +671,7 @@ with gr.Blocks(title="Studio Pulse AI", css="style.css") as demo:
557
  description="Correct vocal pitch automatically"
558
  )
559
 
560
- # --- Real-Time Spectrum Analyzer + Live EQ Preview – Added Back ===
561
  with gr.Tab("πŸ“Š Frequency Spectrum"):
562
  gr.Interface(
563
  fn=visualize_spectrum,
@@ -567,7 +681,7 @@ with gr.Blocks(title="Studio Pulse AI", css="style.css") as demo:
567
  description="See the frequency breakdown of your audio"
568
  )
569
 
570
- # --- Loudness Graph Tab – Added Back ===
571
  with gr.Tab("πŸ“ˆ Loudness Graph"):
572
  gr.Interface(
573
  fn=match_loudness,
@@ -607,7 +721,8 @@ with gr.Blocks(title="Studio Pulse AI", css="style.css") as demo:
607
  ],
608
  outputs=gr.File(label="Project File (.aiproj)"),
609
  title="Save Everything Together",
610
- description="Save your session, effects, and settings in one file to reuse later."
 
611
  )
612
 
613
  gr.Interface(
@@ -632,7 +747,9 @@ with gr.Blocks(title="Studio Pulse AI", css="style.css") as demo:
632
  ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=R+B", "R&B"),
633
  ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=Soul", "Soul"),
634
  ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=Funk", "Funk"),
635
- ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=Jazz", "Jazz")
 
 
636
  ], label="Preset Cards", columns=4, height="auto")
637
 
638
  preset_name_out = gr.Dropdown(choices=preset_names, label="Selected Preset")
 
274
  "Normalize": apply_normalize,
275
  "Noise Gate": lambda x: apply_noise_gate(x, threshold=-50.0),
276
  "Limiter": lambda x: apply_limiter(x, limit_dB=-1),
 
277
  "Bitcrusher": lambda x: apply_bitcrush(x, bit_depth=8),
278
  "Auto Gain": lambda x: apply_auto_gain(x, target_dB=-20),
279
  "Vocal Distortion": lambda x: apply_vocal_distortion(x),
 
412
  def visualize_spectrum(audio_path):
413
  y, sr = torchaudio.load(audio_path)
414
  y_np = y.numpy().flatten()
 
415
  stft = librosa.stft(y_np)
416
  db = librosa.amplitude_to_db(abs(stft))
417
 
 
427
  return Image.open(buf)
428
 
429
  # === Main UI – With Studio Pulse Branding ===
430
+ with gr.Blocks(css="""
431
+ body {
432
+ font-family: 'Segoe UI', Arial, sans-serif;
433
+ background-color: hsl(0 0% 3.9%);
434
+ color: hsl(0 0% 98%);
435
+ padding: 20px;
436
+ }
437
+
438
+ .studio-header {
439
+ text-align: center;
440
+ margin-bottom: 30px;
441
+ animation: float 3s ease-in-out infinite;
442
+ }
443
+
444
+ .studio-header h3 {
445
+ font-size: 18px;
446
+ color: hsl(0 0% 45.1%);
447
+ margin-top: -5px;
448
+ font-style: italic;
449
+ }
450
+
451
+ .gr-interface {
452
+ background-color: hsl(0 0% 10%) !important;
453
+ border-radius: 0.5rem;
454
+ padding: 1rem;
455
+ box-shadow: 0 0 10px hsl(0 0% 14.9% / 0.2);
456
+ border: 1px solid hsl(0 0% 14.9%);
457
+ }
458
+
459
+ .btn-primary {
460
+ background-color: hsl(0 0% 98%) !important;
461
+ color: hsl(0 0% 9%);
462
+ border-radius: 0.5rem;
463
+ padding: 0.75rem 1.5rem;
464
+ font-weight: bold;
465
+ transition: all 0.3s ease;
466
+ }
467
+
468
+ .btn-primary:hover {
469
+ background-color: hsl(0 0% 90%) !important;
470
+ box-shadow: 0 0 10px hsl(0 0% 60% / 0.3);
471
+ }
472
+
473
+ .gr-tabs button {
474
+ font-size: 16px;
475
+ padding: 10px 20px;
476
+ border-radius: 8px;
477
+ background: hsl(0 0% 10%);
478
+ color: white;
479
+ transition: all 0.3s ease;
480
+ }
481
+
482
+ .gr-tabs button:hover {
483
+ background: hsl(120 76% 61%);
484
+ color: black;
485
+ box-shadow: 0 0 10px hsl(120 76% 61% / 0.4);
486
+ }
487
+
488
+ .text-muted-foreground {
489
+ color: hsl(0 0% 45.1%);
490
+ }
491
+
492
+ @keyframes float {
493
+ 0%, 100% { transform: translateY(0); }
494
+ 50% { transform: translateY(-10px); }
495
+ }
496
+
497
+ .float-animation {
498
+ animation: float 3s ease-in-out infinite;
499
+ }
500
+
501
+ input[type="text"], input[type="number"], select, textarea {
502
+ background-color: hsl(0 0% 14.9%);
503
+ color: white;
504
+ border: 1px solid hsl(0 0% 30%);
505
+ border-radius: 0.5rem;
506
+ width: 100%;
507
+ padding: 0.75rem;
508
+ }
509
+
510
+ .gr-checkboxgroup label {
511
+ background: hsl(0 0% 14.9%);
512
+ color: white;
513
+ border: 1px solid hsl(0 0% 30%);
514
+ border-radius: 0.5rem;
515
+ padding: 0.5rem 1rem;
516
+ transition: background 0.3s;
517
+ }
518
+
519
+ .gr-checkboxgroup label:hover {
520
+ background: hsl(0 0% 20%);
521
+ cursor: pointer;
522
+ }
523
+
524
+ .gr-gallery__items > div {
525
+ border-radius: 0.75rem;
526
+ overflow: hidden;
527
+ transition: transform 0.3s ease, box-shadow 0.3s ease;
528
+ }
529
+
530
+ .gr-gallery__items > div:hover {
531
+ transform: scale(1.02);
532
+ box-shadow: 0 0 12px hsl(120 76% 61% / 0.4);
533
+ }
534
+
535
+ .gr-gallery__item-label {
536
+ background: rgba(0, 0, 0, 0.7);
537
+ backdrop-filter: blur(3px);
538
+ color: white;
539
+ font-size: 14px;
540
+ font-weight: bold;
541
+ text-align: center;
542
+ padding: 0.5rem;
543
+ border-radius: 0 0 0.5rem 0.5rem;
544
+ }
545
+ """) as demo:
546
+
547
+ # Header
548
  gr.HTML('''
549
+ <div class="studio-header float-animation">
550
  <img src="https://via.placeholder.com/400x100/1e1e1e/1db954?text=Studio+Pulse+AI" width="400" />
551
+ <h3 class="text-muted-foreground">Where Your Audio Meets Intelligence</h3>
552
  </div>
553
  ''')
554
 
 
563
  preset_dropdown = gr.Dropdown(choices=preset_names, label="Select Preset", value=preset_names[0])
564
  export_format = gr.Dropdown(choices=["MP3", "WAV"], label="Export Format", value="MP3")
565
  isolate_vocals = gr.Checkbox(label="Isolate Vocals After Effects")
566
+ submit_btn = gr.Button("Process Audio", elem_classes=["btn-primary"])
567
  with gr.Column(min_width=300):
568
  output_audio = gr.Audio(label="Processed Audio", type="filepath")
569
  waveform_img = gr.Image(label="Waveform Preview")
 
577
  output_audio, waveform_img, session_log_out, genre_out, status_box
578
  ])
579
 
580
+ # --- AI Mastering Chain Tab ---
581
  with gr.Tab("🎧 AI Mastering Chain"):
582
  gr.Interface(
583
  fn=ai_mastering_chain,
 
671
  description="Correct vocal pitch automatically"
672
  )
673
 
674
+ # --- Frequency Spectrum Tab – Real-time Visualizer ===
675
  with gr.Tab("πŸ“Š Frequency Spectrum"):
676
  gr.Interface(
677
  fn=visualize_spectrum,
 
681
  description="See the frequency breakdown of your audio"
682
  )
683
 
684
+ # --- Loudness Graph Tab – EBU R128 Matching ===
685
  with gr.Tab("πŸ“ˆ Loudness Graph"):
686
  gr.Interface(
687
  fn=match_loudness,
 
721
  ],
722
  outputs=gr.File(label="Project File (.aiproj)"),
723
  title="Save Everything Together",
724
+ description="Save your session, effects, and settings in one file to reuse later.",
725
+ allow_flagging="never"
726
  )
727
 
728
  gr.Interface(
 
747
  ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=R+B", "R&B"),
748
  ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=Soul", "Soul"),
749
  ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=Funk", "Funk"),
750
+ ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=Jazz", "Jazz"),
751
+ ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=Stage+Mode", "Stage Mode"),
752
+ ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=Tube+Saturation", "Tube Saturation")
753
  ], label="Preset Cards", columns=4, height="auto")
754
 
755
  preset_name_out = gr.Dropdown(choices=preset_names, label="Selected Preset")