Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,8 +23,6 @@ import base64
|
|
| 23 |
import pickle
|
| 24 |
import json
|
| 25 |
import soundfile as sf
|
| 26 |
-
from moviepy.editor import VideoFileClip, AudioFileClip
|
| 27 |
-
from fpdf import FPDF
|
| 28 |
|
| 29 |
# Suppress warnings
|
| 30 |
warnings.filterwarnings("ignore")
|
|
@@ -551,7 +549,7 @@ def clone_voice(source_audio, reference_audio):
|
|
| 551 |
mixed.export(out_path, format="wav")
|
| 552 |
return out_path
|
| 553 |
|
| 554 |
-
# === AI Remastering – Now Fixed
|
| 555 |
def ai_remaster(audio_path):
|
| 556 |
try:
|
| 557 |
audio = AudioSegment.from_file(audio_path)
|
|
@@ -577,12 +575,20 @@ def ai_mastering_chain(audio_path, genre="Pop", target_lufs=-14.0):
|
|
| 577 |
return out_path
|
| 578 |
|
| 579 |
# === Generate PDF Report ===
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 580 |
class PDFReport(FPDF):
|
| 581 |
def header(self):
|
| 582 |
self.set_font('Arial', 'B', 12)
|
| 583 |
self.cell(0, 10, 'Studio Pulse AI - Session Report', ln=True, align='C')
|
| 584 |
|
| 585 |
def export_session_report(session_data):
|
|
|
|
|
|
|
| 586 |
pdf = PDFReport()
|
| 587 |
pdf.add_page()
|
| 588 |
pdf.set_font("Arial", size=10)
|
|
@@ -591,35 +597,6 @@ def export_session_report(session_data):
|
|
| 591 |
pdf.output(out_path)
|
| 592 |
return out_path
|
| 593 |
|
| 594 |
-
# === Video Sync Mode – Extract and re-sync audio ===
|
| 595 |
-
def extract_audio_from_video(video_path):
|
| 596 |
-
clip = VideoFileClip(video_path)
|
| 597 |
-
out_path = os.path.join(tempfile.gettempdir(), "video_audio.wav")
|
| 598 |
-
clip.audio.write_audiofile(out_path)
|
| 599 |
-
return out_path
|
| 600 |
-
|
| 601 |
-
def re_sync_audio(video_path, edited_audio_path):
|
| 602 |
-
original_clip = VideoFileClip(video_path)
|
| 603 |
-
edited_audio = AudioSegment.from_file(edited_audio_path)
|
| 604 |
-
temp_audio_path = os.path.join(tempfile.gettempdir(), "temp_edited.mp3")
|
| 605 |
-
edited_audio.export(temp_audio_path, format="mp3")
|
| 606 |
-
final_clip = original_clip.set_audio(AudioFileClip(temp_audio_path))
|
| 607 |
-
out_path = os.path.join(tempfile.gettempdir(), "final_video.mp4")
|
| 608 |
-
final_clip.write_videofile(out_path, codec="libx264", audio_codec="aac")
|
| 609 |
-
return out_path
|
| 610 |
-
|
| 611 |
-
# === Sidechain Compression / Ducking ===
|
| 612 |
-
def sidechain_ducking(background, voice, threshold=-16, ratio=4):
|
| 613 |
-
bg_samples, bg_sr = audiosegment_to_array(background)
|
| 614 |
-
voice_samples, v_sr = audiosegment_to_array(voice)
|
| 615 |
-
if bg_sr != v_sr:
|
| 616 |
-
voice_samples = librosa.resample(voice_samples, orig_sr=v_sr, target_sr=bg_sr)
|
| 617 |
-
bg_rms = np.sqrt(np.mean(bg_samples ** 2))
|
| 618 |
-
voice_rms = np.sqrt(np.mean(voice_samples ** 2))
|
| 619 |
-
if voice_rms > bg_rms * threshold / 100:
|
| 620 |
-
bg_samples = bg_samples * ratio
|
| 621 |
-
return array_to_audiosegment(bg_samples.astype(np.int16), bg_sr, channels=background.channels)
|
| 622 |
-
|
| 623 |
# === Main UI – With Studio Pulse Branding ===
|
| 624 |
with gr.Blocks(css="""
|
| 625 |
body {
|
|
@@ -810,72 +787,62 @@ with gr.Blocks(css="""
|
|
| 810 |
|
| 811 |
# --- AI Remastering Tab – Now Fixed & Working ===
|
| 812 |
with gr.Tab("🔮 AI Remastering"):
|
| 813 |
-
gr.Interface(
|
| 814 |
-
|
| 815 |
-
|
| 816 |
-
|
| 817 |
-
|
| 818 |
-
description="Uses noise reduction, vocal isolation, and mastering to enhance old recordings."
|
| 819 |
-
)
|
| 820 |
|
| 821 |
# --- Harmonic Saturation / Exciter – Now Included ===
|
| 822 |
with gr.Tab("🧬 Harmonic Saturation"):
|
| 823 |
-
gr.Interface(
|
| 824 |
-
|
| 825 |
-
|
| 826 |
-
|
| 827 |
-
|
| 828 |
-
|
| 829 |
-
|
| 830 |
-
|
| 831 |
-
|
| 832 |
-
|
| 833 |
-
allow_flagging="never"
|
| 834 |
-
)
|
| 835 |
|
| 836 |
# --- Vocal Doubler / Harmonizer – Added ===
|
| 837 |
with gr.Tab("🎧 Vocal Doubler / Harmonizer"):
|
| 838 |
-
gr.Interface(
|
| 839 |
-
|
| 840 |
-
|
| 841 |
-
|
| 842 |
-
|
| 843 |
-
description="Enhance vocals with doubling or harmony"
|
| 844 |
-
)
|
| 845 |
|
| 846 |
# --- Batch Processing – Full Support ===
|
| 847 |
with gr.Tab("🔊 Batch Processing"):
|
| 848 |
-
gr.Interface(
|
| 849 |
-
|
| 850 |
-
|
| 851 |
-
|
| 852 |
-
|
| 853 |
-
|
| 854 |
-
|
| 855 |
-
|
| 856 |
-
|
| 857 |
-
|
| 858 |
-
|
| 859 |
-
|
| 860 |
-
|
| 861 |
-
|
| 862 |
-
|
| 863 |
-
|
| 864 |
-
submit_btn="Process All Files"
|
| 865 |
-
)
|
| 866 |
|
| 867 |
# --- Vocal Pitch Correction – Auto-Tune Style ===
|
| 868 |
with gr.Tab("🎤 AI Auto-Tune"):
|
| 869 |
-
gr.Interface(
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
|
| 873 |
-
|
| 874 |
-
|
| 875 |
-
|
| 876 |
-
|
| 877 |
-
description="Correct vocal pitch automatically using AI"
|
| 878 |
-
)
|
| 879 |
|
| 880 |
# --- Frequency Spectrum Tab – Real-time Visualizer ===
|
| 881 |
def visualize_spectrum(audio_path):
|
|
@@ -895,200 +862,169 @@ with gr.Blocks(css="""
|
|
| 895 |
return Image.open(buf)
|
| 896 |
|
| 897 |
with gr.Tab("📊 Frequency Spectrum"):
|
| 898 |
-
gr.Interface(
|
| 899 |
-
|
| 900 |
-
|
| 901 |
-
outputs=gr.Image(label="Spectrum Analysis"),
|
| 902 |
-
title="Real-Time Spectrum Analyzer",
|
| 903 |
-
description="See the frequency breakdown of your audio"
|
| 904 |
-
)
|
| 905 |
|
| 906 |
# --- Loudness Graph Tab – EBU R128 Matching ===
|
| 907 |
with gr.Tab("📈 Loudness Graph"):
|
| 908 |
-
gr.Interface(
|
| 909 |
-
|
| 910 |
-
|
| 911 |
-
|
| 912 |
-
|
| 913 |
-
|
| 914 |
-
|
| 915 |
-
|
| 916 |
-
description="Ensure consistent volume using EBU R128 standard"
|
| 917 |
-
)
|
| 918 |
|
| 919 |
# --- Save/Load Mix Session (.aiproj) – Added Back ===
|
| 920 |
with gr.Tab("📁 Save/Load Project"):
|
| 921 |
with gr.Row():
|
| 922 |
with gr.Column(min_width=300):
|
| 923 |
-
gr.Interface(
|
| 924 |
-
|
| 925 |
-
|
| 926 |
-
|
| 927 |
-
|
| 928 |
-
|
| 929 |
-
|
| 930 |
-
outputs=gr.File(label="Project File (.aiproj)")
|
| 931 |
-
)
|
| 932 |
with gr.Column(min_width=300):
|
| 933 |
-
gr.Interface(
|
| 934 |
-
|
| 935 |
-
|
| 936 |
-
|
| 937 |
-
|
| 938 |
-
|
| 939 |
-
|
| 940 |
-
|
| 941 |
-
description="Load your saved session"
|
| 942 |
-
)
|
| 943 |
|
| 944 |
# --- Prompt-Based Editing Tab – Added Back ===
|
| 945 |
with gr.Tab("🧠 Prompt-Based Editing"):
|
| 946 |
-
gr.Interface(
|
| 947 |
-
|
| 948 |
-
|
| 949 |
-
|
| 950 |
-
|
| 951 |
-
|
| 952 |
-
|
| 953 |
-
|
| 954 |
-
|
| 955 |
-
allow_flagging="never"
|
| 956 |
-
)
|
| 957 |
|
| 958 |
# --- Vocal Presets for Singers – Added Back ===
|
| 959 |
with gr.Tab("🎤 Vocal Presets for Singers"):
|
| 960 |
-
gr.Interface(
|
| 961 |
-
|
| 962 |
-
|
| 963 |
-
|
| 964 |
-
|
| 965 |
-
|
| 966 |
-
|
| 967 |
-
|
| 968 |
-
|
| 969 |
-
|
| 970 |
-
|
| 971 |
-
|
| 972 |
-
|
| 973 |
-
|
| 974 |
-
|
| 975 |
-
|
| 976 |
-
|
| 977 |
-
|
| 978 |
-
|
| 979 |
-
|
| 980 |
-
|
| 981 |
-
|
| 982 |
-
|
| 983 |
-
|
| 984 |
-
|
| 985 |
-
|
| 986 |
-
|
| 987 |
-
|
| 988 |
-
description="Apply singer-friendly presets and effects to enhance vocals.",
|
| 989 |
-
allow_flagging="never"
|
| 990 |
-
)
|
| 991 |
|
| 992 |
# --- Real-Time Streaming Preview ===
|
| 993 |
with gr.Tab("🎧 Real-Time Preview"):
|
| 994 |
-
gr.Interface(
|
| 995 |
-
|
| 996 |
-
|
| 997 |
-
|
| 998 |
-
|
| 999 |
-
|
| 1000 |
-
|
| 1001 |
-
|
| 1002 |
-
description="Try effects live before exporting"
|
| 1003 |
-
)
|
| 1004 |
|
| 1005 |
# --- Custom EQ Editor ===
|
| 1006 |
with gr.Tab("🎛 Custom EQ Editor"):
|
| 1007 |
-
gr.Interface(
|
| 1008 |
-
|
| 1009 |
-
|
| 1010 |
-
|
| 1011 |
-
|
| 1012 |
-
|
| 1013 |
-
|
| 1014 |
-
|
| 1015 |
-
|
| 1016 |
-
|
| 1017 |
-
|
| 1018 |
-
description="Apply custom EQ based on genre"
|
| 1019 |
-
)
|
| 1020 |
|
| 1021 |
# --- AI Suggest Effects Based on Genre ===
|
| 1022 |
with gr.Tab("🧩 AI Effect Suggestions"):
|
| 1023 |
-
gr.Interface(
|
| 1024 |
-
|
| 1025 |
-
|
| 1026 |
-
outputs=gr.CheckboxGroup(choices=preset_choices["Default"], label="Suggested Effects")
|
| 1027 |
-
)
|
| 1028 |
|
| 1029 |
# --- Time-Stretch & BPM Match ===
|
| 1030 |
with gr.Tab("⏱ Time-Stretch & BPM Match"):
|
| 1031 |
-
gr.Interface(
|
| 1032 |
-
|
| 1033 |
-
|
| 1034 |
-
|
| 1035 |
-
|
| 1036 |
-
|
| 1037 |
-
|
| 1038 |
-
|
| 1039 |
-
description="Stretch or shrink audio to match a specific tempo"
|
| 1040 |
-
)
|
| 1041 |
|
| 1042 |
# --- A/B Compare ===
|
| 1043 |
with gr.Tab("🎯 A/B Compare"):
|
| 1044 |
-
gr.Interface(
|
| 1045 |
-
|
| 1046 |
-
|
| 1047 |
-
|
| 1048 |
-
|
| 1049 |
-
|
| 1050 |
-
|
| 1051 |
-
|
| 1052 |
-
|
| 1053 |
-
|
| 1054 |
-
|
| 1055 |
-
|
| 1056 |
-
allow_flagging="never"
|
| 1057 |
-
)
|
| 1058 |
|
| 1059 |
# --- Loop Playback ===
|
| 1060 |
with gr.Tab("🔁 Loop Playback"):
|
| 1061 |
-
gr.Interface(
|
| 1062 |
-
|
| 1063 |
-
|
| 1064 |
-
|
| 1065 |
-
|
| 1066 |
-
|
| 1067 |
-
|
| 1068 |
-
|
| 1069 |
-
|
| 1070 |
-
|
| 1071 |
-
description="Useful for editing a specific part"
|
| 1072 |
-
)
|
| 1073 |
|
| 1074 |
# --- Share Effect Chain Tab – Now Defined! ===
|
| 1075 |
with gr.Tab("🔗 Share Effect Chain"):
|
| 1076 |
-
gr.Interface(
|
| 1077 |
-
|
| 1078 |
-
|
| 1079 |
-
|
| 1080 |
-
|
| 1081 |
-
description="Share your setup via link/code"
|
| 1082 |
-
)
|
| 1083 |
|
| 1084 |
with gr.Tab("📥 Load Shared Chain"):
|
| 1085 |
-
gr.Interface(
|
| 1086 |
-
|
| 1087 |
-
|
| 1088 |
-
|
| 1089 |
-
|
| 1090 |
-
description="Paste shared effect chain JSON to restore settings"
|
| 1091 |
-
)
|
| 1092 |
|
| 1093 |
# --- Keyboard Shortcuts Tab ===
|
| 1094 |
with gr.Tab("⌨ Keyboard Shortcuts"):
|
|
@@ -1105,80 +1041,41 @@ with gr.Blocks(css="""
|
|
| 1105 |
|
| 1106 |
# --- Vocal Formant Correction – Now Defined! ===
|
| 1107 |
with gr.Tab("🧑🎤 Vocal Formant Correction"):
|
| 1108 |
-
gr.Interface(
|
| 1109 |
-
|
| 1110 |
-
|
| 1111 |
-
|
| 1112 |
-
|
| 1113 |
-
|
| 1114 |
-
|
| 1115 |
-
|
| 1116 |
-
description="Make pitch-shifted vocals sound more natural"
|
| 1117 |
-
)
|
| 1118 |
|
| 1119 |
# --- Voice Swap / Cloning – New Tab ===
|
| 1120 |
with gr.Tab("🔁 Voice Swap / Cloning"):
|
| 1121 |
-
gr.Interface(
|
| 1122 |
-
|
| 1123 |
-
|
| 1124 |
-
|
| 1125 |
-
|
| 1126 |
-
|
| 1127 |
-
|
| 1128 |
-
|
| 1129 |
-
description="Clone or convert voice from one to another"
|
| 1130 |
-
)
|
| 1131 |
|
| 1132 |
# --- DAW Template Export – Now Included ===
|
| 1133 |
with gr.Tab("🎛 DAW Template Export"):
|
| 1134 |
-
gr.Interface(
|
| 1135 |
-
|
| 1136 |
-
|
| 1137 |
-
outputs=gr.File(label="DAW Template (.json/.als/.flp)")
|
| 1138 |
-
)
|
| 1139 |
|
| 1140 |
# --- Export Full Mix ZIP – Added Back ===
|
| 1141 |
with gr.Tab("📁 Export Full Mix ZIP"):
|
| 1142 |
-
gr.Interface(
|
| 1143 |
-
|
| 1144 |
-
|
| 1145 |
-
|
| 1146 |
-
|
| 1147 |
-
|
| 1148 |
-
|
| 1149 |
-
|
| 1150 |
-
description="Perfect for sharing with producers or archiving"
|
| 1151 |
-
)
|
| 1152 |
-
|
| 1153 |
-
# --- Session Report Export (PDF) – New Tab ===
|
| 1154 |
-
with gr.Tab("📄 Session Report"):
|
| 1155 |
-
gr.Interface(
|
| 1156 |
-
fn=export_session_report,
|
| 1157 |
-
inputs=gr.Textbox(label="Session Data (JSON)", lines=10),
|
| 1158 |
-
outputs=gr.File(label="Download PDF Report"),
|
| 1159 |
-
title="Export Detailed Session Report",
|
| 1160 |
-
description="For professional use or sharing with collaborators"
|
| 1161 |
-
)
|
| 1162 |
-
|
| 1163 |
-
# --- Effect Chains Marketplace – New Tab ===
|
| 1164 |
-
with gr.Tab("🧩 Effect Chain Marketplace"):
|
| 1165 |
-
gr.Interface(
|
| 1166 |
-
fn=publish_effect_chain,
|
| 1167 |
-
inputs=[
|
| 1168 |
-
gr.Textbox(label="Effect Chain (JSON)", lines=2),
|
| 1169 |
-
gr.Textbox(label="Name", value="My Chain"),
|
| 1170 |
-
gr.CheckboxGroup(choices=["music", "vocals", "podcast", "radio", "edm"], label="Tags")
|
| 1171 |
-
],
|
| 1172 |
-
outputs=gr.JSON(label="Published Chain Info"),
|
| 1173 |
-
title="Publish Your Effect Chain",
|
| 1174 |
-
description="Share your setup with others"
|
| 1175 |
-
)
|
| 1176 |
-
|
| 1177 |
-
with gr.Tab("🧩 Search Chains"):
|
| 1178 |
-
gr.Interface(
|
| 1179 |
-
fn=search_effect_chains,
|
| 1180 |
-
inputs=gr.Textbox(label="Search Query", value="vocal"),
|
| 1181 |
-
outputs=gr.JSON(label="Matching Chains")
|
| 1182 |
-
)
|
| 1183 |
|
| 1184 |
demo.launch()
|
|
|
|
| 23 |
import pickle
|
| 24 |
import json
|
| 25 |
import soundfile as sf
|
|
|
|
|
|
|
| 26 |
|
| 27 |
# Suppress warnings
|
| 28 |
warnings.filterwarnings("ignore")
|
|
|
|
| 549 |
mixed.export(out_path, format="wav")
|
| 550 |
return out_path
|
| 551 |
|
| 552 |
+
# === AI Remastering – Now Fixed! ===
|
| 553 |
def ai_remaster(audio_path):
|
| 554 |
try:
|
| 555 |
audio = AudioSegment.from_file(audio_path)
|
|
|
|
| 575 |
return out_path
|
| 576 |
|
| 577 |
# === Generate PDF Report ===
|
| 578 |
+
try:
|
| 579 |
+
from fpdf import FPDF
|
| 580 |
+
pdf_available = True
|
| 581 |
+
except ImportError:
|
| 582 |
+
pdf_available = False
|
| 583 |
+
|
| 584 |
class PDFReport(FPDF):
|
| 585 |
def header(self):
|
| 586 |
self.set_font('Arial', 'B', 12)
|
| 587 |
self.cell(0, 10, 'Studio Pulse AI - Session Report', ln=True, align='C')
|
| 588 |
|
| 589 |
def export_session_report(session_data):
|
| 590 |
+
if not pdf_available:
|
| 591 |
+
return None
|
| 592 |
pdf = PDFReport()
|
| 593 |
pdf.add_page()
|
| 594 |
pdf.set_font("Arial", size=10)
|
|
|
|
| 597 |
pdf.output(out_path)
|
| 598 |
return out_path
|
| 599 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 600 |
# === Main UI – With Studio Pulse Branding ===
|
| 601 |
with gr.Blocks(css="""
|
| 602 |
body {
|
|
|
|
| 787 |
|
| 788 |
# --- AI Remastering Tab – Now Fixed & Working ===
|
| 789 |
with gr.Tab("🔮 AI Remastering"):
|
| 790 |
+
gr.Interface(fn=ai_remaster,
|
| 791 |
+
inputs=gr.Audio(label="Upload Low-Quality Recording", type="filepath"),
|
| 792 |
+
outputs=gr.Audio(label="Studio-Grade Output", type="filepath"),
|
| 793 |
+
title="Transform Low-Quality Recordings to Studio Sound",
|
| 794 |
+
description="Uses noise reduction, vocal isolation, and mastering to enhance old recordings.")
|
|
|
|
|
|
|
| 795 |
|
| 796 |
# --- Harmonic Saturation / Exciter – Now Included ===
|
| 797 |
with gr.Tab("🧬 Harmonic Saturation"):
|
| 798 |
+
gr.Interface(fn=harmonic_saturation,
|
| 799 |
+
inputs=[
|
| 800 |
+
gr.Audio(label="Upload Track", type="filepath"),
|
| 801 |
+
gr.Dropdown(choices=["Tube", "Tape", "Console", "Mix Bus"], label="Saturation Type", value="Tube"),
|
| 802 |
+
gr.Slider(minimum=0.1, maximum=1.0, value=0.2, label="Intensity")
|
| 803 |
+
],
|
| 804 |
+
outputs=gr.Audio(label="Warm Output", type="filepath"),
|
| 805 |
+
title="Add Analog-Style Warmth",
|
| 806 |
+
description="Enhance clarity and presence using saturation styles like Tube or Tape.",
|
| 807 |
+
allow_flagging="never")
|
|
|
|
|
|
|
| 808 |
|
| 809 |
# --- Vocal Doubler / Harmonizer – Added ===
|
| 810 |
with gr.Tab("🎧 Vocal Doubler / Harmonizer"):
|
| 811 |
+
gr.Interface(fn=lambda x: apply_harmony(x),
|
| 812 |
+
inputs=gr.Audio(label="Upload Vocal Clip", type="filepath"),
|
| 813 |
+
outputs=gr.Audio(label="Doubled Output", type="filepath"),
|
| 814 |
+
title="Add Vocal Doubling / Harmony",
|
| 815 |
+
description="Enhance vocals with doubling or harmony")
|
|
|
|
|
|
|
| 816 |
|
| 817 |
# --- Batch Processing – Full Support ===
|
| 818 |
with gr.Tab("🔊 Batch Processing"):
|
| 819 |
+
gr.Interface(fn=batch_process_audio,
|
| 820 |
+
inputs=[
|
| 821 |
+
gr.File(label="Upload Multiple Files", file_count="multiple"),
|
| 822 |
+
gr.CheckboxGroup(choices=preset_choices["Default"], label="Apply Effects in Order"),
|
| 823 |
+
gr.Checkbox(label="Isolate Vocals After Effects"),
|
| 824 |
+
gr.Dropdown(choices=preset_names, label="Select Preset", value=preset_names[0]),
|
| 825 |
+
gr.Dropdown(choices=["MP3", "WAV"], label="Export Format", value="MP3")
|
| 826 |
+
],
|
| 827 |
+
outputs=[
|
| 828 |
+
gr.File(label="Download ZIP of All Processed Files"),
|
| 829 |
+
gr.Textbox(label="Status", value="✅ Ready", lines=1)
|
| 830 |
+
],
|
| 831 |
+
title="Batch Audio Processor",
|
| 832 |
+
description="Upload multiple files, apply effects in bulk, and download all results in a ZIP.",
|
| 833 |
+
flagging_mode="never",
|
| 834 |
+
submit_btn="Process All Files")
|
|
|
|
|
|
|
| 835 |
|
| 836 |
# --- Vocal Pitch Correction – Auto-Tune Style ===
|
| 837 |
with gr.Tab("🎤 AI Auto-Tune"):
|
| 838 |
+
gr.Interface(fn=auto_tune_vocal,
|
| 839 |
+
inputs=[
|
| 840 |
+
gr.File(label="Source Voice Clip"),
|
| 841 |
+
gr.Textbox(label="Target Key", value="C", lines=1)
|
| 842 |
+
],
|
| 843 |
+
outputs=gr.Audio(label="Pitch-Corrected Output", type="filepath"),
|
| 844 |
+
title="AI Auto-Tune",
|
| 845 |
+
description="Correct vocal pitch automatically using AI")
|
|
|
|
|
|
|
| 846 |
|
| 847 |
# --- Frequency Spectrum Tab – Real-time Visualizer ===
|
| 848 |
def visualize_spectrum(audio_path):
|
|
|
|
| 862 |
return Image.open(buf)
|
| 863 |
|
| 864 |
with gr.Tab("📊 Frequency Spectrum"):
|
| 865 |
+
gr.Interface(fn=visualize_spectrum,
|
| 866 |
+
inputs=gr.Audio(label="Upload Track", type="filepath"),
|
| 867 |
+
outputs=gr.Image(label="Spectrum Analysis"))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 868 |
|
| 869 |
# --- Loudness Graph Tab – EBU R128 Matching ===
|
| 870 |
with gr.Tab("📈 Loudness Graph"):
|
| 871 |
+
gr.Interface(fn=match_loudness,
|
| 872 |
+
inputs=[
|
| 873 |
+
gr.Audio(label="Upload Track", type="filepath"),
|
| 874 |
+
gr.Slider(minimum=-24, maximum=-6, value=-14, label="Target LUFS")
|
| 875 |
+
],
|
| 876 |
+
outputs=gr.Audio(label="Normalized Output", type="filepath"),
|
| 877 |
+
title="Match Loudness Across Tracks",
|
| 878 |
+
description="Ensure consistent volume using EBU R128 standard")
|
|
|
|
|
|
|
| 879 |
|
| 880 |
# --- Save/Load Mix Session (.aiproj) – Added Back ===
|
| 881 |
with gr.Tab("📁 Save/Load Project"):
|
| 882 |
with gr.Row():
|
| 883 |
with gr.Column(min_width=300):
|
| 884 |
+
gr.Interface(fn=save_project,
|
| 885 |
+
inputs=[
|
| 886 |
+
gr.File(label="Original Audio"),
|
| 887 |
+
gr.Dropdown(choices=preset_names, label="Used Preset", value=preset_names[0]),
|
| 888 |
+
gr.CheckboxGroup(choices=preset_choices["Default"], label="Applied Effects")
|
| 889 |
+
],
|
| 890 |
+
outputs=gr.File(label="Project File (.aiproj)"))
|
|
|
|
|
|
|
| 891 |
with gr.Column(min_width=300):
|
| 892 |
+
gr.Interface(fn=load_project,
|
| 893 |
+
inputs=gr.File(label="Upload .aiproj File"),
|
| 894 |
+
outputs=[
|
| 895 |
+
gr.Dropdown(choices=preset_names, label="Loaded Preset"),
|
| 896 |
+
gr.CheckboxGroup(choices=preset_choices["Default"], label="Loaded Effects")
|
| 897 |
+
],
|
| 898 |
+
title="Resume Last Project",
|
| 899 |
+
description="Load your saved session")
|
|
|
|
|
|
|
| 900 |
|
| 901 |
# --- Prompt-Based Editing Tab – Added Back ===
|
| 902 |
with gr.Tab("🧠 Prompt-Based Editing"):
|
| 903 |
+
gr.Interface(fn=process_prompt,
|
| 904 |
+
inputs=[
|
| 905 |
+
gr.File(label="Upload Audio", type="filepath"),
|
| 906 |
+
gr.Textbox(label="Describe What You Want", lines=5)
|
| 907 |
+
],
|
| 908 |
+
outputs=gr.Audio(label="Edited Output", type="filepath"),
|
| 909 |
+
title="Type Your Edits – AI Does the Rest",
|
| 910 |
+
description="Say what you want done and let AI handle it.",
|
| 911 |
+
allow_flagging="never")
|
|
|
|
|
|
|
| 912 |
|
| 913 |
# --- Vocal Presets for Singers – Added Back ===
|
| 914 |
with gr.Tab("🎤 Vocal Presets for Singers"):
|
| 915 |
+
gr.Interface(fn=process_audio,
|
| 916 |
+
inputs=[
|
| 917 |
+
gr.Audio(label="Upload Vocal Track", type="filepath"),
|
| 918 |
+
gr.CheckboxGroup(choices=[
|
| 919 |
+
"Noise Reduction",
|
| 920 |
+
"Normalize",
|
| 921 |
+
"Compress Dynamic Range",
|
| 922 |
+
"Bass Boost",
|
| 923 |
+
"Treble Boost",
|
| 924 |
+
"Reverb",
|
| 925 |
+
"Auto Gain",
|
| 926 |
+
"Vocal Distortion",
|
| 927 |
+
"Stage Mode"
|
| 928 |
+
]),
|
| 929 |
+
gr.Checkbox(label="Isolate Vocals After Effects"),
|
| 930 |
+
gr.Dropdown(choices=preset_names, label="Select Vocal Preset", value=preset_names[0]),
|
| 931 |
+
gr.Dropdown(choices=["MP3", "WAV"], label="Export Format", value="MP3")
|
| 932 |
+
],
|
| 933 |
+
outputs=[
|
| 934 |
+
gr.Audio(label="Processed Vocal", type="filepath"),
|
| 935 |
+
gr.Image(label="Waveform Preview"),
|
| 936 |
+
gr.Textbox(label="Session Log (JSON)", lines=5),
|
| 937 |
+
gr.Textbox(label="Detected Genre", lines=1),
|
| 938 |
+
gr.Textbox(label="Status", value="✅ Ready", lines=1)
|
| 939 |
+
],
|
| 940 |
+
title="Create Studio-Quality Vocal Tracks",
|
| 941 |
+
description="Apply singer-friendly presets and effects to enhance vocals.",
|
| 942 |
+
allow_flagging="never")
|
|
|
|
|
|
|
|
|
|
| 943 |
|
| 944 |
# --- Real-Time Streaming Preview ===
|
| 945 |
with gr.Tab("🎧 Real-Time Preview"):
|
| 946 |
+
gr.Interface(fn=live_effect_preview,
|
| 947 |
+
inputs=[
|
| 948 |
+
gr.Audio(sources=["microphone"], streaming=True, label="Live Mic Input"),
|
| 949 |
+
gr.Dropdown(choices=["Normalize", "Reverb", "Pitch Shift", "Saturation"]),
|
| 950 |
+
],
|
| 951 |
+
outputs=gr.Audio(label="Live Output", type="filepath"),
|
| 952 |
+
title="Preview Effects in Real-Time",
|
| 953 |
+
description="Try effects live before exporting")
|
|
|
|
|
|
|
| 954 |
|
| 955 |
# --- Custom EQ Editor ===
|
| 956 |
with gr.Tab("🎛 Custom EQ Editor"):
|
| 957 |
+
gr.Interface(fn=auto_eq,
|
| 958 |
+
inputs=[
|
| 959 |
+
gr.Audio(label="Upload Track", type="filepath"),
|
| 960 |
+
gr.Dropdown(choices=["Pop", "EDM", "Rock", "Hip-Hop", "Acoustic", "Metal", "Trap", "LoFi",
|
| 961 |
+
"Jazz", "Classical", "Chillhop", "Ambient", "Jazz Piano", "Trap EDM",
|
| 962 |
+
"Indie Rock", "Lo-Fi Jazz", "R&B", "Soul", "Funk"],
|
| 963 |
+
label="Genre", value="Pop")
|
| 964 |
+
],
|
| 965 |
+
outputs=gr.Audio(label="EQ-Enhanced Output", type="filepath"),
|
| 966 |
+
title="Custom EQ by Genre",
|
| 967 |
+
description="Apply custom EQ based on genre")
|
|
|
|
|
|
|
| 968 |
|
| 969 |
# --- AI Suggest Effects Based on Genre ===
|
| 970 |
with gr.Tab("🧩 AI Effect Suggestions"):
|
| 971 |
+
gr.Interface(fn=suggest_by_genre,
|
| 972 |
+
inputs=gr.Audio(label="Upload Track", type="filepath"),
|
| 973 |
+
outputs=gr.CheckboxGroup(choices=preset_choices["Default"], label="Suggested Effects"))
|
|
|
|
|
|
|
| 974 |
|
| 975 |
# --- Time-Stretch & BPM Match ===
|
| 976 |
with gr.Tab("⏱ Time-Stretch & BPM Match"):
|
| 977 |
+
gr.Interface(fn=stretch_to_bpm,
|
| 978 |
+
inputs=[
|
| 979 |
+
gr.Audio(label="Upload Track", type="filepath"),
|
| 980 |
+
gr.Slider(minimum=60, maximum=200, value=128, label="Target BPM")
|
| 981 |
+
],
|
| 982 |
+
outputs=gr.Audio(label="Stretched Output", type="filepath"),
|
| 983 |
+
title="Match Track to BPM",
|
| 984 |
+
description="Stretch audio to match a specific tempo")
|
|
|
|
|
|
|
| 985 |
|
| 986 |
# --- A/B Compare ===
|
| 987 |
with gr.Tab("🎯 A/B Compare"):
|
| 988 |
+
gr.Interface(fn=compare_ab,
|
| 989 |
+
inputs=[
|
| 990 |
+
gr.Audio(label="Version A", type="filepath"),
|
| 991 |
+
gr.Audio(label="Version B", type="filepath")
|
| 992 |
+
],
|
| 993 |
+
outputs=[
|
| 994 |
+
gr.Audio(label="Version A", type="filepath"),
|
| 995 |
+
gr.Audio(label="Version B", type="filepath")
|
| 996 |
+
],
|
| 997 |
+
title="Compare Two Versions",
|
| 998 |
+
description="Hear two mixes side-by-side",
|
| 999 |
+
allow_flagging="never")
|
|
|
|
|
|
|
| 1000 |
|
| 1001 |
# --- Loop Playback ===
|
| 1002 |
with gr.Tab("🔁 Loop Playback"):
|
| 1003 |
+
gr.Interface(fn=loop_section,
|
| 1004 |
+
inputs=[
|
| 1005 |
+
gr.Audio(label="Upload Track", type="filepath"),
|
| 1006 |
+
gr.Slider(minimum=0, maximum=30000, step=100, value=5000, label="Start MS"),
|
| 1007 |
+
gr.Slider(minimum=100, maximum=30000, step=100, value=10000, label="End MS"),
|
| 1008 |
+
gr.Slider(minimum=1, maximum=10, value=2, label="Repeat Loops")
|
| 1009 |
+
],
|
| 1010 |
+
outputs=gr.Audio(label="Looped Output", type="filepath"),
|
| 1011 |
+
title="Repeat a Section",
|
| 1012 |
+
description="Useful for editing a specific part")
|
|
|
|
|
|
|
| 1013 |
|
| 1014 |
# --- Share Effect Chain Tab – Now Defined! ===
|
| 1015 |
with gr.Tab("🔗 Share Effect Chain"):
|
| 1016 |
+
gr.Interface(fn=lambda x: json.dumps(x),
|
| 1017 |
+
inputs=gr.CheckboxGroup(choices=preset_choices["Default"]),
|
| 1018 |
+
outputs=gr.Textbox(label="Share Code", lines=2),
|
| 1019 |
+
title="Copy/Paste Effect Chain",
|
| 1020 |
+
description="Share your setup via link/code")
|
|
|
|
|
|
|
| 1021 |
|
| 1022 |
with gr.Tab("📥 Load Shared Chain"):
|
| 1023 |
+
gr.Interface(fn=json.loads,
|
| 1024 |
+
inputs=gr.Textbox(label="Paste Shared Code", lines=2),
|
| 1025 |
+
outputs=gr.CheckboxGroup(choices=preset_choices["Default"], label="Loaded Effects"),
|
| 1026 |
+
title="Restore From Shared Chain",
|
| 1027 |
+
description="Paste shared effect chain JSON to restore settings")
|
|
|
|
|
|
|
| 1028 |
|
| 1029 |
# --- Keyboard Shortcuts Tab ===
|
| 1030 |
with gr.Tab("⌨ Keyboard Shortcuts"):
|
|
|
|
| 1041 |
|
| 1042 |
# --- Vocal Formant Correction – Now Defined! ===
|
| 1043 |
with gr.Tab("🧑🎤 Vocal Formant Correction"):
|
| 1044 |
+
gr.Interface(fn=formant_correct,
|
| 1045 |
+
inputs=[
|
| 1046 |
+
gr.Audio(label="Upload Vocal Track", type="filepath"),
|
| 1047 |
+
gr.Slider(minimum=-2, maximum=2, value=1.0, label="Formant Shift")
|
| 1048 |
+
],
|
| 1049 |
+
outputs=gr.Audio(label="Natural-Sounding Vocal", type="filepath"),
|
| 1050 |
+
title="Preserve Vocal Quality During Pitch Shift",
|
| 1051 |
+
description="Make pitch-shifted vocals sound more human")
|
|
|
|
|
|
|
| 1052 |
|
| 1053 |
# --- Voice Swap / Cloning – New Tab ===
|
| 1054 |
with gr.Tab("🔁 Voice Swap / Cloning"):
|
| 1055 |
+
gr.Interface(fn=clone_voice,
|
| 1056 |
+
inputs=[
|
| 1057 |
+
gr.File(label="Source Voice Clip"),
|
| 1058 |
+
gr.File(label="Reference Voice")
|
| 1059 |
+
],
|
| 1060 |
+
outputs=gr.Audio(label="Converted Output", type="filepath"),
|
| 1061 |
+
title="Swap Voices Using AI",
|
| 1062 |
+
description="Clone or convert voice from one to another")
|
|
|
|
|
|
|
| 1063 |
|
| 1064 |
# --- DAW Template Export – Now Included ===
|
| 1065 |
with gr.Tab("🎛 DAW Template Export"):
|
| 1066 |
+
gr.Interface(fn=generate_ableton_template,
|
| 1067 |
+
inputs=[gr.File(label="Upload Stems", file_count="multiple")],
|
| 1068 |
+
outputs=gr.File(label="DAW Template (.json/.als/.flp)")
|
|
|
|
|
|
|
| 1069 |
|
| 1070 |
# --- Export Full Mix ZIP – Added Back ===
|
| 1071 |
with gr.Tab("📁 Export Full Mix ZIP"):
|
| 1072 |
+
gr.Interface(fn=export_full_mix,
|
| 1073 |
+
inputs=[
|
| 1074 |
+
gr.File(label="Stems", file_count="multiple"),
|
| 1075 |
+
gr.File(label="Final Mix")
|
| 1076 |
+
],
|
| 1077 |
+
outputs=gr.File(label="Full Mix Archive (.zip)",
|
| 1078 |
+
title="Export Stems + Final Mix Together",
|
| 1079 |
+
description="Perfect for sharing with producers or archiving"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1080 |
|
| 1081 |
demo.launch()
|