tee342 commited on
Commit
de2576e
Β·
verified Β·
1 Parent(s): a6ebcc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -51
app.py CHANGED
@@ -137,25 +137,25 @@ def match_loudness(audio_path, target_lufs=-14.0):
137
  # === Auto-EQ per Genre – With New Genres Added ===
138
  def auto_eq(audio, genre="Pop"):
139
  eq_map = {
140
- "Pop": [(200, 500, -3), (2000, 4000, +4)], # Cut muddiness, boost vocals
141
- "EDM": [(60, 250, +6), (8000, 12000, +3)], # Maximize bass & sparkle
142
- "Rock": [(1000, 3000, +4), (7000, 10000, -3)], # Punchy mids, reduce sibilance
143
- "Hip-Hop": [(20, 100, +6), (7000, 10000, -4)], # Deep lows, smooth highs
144
- "Acoustic": [(100, 300, -3), (4000, 8000, +2)], # Natural tone
145
- "Metal": [(100, 500, -4), (2000, 5000, +6), (7000, 12000, -3)], # Clear low-mids, crisp highs
146
- "Trap": [(80, 120, +6), (3000, 6000, -4)], # Sub-bass boost, cut harsh highs
147
- "LoFi": [(20, 200, +3), (1000, 3000, -2)], # Warmth, soft mids
148
- "Jazz": [(100, 400, +2), (1500, 3000, +1)], # Smooth midrange
149
- "Classical": [(200, 1000, +1), (3000, 6000, +2)], # Balanced orchestral EQ
150
- "Chillhop": [(50, 200, +3), (2000, 5000, +1)], # Laid-back warmth
151
- "Ambient": [(100, 500, +4), (6000, 12000, +2)], # Spacey atmosphere
152
- "Jazz Piano": [(100, 1000, +3), (2000, 5000, +2)], # Rich piano tone
153
- "Trap EDM": [(60, 120, +6), (2000, 5000, -3)], # Heavy sub + clean highs
154
- "Indie Rock": [(150, 400, +2), (2000, 5000, +3)], # Crisp guitars
155
- "Lo-Fi Jazz": [(80, 200, +3), (2000, 4000, +1)], # Cozy jazz warmth
156
- "R&B": [(100, 300, +4), (2000, 4000, +3)], # Full vocals
157
- "Soul": [(80, 200, +3), (1500, 3500, +4)], # Emotive vocal clarity
158
- "Funk": [(80, 200, +5), (1000, 3000, +3)], # Tight low end
159
  "Default": []
160
  }
161
 
@@ -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),
@@ -362,7 +361,7 @@ preset_choices = {
362
  "🌫 ASMR Vocal": ["Auto Gain", "Low-Pass Filter (3000Hz)", "Noise Gate"],
363
  "🎼 Stage Mode": ["Reverb", "Bass Boost", "Limiter"],
364
  "🎡 Auto-Tune Style": ["Pitch Shift (+1 semitone)", "Normalize", "Treble Boost"],
365
- "🎷 Jazz Vocal": ["Bass Boost (-200-400Hz)", "Treble Boost (2000-4000Hz)", "Normalize"],
366
  "🎹 Jazz Piano": ["Treble Boost (4000-6000Hz)", "Normalize", "Stereo Widening"],
367
  "🎻 Classical Strings": ["Bass Boost (100-500Hz)", "Treble Boost (3000-6000Hz)", "Reverb"],
368
  "β˜• Chillhop": ["Noise Gate", "Treble Boost (-3000Hz)", "Reverb"],
@@ -371,7 +370,7 @@ preset_choices = {
371
  "πŸ’ƒ Soul Vocal": ["Noise Reduction", "Bass Boost (80-200Hz)", "Treble Boost (1500-3500Hz)"],
372
  "πŸ•Ί Funk Groove": ["Bass Boost (80-200Hz)", "Treble Boost (1000-3000Hz)", "Stereo Widening"],
373
  "🎹 Jazz Piano Solo": ["Treble Boost (2000-5000Hz)", "Normalize", "Stage Mode"],
374
- "🎢 Trap EDM": ["Bass Boost (60-120Hz)", "Treble Boost (2000-5000Hz)", "Limiter"],
375
  "🎸 Indie Rock": ["Bass Boost (150-400Hz)", "Treble Boost (2000-5000Hz)", "Compress Dynamic Range"]
376
  }
377
 
@@ -427,9 +426,9 @@ def visualize_spectrum(audio_path):
427
  buf.seek(0)
428
  return Image.open(buf)
429
 
430
- # === Main UI ===
431
- with gr.Blocks(title="AI Audio Studio", css="style.css") as demo:
432
- gr.HTML('<div class="studio-header"><img src="logo.png" width="400" /></div>')
433
  gr.Markdown("### Upload, edit, export β€” powered by AI!")
434
 
435
  with gr.Tab("🎡 Single File Studio"):
@@ -463,7 +462,7 @@ with gr.Blocks(title="AI Audio Studio", css="style.css") as demo:
463
  gr.Dropdown(choices=["Pop", "EDM", "Rock", "Hip-Hop", "Acoustic", "Metal", "Trap", "LoFi",
464
  "Jazz", "Classical", "Chillhop", "Ambient", "Jazz Piano", "Trap EDM",
465
  "Indie Rock", "Lo-Fi Jazz", "R&B", "Soul", "Funk"],
466
- label="Genre", value="Pop"),
467
  gr.Slider(minimum=-24, maximum=-6, value=-14, label="Target LUFS")
468
  ],
469
  outputs=gr.Audio(label="Mastered Output", type="filepath"),
@@ -489,7 +488,7 @@ with gr.Blocks(title="AI Audio Studio", css="style.css") as demo:
489
  clear_btn=None
490
  )
491
 
492
- # --- Harmonic Saturation / Exciter ===
493
  with gr.Tab("🧬 Harmonic Saturation"):
494
  gr.Interface(
495
  fn=harmonic_saturation,
@@ -586,16 +585,7 @@ with gr.Blocks(title="AI Audio Studio", css="style.css") as demo:
586
  def load_project(project_file):
587
  with open(project_file.name, "rb") as f:
588
  data = pickle.load(f)
589
- return (
590
- array_to_audiosegment(data["audio"], 44100),
591
- array_to_audiosegment(data["audio"], 44100),
592
- array_to_audiosegment(data["audio"], 44100),
593
- array_to_audiosegment(data["audio"], 44100),
594
- data["preset"],
595
- data["effects"],
596
- data["effects"],
597
- data["effects"]
598
- )
599
 
600
  with gr.Tab("πŸ“ Save/Load Project"):
601
  gr.Interface(
@@ -615,13 +605,7 @@ with gr.Blocks(title="AI Audio Studio", css="style.css") as demo:
615
  fn=load_project,
616
  inputs=gr.File(label="Upload .aiproj File"),
617
  outputs=[
618
- gr.File(label="Loaded Vocals"),
619
- gr.File(label="Loaded Drums"),
620
- gr.File(label="Loaded Bass"),
621
- gr.File(label="Loaded Other"),
622
  gr.Dropdown(choices=preset_names, label="Loaded Preset"),
623
- gr.CheckboxGroup(choices=preset_choices["Default"], label="Loaded Effects"),
624
- gr.CheckboxGroup(choices=preset_choices["Default"], label="Loaded Effects"),
625
  gr.CheckboxGroup(choices=preset_choices["Default"], label="Loaded Effects")
626
  ],
627
  title="Resume Last Project",
@@ -640,23 +624,19 @@ with gr.Blocks(title="AI Audio Studio", css="style.css") as demo:
640
  ("images/stage_mode_card.png", "Stage Mode"),
641
  ("images/vocal_distortion_card.png", "Vocal Distortion"),
642
  ("images/tube_saturation_card.png", "Tube Saturation"),
643
- ("images/jazz_card.png", "Jazz"),
644
- ("images/classical_card.png", "Classical"),
645
- ("images/chillhop_card.png", "Chillhop"),
646
- ("images/ambient_card.png", "Ambient"),
647
  ("images/rnb_card.png", "R&B"),
648
  ("images/soul_card.png", "Soul"),
649
- ("images/funk_card.png", "Funk")
 
650
  ], label="Preset Cards", columns=4, height="auto")
651
 
652
  preset_name_out = gr.Dropdown(choices=preset_names, label="Selected Preset")
653
- preset_effects_out = gr.CheckboxGroup(choices=list(preset_choices.keys())[0:], label="Effects")
654
 
655
  def load_preset_by_card(evt: gr.SelectData):
656
  index = evt.index % len(preset_names)
657
  name = preset_names[index]
658
- effects = preset_choices[name]
659
- return name, effects
660
 
661
  preset_gallery.select(fn=load_preset_by_card, inputs=[], outputs=[preset_name_out, preset_effects_out])
662
 
 
137
  # === Auto-EQ per Genre – With New Genres Added ===
138
  def auto_eq(audio, genre="Pop"):
139
  eq_map = {
140
+ "Pop": [(200, 500, -3), (2000, 4000, +4)],
141
+ "EDM": [(60, 250, +6), (8000, 12000, +3)],
142
+ "Rock": [(1000, 3000, +4), (7000, 10000, -3)],
143
+ "Hip-Hop": [(20, 100, +6), (7000, 10000, -4)],
144
+ "Acoustic": [(100, 300, -3), (4000, 8000, +2)],
145
+ "Metal": [(100, 500, -4), (2000, 5000, +6), (7000, 12000, -3)],
146
+ "Trap": [(80, 120, +6), (3000, 6000, -4)],
147
+ "LoFi": [(20, 200, +3), (1000, 3000, -2)],
148
+ "Jazz": [(100, 400, +2), (1500, 3000, +1)],
149
+ "Classical": [(200, 1000, +1), (3000, 6000, +2)],
150
+ "Chillhop": [(50, 200, +3), (2000, 5000, +1)],
151
+ "Ambient": [(100, 500, +4), (6000, 12000, +2)],
152
+ "Jazz Piano": [(100, 1000, +3), (2000, 5000, +2)],
153
+ "Trap EDM": [(60, 120, +6), (2000, 5000, -3)],
154
+ "Indie Rock": [(150, 400, +2), (2000, 5000, +3)],
155
+ "Lo-Fi Jazz": [(80, 200, +3), (2000, 4000, -1)],
156
+ "R&B": [(100, 300, +4), (2000, 4000, +3)],
157
+ "Soul": [(80, 200, +3), (1500, 3500, +4)],
158
+ "Funk": [(80, 200, +5), (1000, 3000, +3)],
159
  "Default": []
160
  }
161
 
 
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),
 
361
  "🌫 ASMR Vocal": ["Auto Gain", "Low-Pass Filter (3000Hz)", "Noise Gate"],
362
  "🎼 Stage Mode": ["Reverb", "Bass Boost", "Limiter"],
363
  "🎡 Auto-Tune Style": ["Pitch Shift (+1 semitone)", "Normalize", "Treble Boost"],
364
+ "🎷 Jazz Vocal": ["Bass Boost (-200-400Hz)", "Treble Boost (-3000Hz)", "Normalize"],
365
  "🎹 Jazz Piano": ["Treble Boost (4000-6000Hz)", "Normalize", "Stereo Widening"],
366
  "🎻 Classical Strings": ["Bass Boost (100-500Hz)", "Treble Boost (3000-6000Hz)", "Reverb"],
367
  "β˜• Chillhop": ["Noise Gate", "Treble Boost (-3000Hz)", "Reverb"],
 
370
  "πŸ’ƒ Soul Vocal": ["Noise Reduction", "Bass Boost (80-200Hz)", "Treble Boost (1500-3500Hz)"],
371
  "πŸ•Ί Funk Groove": ["Bass Boost (80-200Hz)", "Treble Boost (1000-3000Hz)", "Stereo Widening"],
372
  "🎹 Jazz Piano Solo": ["Treble Boost (2000-5000Hz)", "Normalize", "Stage Mode"],
373
+ "🎸 Trap EDM": ["Bass Boost (60-120Hz)", "Treble Boost (2000-5000Hz)", "Limiter"],
374
  "🎸 Indie Rock": ["Bass Boost (150-400Hz)", "Treble Boost (2000-5000Hz)", "Compress Dynamic Range"]
375
  }
376
 
 
426
  buf.seek(0)
427
  return Image.open(buf)
428
 
429
+ # === Main UI – With Studio Pulse AI Branding ===
430
+ with gr.Blocks(title="Studio Pulse AI", css="style.css") as demo:
431
+ gr.HTML('<div class="studio-header"><img src="logo.png" width="400" /><h3>Where Your Audio Meets Intelligence</h3></div>')
432
  gr.Markdown("### Upload, edit, export β€” powered by AI!")
433
 
434
  with gr.Tab("🎡 Single File Studio"):
 
462
  gr.Dropdown(choices=["Pop", "EDM", "Rock", "Hip-Hop", "Acoustic", "Metal", "Trap", "LoFi",
463
  "Jazz", "Classical", "Chillhop", "Ambient", "Jazz Piano", "Trap EDM",
464
  "Indie Rock", "Lo-Fi Jazz", "R&B", "Soul", "Funk"],
465
+ label="Genre", value="Pop"),
466
  gr.Slider(minimum=-24, maximum=-6, value=-14, label="Target LUFS")
467
  ],
468
  outputs=gr.Audio(label="Mastered Output", type="filepath"),
 
488
  clear_btn=None
489
  )
490
 
491
+ # --- Harmonic Saturation / Exciter – Now Included ===
492
  with gr.Tab("🧬 Harmonic Saturation"):
493
  gr.Interface(
494
  fn=harmonic_saturation,
 
585
  def load_project(project_file):
586
  with open(project_file.name, "rb") as f:
587
  data = pickle.load(f)
588
+ return data["preset"], data["effects"]
 
 
 
 
 
 
 
 
 
589
 
590
  with gr.Tab("πŸ“ Save/Load Project"):
591
  gr.Interface(
 
605
  fn=load_project,
606
  inputs=gr.File(label="Upload .aiproj File"),
607
  outputs=[
 
 
 
 
608
  gr.Dropdown(choices=preset_names, label="Loaded Preset"),
 
 
609
  gr.CheckboxGroup(choices=preset_choices["Default"], label="Loaded Effects")
610
  ],
611
  title="Resume Last Project",
 
624
  ("images/stage_mode_card.png", "Stage Mode"),
625
  ("images/vocal_distortion_card.png", "Vocal Distortion"),
626
  ("images/tube_saturation_card.png", "Tube Saturation"),
 
 
 
 
627
  ("images/rnb_card.png", "R&B"),
628
  ("images/soul_card.png", "Soul"),
629
+ ("images/funk_card.png", "Funk"),
630
+ ("images/jazz_card.png", "Jazz")
631
  ], label="Preset Cards", columns=4, height="auto")
632
 
633
  preset_name_out = gr.Dropdown(choices=preset_names, label="Selected Preset")
634
+ preset_effects_out = gr.CheckboxGroup(choices=list(preset_choices["Default"]), label="Effects")
635
 
636
  def load_preset_by_card(evt: gr.SelectData):
637
  index = evt.index % len(preset_names)
638
  name = preset_names[index]
639
+ return name, preset_choices[name]
 
640
 
641
  preset_gallery.select(fn=load_preset_by_card, inputs=[], outputs=[preset_name_out, preset_effects_out])
642