tee342 commited on
Commit
8daccd1
Β·
verified Β·
1 Parent(s): 89d6845

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -55
app.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import gradio as gr
3
  from pydub import AudioSegment
4
  from pydub.silence import detect_nonsilent
@@ -23,40 +22,6 @@ from TTS.api import TTS
23
  import base64
24
  import pickle
25
  import json
26
- import gradio as gr
27
- from pydub import AudioSegment
28
-
29
- # === Studio Logo – Embedded via Base64 or URL ===
30
- def get_logo():
31
- return "https://via.placeholder.com/400x100/1e1e1e/1db954?text=Studio+Pulse+AI"
32
-
33
- # === Start Gradio App ===
34
- with gr.Blocks(title="Studio Pulse AI", css="style.css") as demo:
35
- # Header with logo and tagline
36
- gr.HTML(f'''
37
- <div class="studio-header">
38
- <img src="{get_logo()}" width="400" />
39
- <h3>Where Your Audio Meets Intelligence</h3>
40
- </div>
41
- ''')
42
-
43
- gr.Markdown("### Upload, edit, export β€” powered by AI!")
44
-
45
- # Preset Gallery Tab
46
- with gr.Tab("πŸŽ› Preset Gallery"):
47
- gr.Markdown("### Select a preset visually")
48
- preset_gallery = gr.Gallery(value=[
49
- ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=Pop", "Pop"),
50
- ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=EDM", "EDM"),
51
- ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=R+B", "R&B"),
52
- ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=Soul", "Soul"),
53
- ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=Funk", "Funk"),
54
- ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=Jazz", "Jazz"),
55
- ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=Stage+Mode", "Stage Mode"),
56
- ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=Tube+Saturation", "Tube Saturation")
57
- ], label="Preset Cards", columns=4)
58
-
59
- demo.launch()
60
 
61
  # Suppress warnings
62
  warnings.filterwarnings("ignore")
@@ -169,7 +134,7 @@ def match_loudness(audio_path, target_lufs=-14.0):
169
  adjusted.export(out_path, format="wav")
170
  return out_path
171
 
172
- # === Auto-EQ per Genre – With New Genres Added ===
173
  def auto_eq(audio, genre="Pop"):
174
  eq_map = {
175
  "Pop": [(200, 500, -3), (2000, 4000, +4)],
@@ -309,6 +274,7 @@ def process_audio(audio_file, selected_effects, isolate_vocals, preset_name, exp
309
  "Normalize": apply_normalize,
310
  "Noise Gate": lambda x: apply_noise_gate(x, threshold=-50.0),
311
  "Limiter": lambda x: apply_limiter(x, limit_dB=-1),
 
312
  "Bitcrusher": lambda x: apply_bitcrush(x, bit_depth=8),
313
  "Auto Gain": lambda x: apply_auto_gain(x, target_dB=-20),
314
  "Vocal Distortion": lambda x: apply_vocal_distortion(x),
@@ -447,6 +413,7 @@ def auto_tune_vocal(audio_path, target_key="C"):
447
  def visualize_spectrum(audio_path):
448
  y, sr = torchaudio.load(audio_path)
449
  y_np = y.numpy().flatten()
 
450
  stft = librosa.stft(y_np)
451
  db = librosa.amplitude_to_db(abs(stft))
452
 
@@ -461,11 +428,19 @@ def visualize_spectrum(audio_path):
461
  buf.seek(0)
462
  return Image.open(buf)
463
 
464
- # === Main UI – With Studio Pulse AI Branding ===
465
  with gr.Blocks(title="Studio Pulse AI", css="style.css") as demo:
466
- gr.HTML('<div class="studio-header"><img src="logo.png" width="400" /><h3>Where Your Audio Meets Intelligence</h3></div>')
467
- gr.Markdown("### Upload, edit, export β€” powered by AI!")
 
 
 
 
 
468
 
 
 
 
469
  with gr.Tab("🎡 Single File Studio"):
470
  with gr.Row():
471
  with gr.Column(min_width=300):
@@ -497,7 +472,7 @@ with gr.Blocks(title="Studio Pulse AI", css="style.css") as demo:
497
  gr.Dropdown(choices=["Pop", "EDM", "Rock", "Hip-Hop", "Acoustic", "Metal", "Trap", "LoFi",
498
  "Jazz", "Classical", "Chillhop", "Ambient", "Jazz Piano", "Trap EDM",
499
  "Indie Rock", "Lo-Fi Jazz", "R&B", "Soul", "Funk"],
500
- label="Genre", value="Pop"),
501
  gr.Slider(minimum=-24, maximum=-6, value=-14, label="Target LUFS")
502
  ],
503
  outputs=gr.Audio(label="Mastered Output", type="filepath"),
@@ -632,8 +607,7 @@ with gr.Blocks(title="Studio Pulse AI", css="style.css") as demo:
632
  ],
633
  outputs=gr.File(label="Project File (.aiproj)"),
634
  title="Save Everything Together",
635
- description="Save your session, effects, and settings in one file to reuse later.",
636
- allow_flagging="never"
637
  )
638
 
639
  gr.Interface(
@@ -651,18 +625,14 @@ with gr.Blocks(title="Studio Pulse AI", css="style.css") as demo:
651
  with gr.Tab("πŸŽ› Preset Gallery"):
652
  gr.Markdown("### Select a preset visually")
653
  preset_gallery = gr.Gallery(value=[
654
- ("images/pop_card.png", "Pop"),
655
- ("images/edm_card.png", "EDM"),
656
- ("images/rock_card.png", "Rock"),
657
- ("images/hiphop_card.png", "Hip-Hop"),
658
- ("images/acoustic_card.png", "Acoustic"),
659
- ("images/stage_mode_card.png", "Stage Mode"),
660
- ("images/vocal_distortion_card.png", "Vocal Distortion"),
661
- ("images/tube_saturation_card.png", "Tube Saturation"),
662
- ("images/rnb_card.png", "R&B"),
663
- ("images/soul_card.png", "Soul"),
664
- ("images/funk_card.png", "Funk"),
665
- ("images/jazz_card.png", "Jazz")
666
  ], label="Preset Cards", columns=4, height="auto")
667
 
668
  preset_name_out = gr.Dropdown(choices=preset_names, label="Selected Preset")
@@ -675,7 +645,7 @@ with gr.Blocks(title="Studio Pulse AI", css="style.css") as demo:
675
 
676
  preset_gallery.select(fn=load_preset_by_card, inputs=[], outputs=[preset_name_out, preset_effects_out])
677
 
678
- # --- Prompt-Based Editing Tab – Added Back ===
679
  def process_prompt(audio, prompt):
680
  return apply_noise_reduction(audio)
681
 
 
 
1
  import gradio as gr
2
  from pydub import AudioSegment
3
  from pydub.silence import detect_nonsilent
 
22
  import base64
23
  import pickle
24
  import json
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  # Suppress warnings
27
  warnings.filterwarnings("ignore")
 
134
  adjusted.export(out_path, format="wav")
135
  return out_path
136
 
137
+ # === Auto-EQ per Genre – With R&B, Soul, Funk ===
138
  def auto_eq(audio, genre="Pop"):
139
  eq_map = {
140
  "Pop": [(200, 500, -3), (2000, 4000, +4)],
 
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
  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
 
 
428
  buf.seek(0)
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
 
441
+ gr.Markdown("### Upload, edit, export β€” powered by AI!")
442
+
443
+ # --- Single File Studio Tab ---
444
  with gr.Tab("🎡 Single File Studio"):
445
  with gr.Row():
446
  with gr.Column(min_width=300):
 
472
  gr.Dropdown(choices=["Pop", "EDM", "Rock", "Hip-Hop", "Acoustic", "Metal", "Trap", "LoFi",
473
  "Jazz", "Classical", "Chillhop", "Ambient", "Jazz Piano", "Trap EDM",
474
  "Indie Rock", "Lo-Fi Jazz", "R&B", "Soul", "Funk"],
475
+ label="Genre", value="Pop"),
476
  gr.Slider(minimum=-24, maximum=-6, value=-14, label="Target LUFS")
477
  ],
478
  outputs=gr.Audio(label="Mastered Output", type="filepath"),
 
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(
 
625
  with gr.Tab("πŸŽ› Preset Gallery"):
626
  gr.Markdown("### Select a preset visually")
627
  preset_gallery = gr.Gallery(value=[
628
+ ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=Pop", "Pop"),
629
+ ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=EDM", "EDM"),
630
+ ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=Rock", "Rock"),
631
+ ("https://via.placeholder.com/150x100/1e1e1e/1db954?text=Hip-Hop", "Hip-Hop"),
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")
 
645
 
646
  preset_gallery.select(fn=load_preset_by_card, inputs=[], outputs=[preset_name_out, preset_effects_out])
647
 
648
+ # --- Prompt-Based Editing Tab – Added Back ===
649
  def process_prompt(audio, prompt):
650
  return apply_noise_reduction(audio)
651