Spaces:
Sleeping
Sleeping
change model
Browse files
app.py
CHANGED
|
@@ -2,45 +2,52 @@ import gradio as gr
|
|
| 2 |
from audio_separator.separator import Separator
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
def
|
| 6 |
if audio_path is None:
|
| 7 |
return None, None
|
| 8 |
|
| 9 |
-
#
|
| 10 |
base_name = os.path.splitext(os.path.basename(audio_path))[0]
|
| 11 |
clean_name = base_name.split('-')[0] if '-' in base_name else base_name
|
| 12 |
|
| 13 |
-
# Inizializziamo il separatore
|
| 14 |
-
# Specifichiamo
|
| 15 |
separator = Separator()
|
| 16 |
|
| 17 |
try:
|
| 18 |
-
#
|
| 19 |
-
model_name = 'UVR-MDX-NET-
|
|
|
|
|
|
|
| 20 |
separator.load_model(model_name)
|
| 21 |
|
| 22 |
-
#
|
|
|
|
| 23 |
output_files = separator.separate(audio_path)
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
v_final = f"{clean_name} (Vocals) (Aura-V1).wav"
|
| 27 |
-
i_final = f"{clean_name} (Instrumental) (Aura-V1).wav"
|
| 28 |
|
| 29 |
-
# Spostiamo i file generati
|
| 30 |
os.rename(output_files[0], v_final)
|
| 31 |
os.rename(output_files[1], i_final)
|
| 32 |
|
|
|
|
| 33 |
return v_final, i_final
|
|
|
|
| 34 |
except Exception as e:
|
| 35 |
-
print(f"❌ Errore
|
| 36 |
return None, None
|
| 37 |
|
| 38 |
-
# Interfaccia
|
| 39 |
with gr.Blocks() as demo:
|
| 40 |
-
gr.Markdown("# 🌌 Aura Engine v0.
|
| 41 |
-
gr.Markdown("Proprietà di **ALEeMAYAyt** |
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
input_audio = gr.Audio(label="Traccia Input", type="filepath")
|
| 44 |
btn = gr.Button("ELABORA CON AURA", variant="primary")
|
| 45 |
|
| 46 |
with gr.Row():
|
|
@@ -48,11 +55,11 @@ with gr.Blocks() as demo:
|
|
| 48 |
i_out = gr.Audio(label="🎸 Instrumental")
|
| 49 |
|
| 50 |
btn.click(
|
| 51 |
-
fn=
|
| 52 |
inputs=input_audio,
|
| 53 |
outputs=[v_out, i_out],
|
| 54 |
api_name="predict"
|
| 55 |
)
|
| 56 |
|
| 57 |
-
#
|
| 58 |
demo.launch(theme=gr.themes.Soft())
|
|
|
|
| 2 |
from audio_separator.separator import Separator
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
def aura_separate_beta(audio_path):
|
| 6 |
if audio_path is None:
|
| 7 |
return None, None
|
| 8 |
|
| 9 |
+
# Pulizia nome file per il tuo brand ALEeMAYAyt
|
| 10 |
base_name = os.path.splitext(os.path.basename(audio_path))[0]
|
| 11 |
clean_name = base_name.split('-')[0] if '-' in base_name else base_name
|
| 12 |
|
| 13 |
+
# Inizializziamo il separatore professionale
|
| 14 |
+
# Specifichiamo una cartella temporanea per i modelli
|
| 15 |
separator = Separator()
|
| 16 |
|
| 17 |
try:
|
| 18 |
+
# 1. IL MODELLO: Questo è lo standard per le basi pulite (Instrumental HQ)
|
| 19 |
+
model_name = 'UVR-MDX-NET-Inst_HQ_3.onnx'
|
| 20 |
+
|
| 21 |
+
print(f"--- Caricamento Modello Professional: {model_name} ---")
|
| 22 |
separator.load_model(model_name)
|
| 23 |
|
| 24 |
+
# 2. SEPARAZIONE: Usiamo parametri che bilanciano qualità e velocità su CPU
|
| 25 |
+
# La libreria scaricherà il modello se non è presente
|
| 26 |
output_files = separator.separate(audio_path)
|
| 27 |
|
| 28 |
+
# 3. RINOMINA: Formato richiesto per la tua Beta
|
| 29 |
+
v_final = f"{clean_name} (Vocals) (Aura-V1-Beta).wav"
|
| 30 |
+
i_final = f"{clean_name} (Instrumental) (Aura-V1-Beta).wav"
|
| 31 |
|
| 32 |
+
# Spostiamo i file generati (output_files è una lista: [Vocals, Instrumental])
|
| 33 |
os.rename(output_files[0], v_final)
|
| 34 |
os.rename(output_files[1], i_final)
|
| 35 |
|
| 36 |
+
print(f"✅ Separazione completata per: {clean_name}")
|
| 37 |
return v_final, i_final
|
| 38 |
+
|
| 39 |
except Exception as e:
|
| 40 |
+
print(f"❌ Errore critico nel motore Beta: {e}")
|
| 41 |
return None, None
|
| 42 |
|
| 43 |
+
# Interfaccia pulita per lo Space
|
| 44 |
with gr.Blocks() as demo:
|
| 45 |
+
gr.Markdown("# 🌌 Aura Engine v0.7 (BETA)")
|
| 46 |
+
gr.Markdown("Proprietà di **ALEeMAYAyt** | Test Modello MDX-Net Inst_HQ_3")
|
| 47 |
+
|
| 48 |
+
with gr.Row():
|
| 49 |
+
input_audio = gr.Audio(label="Traccia Input", type="filepath")
|
| 50 |
|
|
|
|
| 51 |
btn = gr.Button("ELABORA CON AURA", variant="primary")
|
| 52 |
|
| 53 |
with gr.Row():
|
|
|
|
| 55 |
i_out = gr.Audio(label="🎸 Instrumental")
|
| 56 |
|
| 57 |
btn.click(
|
| 58 |
+
fn=aura_separate_beta,
|
| 59 |
inputs=input_audio,
|
| 60 |
outputs=[v_out, i_out],
|
| 61 |
api_name="predict"
|
| 62 |
)
|
| 63 |
|
| 64 |
+
# Lancio ottimizzato
|
| 65 |
demo.launch(theme=gr.themes.Soft())
|