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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -23
app.py CHANGED
@@ -223,7 +223,6 @@ def stem_split(audio_path):
223
  def process_audio(audio_file, selected_effects, isolate_vocals, preset_name, export_format):
224
  status = "๐Ÿ”Š Loading audio..."
225
  try:
226
- # Load input audio file
227
  audio = AudioSegment.from_file(audio_file)
228
  status = "๐Ÿ›  Applying effects..."
229
  effect_map_real = {
@@ -241,7 +240,7 @@ 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
- 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)
@@ -301,7 +300,7 @@ def generate_session_log(audio_path, effects, isolate_vocals, export_format, gen
301
  "detected_genre": genre
302
  }, indent=2)
303
 
304
- # Preset Choices (All restored + more added)
305
  preset_choices = {
306
  "Default": [],
307
  "Clean Podcast": ["Noise Reduction", "Normalize"],
@@ -320,7 +319,6 @@ preset_choices = {
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)"],
326
  "Lo-Fi Chill": ["Noise Gate", "Low-Pass Filter (3000Hz)", "Mono Downmix", "Bitcrusher"],
@@ -575,7 +573,7 @@ with gr.Blocks(css="""
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():
581
  with gr.Column(min_width=200):
@@ -589,7 +587,7 @@ with gr.Blocks(css="""
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(
595
  fn=ai_remaster,
@@ -599,7 +597,7 @@ with gr.Blocks(css="""
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(
605
  fn=harmonic_saturation,
@@ -613,7 +611,7 @@ with gr.Blocks(css="""
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(
619
  fn=lambda x: apply_harmony(x),
@@ -622,7 +620,7 @@ with gr.Blocks(css="""
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(
628
  fn=batch_process_audio,
@@ -642,7 +640,7 @@ with gr.Blocks(css="""
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(
648
  fn=auto_tune_vocal,
@@ -654,14 +652,14 @@ with gr.Blocks(css="""
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(
660
  fn=visualize_spectrum,
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(
667
  fn=match_loudness,
@@ -673,7 +671,7 @@ with gr.Blocks(css="""
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():
679
  with gr.Column(min_width=300):
@@ -685,6 +683,7 @@ with gr.Blocks(css="""
685
  gr.CheckboxGroup(choices=preset_choices["Default"], label="Applied Effects")
686
  ],
687
  outputs=gr.File(label="Project File (.aiproj)")
 
688
  with gr.Column(min_width=300):
689
  gr.Interface(
690
  fn=load_project,
@@ -696,7 +695,7 @@ with gr.Blocks(css="""
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(
702
  fn=process_prompt,
@@ -709,7 +708,7 @@ with gr.Blocks(css="""
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,
@@ -721,7 +720,7 @@ with gr.Blocks(css="""
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(
727
  fn=compare_ab,
@@ -737,7 +736,7 @@ with gr.Blocks(css="""
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(
743
  fn=loop_section,
@@ -751,7 +750,7 @@ with gr.Blocks(css="""
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(
757
  fn=lambda x: json.dumps(x),
@@ -768,7 +767,7 @@ with gr.Blocks(css="""
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
@@ -780,7 +779,7 @@ with gr.Blocks(css="""
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(
786
  fn=formant_correct,
@@ -792,7 +791,7 @@ with gr.Blocks(css="""
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(
798
  fn=clone_voice,
@@ -804,7 +803,7 @@ with gr.Blocks(css="""
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(
810
  fn=generate_ableton_template,
@@ -813,7 +812,7 @@ with gr.Blocks(css="""
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(
819
  fn=export_full_mix,
 
223
  def process_audio(audio_file, selected_effects, isolate_vocals, preset_name, export_format):
224
  status = "๐Ÿ”Š Loading audio..."
225
  try:
 
226
  audio = AudioSegment.from_file(audio_file)
227
  status = "๐Ÿ›  Applying effects..."
228
  effect_map_real = {
 
240
  "Vocal Distortion": lambda x: apply_vocal_distortion(x),
241
  "Stage Mode": apply_stage_mode
242
  }
243
+ history = [audio]
244
  for effect_name in selected_effects:
245
  if effect_name in effect_map_real:
246
  audio = effect_map_real[effect_name](audio)
 
300
  "detected_genre": genre
301
  }, indent=2)
302
 
303
+ # Preset Choices
304
  preset_choices = {
305
  "Default": [],
306
  "Clean Podcast": ["Noise Reduction", "Normalize"],
 
319
  "๐ŸŽค R&B Vocal": ["Noise Reduction", "Bass Boost (100-300Hz)", "Treble Boost (2000-4000Hz)"],
320
  "๐Ÿ’ƒ Soul Vocal": ["Noise Reduction", "Bass Boost (80-200Hz)", "Treble Boost (1500-3500Hz)"],
321
  "๐Ÿ•บ Funk Groove": ["Bass Boost (80-200Hz)", "Treble Boost (1000-3000Hz)"],
 
322
  "Studio Master": ["Noise Reduction", "Normalize", "Bass Boost", "Treble Boost", "Limiter"],
323
  "Podcast Voice": ["Noise Reduction", "Auto Gain", "High Pass Filter (85Hz)"],
324
  "Lo-Fi Chill": ["Noise Gate", "Low-Pass Filter (3000Hz)", "Mono Downmix", "Bitcrusher"],
 
573
  ], outputs=[
574
  output_audio, waveform_img, session_log_out, genre_out, status_box
575
  ])
576
+ # --- Remix Mode โ€“ Stem Splitting + Per-Stem Effects ---
577
  with gr.Tab("๐ŸŽ› Remix Mode"):
578
  with gr.Row():
579
  with gr.Column(min_width=200):
 
587
  gr.File(label="Other")
588
  ]
589
  split_button.click(fn=stem_split, inputs=[input_audio_remix], outputs=stem_outputs)
590
+ # --- AI Remastering Tab ---
591
  with gr.Tab("๐Ÿ”ฎ AI Remastering"):
592
  gr.Interface(
593
  fn=ai_remaster,
 
597
  description="Uses noise reduction, vocal isolation, and mastering to enhance old recordings.",
598
  allow_flagging="never"
599
  )
600
+ # --- Harmonic Saturation / Exciter ---
601
  with gr.Tab("๐Ÿงฌ Harmonic Saturation"):
602
  gr.Interface(
603
  fn=harmonic_saturation,
 
611
  description="Enhance clarity and presence using saturation styles like Tube or Tape.",
612
  allow_flagging="never"
613
  )
614
+ # --- Vocal Doubler / Harmonizer ---
615
  with gr.Tab("๐ŸŽง Vocal Doubler / Harmonizer"):
616
  gr.Interface(
617
  fn=lambda x: apply_harmony(x),
 
620
  title="Add Vocal Doubling / Harmony",
621
  description="Enhance vocals with doubling or harmony"
622
  )
623
+ # --- Batch Processing ---
624
  with gr.Tab("๐Ÿ”Š Batch Processing"):
625
  gr.Interface(
626
  fn=batch_process_audio,
 
640
  flagging_mode="never",
641
  submit_btn="Process All Files"
642
  )
643
+ # --- Vocal Pitch Correction โ€“ Auto-Tune Style ---
644
  with gr.Tab("๐ŸŽค AI Auto-Tune"):
645
  gr.Interface(
646
  fn=auto_tune_vocal,
 
652
  title="AI Auto-Tune",
653
  description="Correct vocal pitch automatically using AI"
654
  )
655
+ # --- Frequency Spectrum Tab โ€“ Real-time Visualizer ---
656
  with gr.Tab("๐Ÿ“Š Frequency Spectrum"):
657
  gr.Interface(
658
  fn=visualize_spectrum,
659
  inputs=gr.Audio(label="Upload Track", type="filepath"),
660
  outputs=gr.Image(label="Spectrum Analysis")
661
  )
662
+ # --- Loudness Graph Tab โ€“ EBU R128 Matching ---
663
  with gr.Tab("๐Ÿ“ˆ Loudness Graph"):
664
  gr.Interface(
665
  fn=match_loudness,
 
671
  title="Match Loudness Across Tracks",
672
  description="Ensure consistent volume using EBU R128 standard"
673
  )
674
+ # --- Save/Load Mix Session (.aiproj) ---
675
  with gr.Tab("๐Ÿ“ Save/Load Project"):
676
  with gr.Row():
677
  with gr.Column(min_width=300):
 
683
  gr.CheckboxGroup(choices=preset_choices["Default"], label="Applied Effects")
684
  ],
685
  outputs=gr.File(label="Project File (.aiproj)")
686
+ )
687
  with gr.Column(min_width=300):
688
  gr.Interface(
689
  fn=load_project,
 
695
  title="Resume Last Project",
696
  description="Load your saved session"
697
  )
698
+ # --- Prompt-Based Editing Tab ---
699
  with gr.Tab("๐Ÿง  Prompt-Based Editing"):
700
  gr.Interface(
701
  fn=process_prompt,
 
708
  description="Say what you want done and let AI handle it.",
709
  allow_flagging="never"
710
  )
711
+ # --- Custom EQ Editor ---
712
  with gr.Tab("๐ŸŽ› Custom EQ Editor"):
713
  gr.Interface(
714
  fn=auto_eq,
 
720
  title="Custom EQ by Genre",
721
  description="Apply custom EQ based on genre"
722
  )
723
+ # --- A/B Compare Two Tracks ---
724
  with gr.Tab("๐ŸŽฏ A/B Compare"):
725
  gr.Interface(
726
  fn=compare_ab,
 
736
  description="Hear two mixes side-by-side",
737
  allow_flagging="never"
738
  )
739
+ # --- Loop Playback ---
740
  with gr.Tab("๐Ÿ” Loop Playback"):
741
  gr.Interface(
742
  fn=loop_section,
 
750
  title="Repeat a Section",
751
  description="Useful for editing a specific part"
752
  )
753
+ # --- Share Effect Chain Tab ---
754
  with gr.Tab("๐Ÿ”— Share Effect Chain"):
755
  gr.Interface(
756
  fn=lambda x: json.dumps(x),
 
767
  title="Restore From Shared Chain",
768
  description="Paste shared effect chain JSON to restore settings"
769
  )
770
+ # --- Keyboard Shortcuts Tab ---
771
  with gr.Tab("โŒจ Keyboard Shortcuts"):
772
  gr.Markdown("""
773
  ### Keyboard Controls
 
779
  - `Ctrl + C`: Copy effect chain
780
  - `Ctrl + V`: Paste effect chain
781
  """)
782
+ # --- Vocal Formant Correction ---
783
  with gr.Tab("๐Ÿง‘โ€๐ŸŽค Vocal Formant Correction"):
784
  gr.Interface(
785
  fn=formant_correct,
 
791
  title="Preserve Vocal Quality During Pitch Shift",
792
  description="Make pitch-shifted vocals sound more human"
793
  )
794
+ # --- Voice Swap / Cloning ---
795
  with gr.Tab("๐Ÿ” Voice Swap / Cloning"):
796
  gr.Interface(
797
  fn=clone_voice,
 
803
  title="Swap Voices Using AI",
804
  description="Clone or convert voice from one to another"
805
  )
806
+ # --- DAW Template Export ---
807
  with gr.Tab("๐ŸŽ› DAW Template Export"):
808
  gr.Interface(
809
  fn=generate_ableton_template,
 
812
  title="Generate Ableton/Live/FLP Template",
813
  description="Export ready-to-use templates for DAWs"
814
  )
815
+ # --- Export Full Mix ZIP ---
816
  with gr.Tab("๐Ÿ“ Export Full Mix ZIP"):
817
  gr.Interface(
818
  fn=export_full_mix,