Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,8 +23,7 @@ import base64
|
|
| 23 |
import pickle
|
| 24 |
import json
|
| 25 |
import soundfile as sf
|
| 26 |
-
import
|
| 27 |
-
import struct
|
| 28 |
|
| 29 |
# Suppress warnings
|
| 30 |
warnings.filterwarnings("ignore")
|
|
@@ -368,22 +367,6 @@ def key_to_semitone(key="C"):
|
|
| 368 |
"F#": 6, "G": 7, "G#": 8, "A": 9, "A#": 10, "B": 11}
|
| 369 |
return keys.get(key, 0)
|
| 370 |
|
| 371 |
-
# === AI Remastering Tab โ Now Fixed & Working ===
|
| 372 |
-
def ai_remaster(audio_path):
|
| 373 |
-
try:
|
| 374 |
-
audio = AudioSegment.from_file(audio_path)
|
| 375 |
-
samples, sr = audiosegment_to_array(audio)
|
| 376 |
-
reduced = nr.reduce_noise(y=samples, sr=sr)
|
| 377 |
-
cleaned = array_to_audiosegment(reduced, sr, channels=audio.channels)
|
| 378 |
-
cleaned_wav_path = os.path.join(tempfile.gettempdir(), "cleaned.wav")
|
| 379 |
-
cleaned.export(cleaned_wav_path, format="wav")
|
| 380 |
-
isolated_path = apply_vocal_isolation(cleaned_wav_path)
|
| 381 |
-
final_path = ai_mastering_chain(isolated_path, genre="Pop", target_lufs=-14.0)
|
| 382 |
-
return final_path
|
| 383 |
-
except Exception as e:
|
| 384 |
-
print(f"Remastering Error: {str(e)}")
|
| 385 |
-
return None
|
| 386 |
-
|
| 387 |
# === Apply Effects to Stems ===
|
| 388 |
def apply_effects_to_stem(stem_path, selected_effects):
|
| 389 |
try:
|
|
@@ -560,7 +543,6 @@ def text_to_sound(prompt):
|
|
| 560 |
|
| 561 |
# === Voice Cloning via OpenVoice (Simulated) ===
|
| 562 |
def clone_voice(source_audio, reference_audio):
|
| 563 |
-
# Simulate voice swap
|
| 564 |
source = AudioSegment.from_file(source_audio)
|
| 565 |
ref = AudioSegment.from_file(reference_audio)
|
| 566 |
mixed = source.overlay(ref - 10)
|
|
@@ -773,7 +755,7 @@ with gr.Blocks(css="""
|
|
| 773 |
output_other = gr.Audio(label="Processed Other", type="filepath")
|
| 774 |
btn_other.click(fn=apply_effects_to_stem, inputs=[other_path, other_effects], outputs=output_other)
|
| 775 |
|
| 776 |
-
# --- AI Remastering Tab โ
|
| 777 |
with gr.Tab("๐ฎ AI Remastering"):
|
| 778 |
gr.Interface(
|
| 779 |
fn=ai_remaster,
|
|
@@ -794,7 +776,8 @@ with gr.Blocks(css="""
|
|
| 794 |
],
|
| 795 |
outputs=gr.Audio(label="Warm Output", type="filepath"),
|
| 796 |
title="Add Analog-Style Warmth",
|
| 797 |
-
description="Enhance clarity and presence using saturation styles like Tube or Tape."
|
|
|
|
| 798 |
)
|
| 799 |
|
| 800 |
# --- Vocal Doubler / Harmonizer โ Added ===
|
|
@@ -959,7 +942,7 @@ with gr.Blocks(css="""
|
|
| 959 |
fn=live_effect_preview,
|
| 960 |
inputs=[
|
| 961 |
gr.Audio(sources=["microphone"], streaming=True, label="Live Mic Input"),
|
| 962 |
-
gr.Dropdown(choices=["Normalize", "Reverb", "Pitch Shift", "Saturation"]
|
| 963 |
],
|
| 964 |
outputs=gr.Audio(label="Live Output", type="filepath"),
|
| 965 |
title="Preview Effects in Real-Time",
|
|
@@ -1077,7 +1060,7 @@ with gr.Blocks(css="""
|
|
| 1077 |
],
|
| 1078 |
outputs=gr.Audio(label="Natural-Sounding Vocal", type="filepath"),
|
| 1079 |
title="Preserve Vocal Quality During Pitch Shift",
|
| 1080 |
-
description="Make pitch-shifted vocals sound more
|
| 1081 |
)
|
| 1082 |
|
| 1083 |
# --- Voice Swap / Cloning โ New Tab ===
|
|
@@ -1114,36 +1097,4 @@ with gr.Blocks(css="""
|
|
| 1114 |
description="Perfect for sharing with producers or archiving"
|
| 1115 |
)
|
| 1116 |
|
| 1117 |
-
# --- AI Sound Design โ Text to Audio Generation ===
|
| 1118 |
-
with gr.Tab("๐ง AI Sound Design"):
|
| 1119 |
-
gr.Interface(
|
| 1120 |
-
fn=text_to_sound,
|
| 1121 |
-
inputs=gr.Textbox(label="Describe a Sound", lines=5),
|
| 1122 |
-
outputs=gr.Audio(label="Generated Sound", type="filepath"),
|
| 1123 |
-
title="Generate Sounds from Text",
|
| 1124 |
-
description="Describe a sound โ AI generates it"
|
| 1125 |
-
)
|
| 1126 |
-
|
| 1127 |
-
# --- Web DAW Interface โ New Feature ===
|
| 1128 |
-
with gr.Tab("๐ Web DAW"):
|
| 1129 |
-
with gr.Row():
|
| 1130 |
-
with gr.Column(min_width=300):
|
| 1131 |
-
track1 = gr.Audio(label="Track 1", type="filepath")
|
| 1132 |
-
vol1 = gr.Slider(minimum=0, maximum=1, value=1, label="Volume 1")
|
| 1133 |
-
pan1 = gr.Slider(minimum=-1, maximum=1, value=0, label="Pan 1")
|
| 1134 |
-
fx1 = gr.CheckboxGroup(choices=["Reverb", "EQ", "Compression"], label="Effects Track 1")
|
| 1135 |
-
track2 = gr.Audio(label="Track 2", type="filepath")
|
| 1136 |
-
vol2 = gr.Slider(minimum=0, maximum=1, value=1, label="Volume 2")
|
| 1137 |
-
pan2 = gr.Slider(minimum=-1, maximum=1, value=0, label="Pan 2")
|
| 1138 |
-
fx2 = gr.CheckboxGroup(choices=["Reverb", "EQ", "Compression"], label="Effects Track 2")
|
| 1139 |
-
mix_btn = gr.Button("Mix Tracks")
|
| 1140 |
-
with gr.Column(min_width=400):
|
| 1141 |
-
timeline_img = gr.Image(label="Timeline View")
|
| 1142 |
-
final_mix = gr.Audio(label="Final Mix", type="filepath")
|
| 1143 |
-
export_zip_btn = gr.Button("Export Full Mix + Stems (.zip)")
|
| 1144 |
-
|
| 1145 |
-
mix_btn.click(fn=mix_tracks, inputs=[track1, vol1, pan1, fx1, track2, vol2, pan2, fx2], outputs=[final_mix, timeline_img])
|
| 1146 |
-
|
| 1147 |
-
export_zip_btn.click(fn=export_full_mix, inputs=[track1, track2, final_mix], outputs=gr.File(label="Download ZIP"))
|
| 1148 |
-
|
| 1149 |
demo.launch()
|
|
|
|
| 23 |
import pickle
|
| 24 |
import json
|
| 25 |
import soundfile as sf
|
| 26 |
+
from moviepy.editor import VideoFileClip, AudioFileClip
|
|
|
|
| 27 |
|
| 28 |
# Suppress warnings
|
| 29 |
warnings.filterwarnings("ignore")
|
|
|
|
| 367 |
"F#": 6, "G": 7, "G#": 8, "A": 9, "A#": 10, "B": 11}
|
| 368 |
return keys.get(key, 0)
|
| 369 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
# === Apply Effects to Stems ===
|
| 371 |
def apply_effects_to_stem(stem_path, selected_effects):
|
| 372 |
try:
|
|
|
|
| 543 |
|
| 544 |
# === Voice Cloning via OpenVoice (Simulated) ===
|
| 545 |
def clone_voice(source_audio, reference_audio):
|
|
|
|
| 546 |
source = AudioSegment.from_file(source_audio)
|
| 547 |
ref = AudioSegment.from_file(reference_audio)
|
| 548 |
mixed = source.overlay(ref - 10)
|
|
|
|
| 755 |
output_other = gr.Audio(label="Processed Other", type="filepath")
|
| 756 |
btn_other.click(fn=apply_effects_to_stem, inputs=[other_path, other_effects], outputs=output_other)
|
| 757 |
|
| 758 |
+
# --- AI Remastering Tab โ New Feature (Fixed) ===
|
| 759 |
with gr.Tab("๐ฎ AI Remastering"):
|
| 760 |
gr.Interface(
|
| 761 |
fn=ai_remaster,
|
|
|
|
| 776 |
],
|
| 777 |
outputs=gr.Audio(label="Warm Output", type="filepath"),
|
| 778 |
title="Add Analog-Style Warmth",
|
| 779 |
+
description="Enhance clarity and presence using saturation styles like Tube or Tape.",
|
| 780 |
+
allow_flagging="never"
|
| 781 |
)
|
| 782 |
|
| 783 |
# --- Vocal Doubler / Harmonizer โ Added ===
|
|
|
|
| 942 |
fn=live_effect_preview,
|
| 943 |
inputs=[
|
| 944 |
gr.Audio(sources=["microphone"], streaming=True, label="Live Mic Input"),
|
| 945 |
+
gr.Dropdown(choices=["Normalize", "Reverb", "Pitch Shift", "Saturation"]),
|
| 946 |
],
|
| 947 |
outputs=gr.Audio(label="Live Output", type="filepath"),
|
| 948 |
title="Preview Effects in Real-Time",
|
|
|
|
| 1060 |
],
|
| 1061 |
outputs=gr.Audio(label="Natural-Sounding Vocal", type="filepath"),
|
| 1062 |
title="Preserve Vocal Quality During Pitch Shift",
|
| 1063 |
+
description="Make pitch-shifted vocals sound more natural"
|
| 1064 |
)
|
| 1065 |
|
| 1066 |
# --- Voice Swap / Cloning โ New Tab ===
|
|
|
|
| 1097 |
description="Perfect for sharing with producers or archiving"
|
| 1098 |
)
|
| 1099 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1100 |
demo.launch()
|