tee342 commited on
Commit
e56bca3
ยท
verified ยท
1 Parent(s): cb5b337

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -36
app.py CHANGED
@@ -166,6 +166,7 @@ def auto_eq(audio, genre="Pop"):
166
  }
167
 
168
  from scipy.signal import butter, sosfilt
 
169
  def band_eq(samples, sr, lowcut, highcut, gain):
170
  sos = butter(10, [lowcut, highcut], btype='band', output='sos', fs=sr)
171
  filtered = sosfilt(sos, samples)
@@ -225,7 +226,6 @@ def process_audio(audio_file, selected_effects, isolate_vocals, preset_name, exp
225
  # Load input audio file
226
  audio = AudioSegment.from_file(audio_file)
227
  status = "๐Ÿ›  Applying effects..."
228
-
229
  effect_map_real = {
230
  "Noise Reduction": apply_noise_reduction,
231
  "Compress Dynamic Range": apply_compression,
@@ -241,13 +241,11 @@ def process_audio(audio_file, selected_effects, isolate_vocals, preset_name, exp
241
  "Vocal Distortion": lambda x: apply_vocal_distortion(x),
242
  "Stage Mode": apply_stage_mode
243
  }
244
-
245
  history = [audio] # For undo functionality
246
  for effect_name in selected_effects:
247
  if effect_name in effect_map_real:
248
  audio = effect_map_real[effect_name](audio)
249
  history.append(audio)
250
-
251
  status = "๐Ÿ’พ Saving final audio..."
252
  with tempfile.NamedTemporaryFile(delete=False, suffix=f".{export_format.lower()}") as f:
253
  if isolate_vocals:
@@ -259,7 +257,6 @@ def process_audio(audio_file, selected_effects, isolate_vocals, preset_name, exp
259
  final_audio = audio
260
  output_path = f.name
261
  final_audio.export(output_path, format=export_format.lower())
262
-
263
  waveform_image = show_waveform(output_path)
264
  genre = detect_genre(output_path)
265
  session_log = generate_session_log(audio_file, selected_effects, isolate_vocals, export_format, genre)
@@ -323,7 +320,6 @@ preset_choices = {
323
  "๐ŸŽค R&B Vocal": ["Noise Reduction", "Bass Boost (100-300Hz)", "Treble Boost (2000-4000Hz)"],
324
  "๐Ÿ’ƒ Soul Vocal": ["Noise Reduction", "Bass Boost (80-200Hz)", "Treble Boost (1500-3500Hz)"],
325
  "๐Ÿ•บ Funk Groove": ["Bass Boost (80-200Hz)", "Treble Boost (1000-3000Hz)"],
326
-
327
  # New presets
328
  "Studio Master": ["Noise Reduction", "Normalize", "Bass Boost", "Treble Boost", "Limiter"],
329
  "Podcast Voice": ["Noise Reduction", "Auto Gain", "High Pass Filter (85Hz)"],
@@ -558,7 +554,6 @@ with gr.Blocks(css="""
558
  </div>
559
  ''')
560
  gr.Markdown("### Upload, edit, export โ€” powered by AI!")
561
-
562
  # --- Single File Studio Tab ---
563
  with gr.Tab("๐ŸŽต Single File Studio"):
564
  with gr.Row():
@@ -580,7 +575,6 @@ with gr.Blocks(css="""
580
  ], outputs=[
581
  output_audio, waveform_img, session_log_out, genre_out, status_box
582
  ])
583
-
584
  # --- Remix Mode โ€“ Stem Splitting + Per-Stem Effects ===
585
  with gr.Tab("๐ŸŽ› Remix Mode"):
586
  with gr.Row():
@@ -595,7 +589,6 @@ with gr.Blocks(css="""
595
  gr.File(label="Other")
596
  ]
597
  split_button.click(fn=stem_split, inputs=[input_audio_remix], outputs=stem_outputs)
598
-
599
  # --- AI Remastering Tab โ€“ Now Fixed & Working ===
600
  with gr.Tab("๐Ÿ”ฎ AI Remastering"):
601
  gr.Interface(
@@ -606,7 +599,6 @@ with gr.Blocks(css="""
606
  description="Uses noise reduction, vocal isolation, and mastering to enhance old recordings.",
607
  allow_flagging="never"
608
  )
609
-
610
  # --- Harmonic Saturation / Exciter โ€“ Now Included ===
611
  with gr.Tab("๐Ÿงฌ Harmonic Saturation"):
612
  gr.Interface(
@@ -621,7 +613,6 @@ with gr.Blocks(css="""
621
  description="Enhance clarity and presence using saturation styles like Tube or Tape.",
622
  allow_flagging="never"
623
  )
624
-
625
  # --- Vocal Doubler / Harmonizer โ€“ Added Back ===
626
  with gr.Tab("๐ŸŽง Vocal Doubler / Harmonizer"):
627
  gr.Interface(
@@ -631,7 +622,6 @@ with gr.Blocks(css="""
631
  title="Add Vocal Doubling / Harmony",
632
  description="Enhance vocals with doubling or harmony"
633
  )
634
-
635
  # --- Batch Processing โ€“ Full Support ===
636
  with gr.Tab("๐Ÿ”Š Batch Processing"):
637
  gr.Interface(
@@ -652,7 +642,6 @@ with gr.Blocks(css="""
652
  flagging_mode="never",
653
  submit_btn="Process All Files"
654
  )
655
-
656
  # --- Vocal Pitch Correction โ€“ Auto-Tune Style ===
657
  with gr.Tab("๐ŸŽค AI Auto-Tune"):
658
  gr.Interface(
@@ -665,7 +654,6 @@ with gr.Blocks(css="""
665
  title="AI Auto-Tune",
666
  description="Correct vocal pitch automatically using AI"
667
  )
668
-
669
  # --- Frequency Spectrum Tab โ€“ Real-time Visualizer ===
670
  with gr.Tab("๐Ÿ“Š Frequency Spectrum"):
671
  gr.Interface(
@@ -673,7 +661,6 @@ with gr.Blocks(css="""
673
  inputs=gr.Audio(label="Upload Track", type="filepath"),
674
  outputs=gr.Image(label="Spectrum Analysis")
675
  )
676
-
677
  # --- Loudness Graph Tab โ€“ EBU R128 Matching ===
678
  with gr.Tab("๐Ÿ“ˆ Loudness Graph"):
679
  gr.Interface(
@@ -686,7 +673,6 @@ with gr.Blocks(css="""
686
  title="Match Loudness Across Tracks",
687
  description="Ensure consistent volume using EBU R128 standard"
688
  )
689
-
690
  # --- Save/Load Mix Session (.aiproj) โ€“ Added Back ===
691
  with gr.Tab("๐Ÿ“ Save/Load Project"):
692
  with gr.Row():
@@ -710,7 +696,6 @@ with gr.Blocks(css="""
710
  title="Resume Last Project",
711
  description="Load your saved session"
712
  )
713
-
714
  # --- Prompt-Based Editing Tab โ€“ Added Back ===
715
  with gr.Tab("๐Ÿง  Prompt-Based Editing"):
716
  gr.Interface(
@@ -724,20 +709,18 @@ with gr.Blocks(css="""
724
  description="Say what you want done and let AI handle it.",
725
  allow_flagging="never"
726
  )
727
-
728
  # --- Custom EQ Editor ===
729
  with gr.Tab("๐ŸŽ› Custom EQ Editor"):
730
  gr.Interface(
731
  fn=auto_eq,
732
  inputs=[
733
  gr.Audio(label="Upload Track", type="filepath"),
734
- gr.Dropdown(choices=list(auto_eq.__defaults__[0].keys(), label="Genre", value="Pop")
735
  ],
736
  outputs=gr.Audio(label="EQ-Enhanced Output", type="filepath"),
737
  title="Custom EQ by Genre",
738
  description="Apply custom EQ based on genre"
739
  )
740
-
741
  # --- A/B Compare Two Tracks ===
742
  with gr.Tab("๐ŸŽฏ A/B Compare"):
743
  gr.Interface(
@@ -754,7 +737,6 @@ with gr.Blocks(css="""
754
  description="Hear two mixes side-by-side",
755
  allow_flagging="never"
756
  )
757
-
758
  # --- Loop Playback ===
759
  with gr.Tab("๐Ÿ” Loop Playback"):
760
  gr.Interface(
@@ -769,7 +751,6 @@ with gr.Blocks(css="""
769
  title="Repeat a Section",
770
  description="Useful for editing a specific part"
771
  )
772
-
773
  # --- Share Effect Chain Tab โ€“ Now Defined! ===
774
  with gr.Tab("๐Ÿ”— Share Effect Chain"):
775
  gr.Interface(
@@ -779,7 +760,6 @@ with gr.Blocks(css="""
779
  title="Copy/Paste Effect Chain",
780
  description="Share your setup via link/code"
781
  )
782
-
783
  with gr.Tab("๐Ÿ“ฅ Load Shared Chain"):
784
  gr.Interface(
785
  fn=json.loads,
@@ -788,20 +768,18 @@ with gr.Blocks(css="""
788
  title="Restore From Shared Chain",
789
  description="Paste shared effect chain JSON to restore settings"
790
  )
791
-
792
  # --- Keyboard Shortcuts Tab ===
793
  with gr.Tab("โŒจ Keyboard Shortcuts"):
794
  gr.Markdown("""
795
- ### Keyboard Controls
796
- - `Ctrl + Z`: Undo last effect
797
- - `Ctrl + Y`: Redo
798
- - `Spacebar`: Play/Stop playback
799
- - `Ctrl + S`: Save current session
800
- - `Ctrl + O`: Open session
801
- - `Ctrl + C`: Copy effect chain
802
- - `Ctrl + V`: Paste effect chain
803
  """)
804
-
805
  # --- Vocal Formant Correction โ€“ Now Defined! ===
806
  with gr.Tab("๐Ÿง‘โ€๐ŸŽค Vocal Formant Correction"):
807
  gr.Interface(
@@ -814,7 +792,6 @@ with gr.Blocks(css="""
814
  title="Preserve Vocal Quality During Pitch Shift",
815
  description="Make pitch-shifted vocals sound more human"
816
  )
817
-
818
  # --- Voice Swap / Cloning โ€“ New Tab ===
819
  with gr.Tab("๐Ÿ” Voice Swap / Cloning"):
820
  gr.Interface(
@@ -827,7 +804,6 @@ with gr.Blocks(css="""
827
  title="Swap Voices Using AI",
828
  description="Clone or convert voice from one to another"
829
  )
830
-
831
  # --- DAW Template Export โ€“ Now Included ===
832
  with gr.Tab("๐ŸŽ› DAW Template Export"):
833
  gr.Interface(
@@ -837,7 +813,6 @@ with gr.Blocks(css="""
837
  title="Generate Ableton/Live/FLP Template",
838
  description="Export ready-to-use templates for DAWs"
839
  )
840
-
841
  # --- Export Full Mix ZIP โ€“ Added Back ===
842
  with gr.Tab("๐Ÿ“ Export Full Mix ZIP"):
843
  gr.Interface(
@@ -852,4 +827,4 @@ with gr.Blocks(css="""
852
  )
853
 
854
  # Launch Gradio App
855
- demo.launch()
 
166
  }
167
 
168
  from scipy.signal import butter, sosfilt
169
+
170
  def band_eq(samples, sr, lowcut, highcut, gain):
171
  sos = butter(10, [lowcut, highcut], btype='band', output='sos', fs=sr)
172
  filtered = sosfilt(sos, samples)
 
226
  # Load input audio file
227
  audio = AudioSegment.from_file(audio_file)
228
  status = "๐Ÿ›  Applying effects..."
 
229
  effect_map_real = {
230
  "Noise Reduction": apply_noise_reduction,
231
  "Compress Dynamic Range": apply_compression,
 
241
  "Vocal Distortion": lambda x: apply_vocal_distortion(x),
242
  "Stage Mode": apply_stage_mode
243
  }
 
244
  history = [audio] # For undo functionality
245
  for effect_name in selected_effects:
246
  if effect_name in effect_map_real:
247
  audio = effect_map_real[effect_name](audio)
248
  history.append(audio)
 
249
  status = "๐Ÿ’พ Saving final audio..."
250
  with tempfile.NamedTemporaryFile(delete=False, suffix=f".{export_format.lower()}") as f:
251
  if isolate_vocals:
 
257
  final_audio = audio
258
  output_path = f.name
259
  final_audio.export(output_path, format=export_format.lower())
 
260
  waveform_image = show_waveform(output_path)
261
  genre = detect_genre(output_path)
262
  session_log = generate_session_log(audio_file, selected_effects, isolate_vocals, export_format, genre)
 
320
  "๐ŸŽค R&B Vocal": ["Noise Reduction", "Bass Boost (100-300Hz)", "Treble Boost (2000-4000Hz)"],
321
  "๐Ÿ’ƒ Soul Vocal": ["Noise Reduction", "Bass Boost (80-200Hz)", "Treble Boost (1500-3500Hz)"],
322
  "๐Ÿ•บ Funk Groove": ["Bass Boost (80-200Hz)", "Treble Boost (1000-3000Hz)"],
 
323
  # New presets
324
  "Studio Master": ["Noise Reduction", "Normalize", "Bass Boost", "Treble Boost", "Limiter"],
325
  "Podcast Voice": ["Noise Reduction", "Auto Gain", "High Pass Filter (85Hz)"],
 
554
  </div>
555
  ''')
556
  gr.Markdown("### Upload, edit, export โ€” powered by AI!")
 
557
  # --- Single File Studio Tab ---
558
  with gr.Tab("๐ŸŽต Single File Studio"):
559
  with gr.Row():
 
575
  ], outputs=[
576
  output_audio, waveform_img, session_log_out, genre_out, status_box
577
  ])
 
578
  # --- Remix Mode โ€“ Stem Splitting + Per-Stem Effects ===
579
  with gr.Tab("๐ŸŽ› Remix Mode"):
580
  with gr.Row():
 
589
  gr.File(label="Other")
590
  ]
591
  split_button.click(fn=stem_split, inputs=[input_audio_remix], outputs=stem_outputs)
 
592
  # --- AI Remastering Tab โ€“ Now Fixed & Working ===
593
  with gr.Tab("๐Ÿ”ฎ AI Remastering"):
594
  gr.Interface(
 
599
  description="Uses noise reduction, vocal isolation, and mastering to enhance old recordings.",
600
  allow_flagging="never"
601
  )
 
602
  # --- Harmonic Saturation / Exciter โ€“ Now Included ===
603
  with gr.Tab("๐Ÿงฌ Harmonic Saturation"):
604
  gr.Interface(
 
613
  description="Enhance clarity and presence using saturation styles like Tube or Tape.",
614
  allow_flagging="never"
615
  )
 
616
  # --- Vocal Doubler / Harmonizer โ€“ Added Back ===
617
  with gr.Tab("๐ŸŽง Vocal Doubler / Harmonizer"):
618
  gr.Interface(
 
622
  title="Add Vocal Doubling / Harmony",
623
  description="Enhance vocals with doubling or harmony"
624
  )
 
625
  # --- Batch Processing โ€“ Full Support ===
626
  with gr.Tab("๐Ÿ”Š Batch Processing"):
627
  gr.Interface(
 
642
  flagging_mode="never",
643
  submit_btn="Process All Files"
644
  )
 
645
  # --- Vocal Pitch Correction โ€“ Auto-Tune Style ===
646
  with gr.Tab("๐ŸŽค AI Auto-Tune"):
647
  gr.Interface(
 
654
  title="AI Auto-Tune",
655
  description="Correct vocal pitch automatically using AI"
656
  )
 
657
  # --- Frequency Spectrum Tab โ€“ Real-time Visualizer ===
658
  with gr.Tab("๐Ÿ“Š Frequency Spectrum"):
659
  gr.Interface(
 
661
  inputs=gr.Audio(label="Upload Track", type="filepath"),
662
  outputs=gr.Image(label="Spectrum Analysis")
663
  )
 
664
  # --- Loudness Graph Tab โ€“ EBU R128 Matching ===
665
  with gr.Tab("๐Ÿ“ˆ Loudness Graph"):
666
  gr.Interface(
 
673
  title="Match Loudness Across Tracks",
674
  description="Ensure consistent volume using EBU R128 standard"
675
  )
 
676
  # --- Save/Load Mix Session (.aiproj) โ€“ Added Back ===
677
  with gr.Tab("๐Ÿ“ Save/Load Project"):
678
  with gr.Row():
 
696
  title="Resume Last Project",
697
  description="Load your saved session"
698
  )
 
699
  # --- Prompt-Based Editing Tab โ€“ Added Back ===
700
  with gr.Tab("๐Ÿง  Prompt-Based Editing"):
701
  gr.Interface(
 
709
  description="Say what you want done and let AI handle it.",
710
  allow_flagging="never"
711
  )
 
712
  # --- Custom EQ Editor ===
713
  with gr.Tab("๐ŸŽ› Custom EQ Editor"):
714
  gr.Interface(
715
  fn=auto_eq,
716
  inputs=[
717
  gr.Audio(label="Upload Track", type="filepath"),
718
+ gr.Dropdown(choices=list(auto_eq.__defaults__[0].keys()), label="Genre", value="Pop")
719
  ],
720
  outputs=gr.Audio(label="EQ-Enhanced Output", type="filepath"),
721
  title="Custom EQ by Genre",
722
  description="Apply custom EQ based on genre"
723
  )
 
724
  # --- A/B Compare Two Tracks ===
725
  with gr.Tab("๐ŸŽฏ A/B Compare"):
726
  gr.Interface(
 
737
  description="Hear two mixes side-by-side",
738
  allow_flagging="never"
739
  )
 
740
  # --- Loop Playback ===
741
  with gr.Tab("๐Ÿ” Loop Playback"):
742
  gr.Interface(
 
751
  title="Repeat a Section",
752
  description="Useful for editing a specific part"
753
  )
 
754
  # --- Share Effect Chain Tab โ€“ Now Defined! ===
755
  with gr.Tab("๐Ÿ”— Share Effect Chain"):
756
  gr.Interface(
 
760
  title="Copy/Paste Effect Chain",
761
  description="Share your setup via link/code"
762
  )
 
763
  with gr.Tab("๐Ÿ“ฅ Load Shared Chain"):
764
  gr.Interface(
765
  fn=json.loads,
 
768
  title="Restore From Shared Chain",
769
  description="Paste shared effect chain JSON to restore settings"
770
  )
 
771
  # --- Keyboard Shortcuts Tab ===
772
  with gr.Tab("โŒจ Keyboard Shortcuts"):
773
  gr.Markdown("""
774
+ ### Keyboard Controls
775
+ - `Ctrl + Z`: Undo last effect
776
+ - `Ctrl + Y`: Redo
777
+ - `Spacebar`: Play/Stop playback
778
+ - `Ctrl + S`: Save current session
779
+ - `Ctrl + O`: Open session
780
+ - `Ctrl + C`: Copy effect chain
781
+ - `Ctrl + V`: Paste effect chain
782
  """)
 
783
  # --- Vocal Formant Correction โ€“ Now Defined! ===
784
  with gr.Tab("๐Ÿง‘โ€๐ŸŽค Vocal Formant Correction"):
785
  gr.Interface(
 
792
  title="Preserve Vocal Quality During Pitch Shift",
793
  description="Make pitch-shifted vocals sound more human"
794
  )
 
795
  # --- Voice Swap / Cloning โ€“ New Tab ===
796
  with gr.Tab("๐Ÿ” Voice Swap / Cloning"):
797
  gr.Interface(
 
804
  title="Swap Voices Using AI",
805
  description="Clone or convert voice from one to another"
806
  )
 
807
  # --- DAW Template Export โ€“ Now Included ===
808
  with gr.Tab("๐ŸŽ› DAW Template Export"):
809
  gr.Interface(
 
813
  title="Generate Ableton/Live/FLP Template",
814
  description="Export ready-to-use templates for DAWs"
815
  )
 
816
  # --- Export Full Mix ZIP โ€“ Added Back ===
817
  with gr.Tab("๐Ÿ“ Export Full Mix ZIP"):
818
  gr.Interface(
 
827
  )
828
 
829
  # Launch Gradio App
830
+ demo.launch()