Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,34 +2,32 @@ import gradio as gr
|
|
2 |
import librosa
|
3 |
import numpy as np
|
4 |
import os
|
|
|
5 |
|
6 |
# Configuraci贸n
|
7 |
SAMPLE_RATE = 44100
|
|
|
8 |
MODEL_FILES = {
|
9 |
-
"model": "yebama_e200_s3200.pth",
|
10 |
-
"index": "added_IVF403_Flat_nprobe_1_yebama_v2.index",
|
11 |
-
"config": "config.json"
|
12 |
}
|
13 |
|
14 |
def verify_files():
|
15 |
-
"""
|
16 |
-
missing = [f for f in MODEL_FILES.values() if not
|
17 |
if missing:
|
18 |
raise FileNotFoundError(f"Archivos faltantes: {', '.join(missing)}")
|
19 |
|
20 |
def process_audio(audio_path):
|
21 |
try:
|
22 |
-
# 1. Verificar archivos
|
23 |
verify_files()
|
24 |
-
|
25 |
-
# 2. Cargar audio
|
26 |
audio, sr = librosa.load(audio_path, sr=SAMPLE_RATE, mono=True)
|
27 |
|
28 |
-
# --- AQU脥 VA TU
|
29 |
-
#
|
30 |
-
processed_audio = audio # Reemplaza con tu inferencia
|
31 |
|
32 |
-
return (sr, processed_audio.astype(np.float32))
|
33 |
|
34 |
except Exception as e:
|
35 |
raise gr.Error(f"Error: {str(e)}")
|
@@ -39,18 +37,15 @@ with gr.Blocks(title="Yebama RVC") as app:
|
|
39 |
gr.Markdown("## 馃帳 Conversor de Voz Yebama RVC")
|
40 |
with gr.Row():
|
41 |
input_audio = gr.Audio(
|
42 |
-
sources=["upload"
|
43 |
type="filepath",
|
44 |
-
label="
|
45 |
)
|
46 |
output_audio = gr.Audio(
|
47 |
label="Resultado",
|
48 |
-
|
49 |
)
|
50 |
-
gr.Button("Convertir").click(
|
51 |
-
fn=process_audio,
|
52 |
-
inputs=input_audio,
|
53 |
-
outputs=output_audio
|
54 |
-
)
|
55 |
|
56 |
-
|
|
|
|
2 |
import librosa
|
3 |
import numpy as np
|
4 |
import os
|
5 |
+
from pathlib import Path
|
6 |
|
7 |
# Configuraci贸n
|
8 |
SAMPLE_RATE = 44100
|
9 |
+
BASE_DIR = Path(__file__).parent
|
10 |
MODEL_FILES = {
|
11 |
+
"model": BASE_DIR / "yebama_e200_s3200.pth",
|
12 |
+
"index": BASE_DIR / "added_IVF403_Flat_nprobe_1_yebama_v2.index",
|
13 |
+
"config": BASE_DIR / "config.json"
|
14 |
}
|
15 |
|
16 |
def verify_files():
|
17 |
+
"""Verificaci贸n robusta de archivos"""
|
18 |
+
missing = [f.name for f in MODEL_FILES.values() if not f.exists()]
|
19 |
if missing:
|
20 |
raise FileNotFoundError(f"Archivos faltantes: {', '.join(missing)}")
|
21 |
|
22 |
def process_audio(audio_path):
|
23 |
try:
|
|
|
24 |
verify_files()
|
|
|
|
|
25 |
audio, sr = librosa.load(audio_path, sr=SAMPLE_RATE, mono=True)
|
26 |
|
27 |
+
# --- AQU脥 VA TU INFERENCIA RVC ---
|
28 |
+
processed_audio = audio # Placeholder
|
|
|
29 |
|
30 |
+
return (sr, processed_audio.astype(np.float32)) # Tipo expl铆cito
|
31 |
|
32 |
except Exception as e:
|
33 |
raise gr.Error(f"Error: {str(e)}")
|
|
|
37 |
gr.Markdown("## 馃帳 Conversor de Voz Yebama RVC")
|
38 |
with gr.Row():
|
39 |
input_audio = gr.Audio(
|
40 |
+
sources=["upload"],
|
41 |
type="filepath",
|
42 |
+
label="Audio de entrada"
|
43 |
)
|
44 |
output_audio = gr.Audio(
|
45 |
label="Resultado",
|
46 |
+
type="numpy" # Formato 贸ptimo
|
47 |
)
|
48 |
+
gr.Button("Convertir").click(process_audio, input_audio, output_audio)
|
|
|
|
|
|
|
|
|
49 |
|
50 |
+
# Configuraci贸n 贸ptima para Spaces
|
51 |
+
app.launch(server_port=7860, show_error=True)
|