aztro's picture
Update app.py
d021c47 verified
import gradio as gr
import librosa
import numpy as np
import os
from pathlib import Path
# Configuraci贸n
SAMPLE_RATE = 44100
BASE_DIR = Path(__file__).parent
MODEL_FILES = {
"model": BASE_DIR / "yebama_e200_s3200.pth",
"index": BASE_DIR / "added_IVF403_Flat_nprobe_1_yebama_v2.index",
"config": BASE_DIR / "config.json"
}
def verify_files():
"""Verificaci贸n robusta de archivos"""
missing = [f.name for f in MODEL_FILES.values() if not f.exists()]
if missing:
raise FileNotFoundError(f"Archivos faltantes: {', '.join(missing)}")
def process_audio(audio_path):
try:
verify_files()
audio, sr = librosa.load(audio_path, sr=SAMPLE_RATE, mono=True)
# --- AQU脥 VA TU INFERENCIA RVC ---
processed_audio = audio # Placeholder
return (sr, processed_audio.astype(np.float32)) # Tipo expl铆cito
except Exception as e:
raise gr.Error(f"Error: {str(e)}")
# Interfaz
with gr.Blocks(title="Yebama RVC") as app:
gr.Markdown("## 馃帳 Conversor de Voz Yebama RVC")
with gr.Row():
input_audio = gr.Audio(
sources=["upload"],
type="filepath",
label="Audio de entrada"
)
output_audio = gr.Audio(
label="Resultado",
type="numpy" # Formato 贸ptimo
)
gr.Button("Convertir").click(process_audio, input_audio, output_audio)
# Configuraci贸n 贸ptima para Spaces
app.launch(server_port=7860, show_error=True)