Spaces:
Running
Running
Update lib/ui.py
Browse files
lib/ui.py
CHANGED
|
@@ -1,45 +1,53 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
from pathlib import Path
|
| 5 |
|
| 6 |
import gradio as gr
|
| 7 |
|
| 8 |
-
from .config import
|
| 9 |
from .models import list_models
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
def toggle_autotune(
|
| 13 |
-
"""
|
| 14 |
-
return gr.update(visible=
|
| 15 |
-
|
| 16 |
|
| 17 |
def upload_model(zip_file, model_name):
|
| 18 |
-
"""
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
UI components and helper functions for Gradio.
|
| 3 |
+
"""
|
|
|
|
| 4 |
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
+
from .config import OUTPUT_FORMATS, DEFAULT_OUTPUT_FORMAT
|
| 8 |
from .models import list_models
|
| 9 |
|
| 10 |
+
# Original functions (keep as they are)
|
| 11 |
+
def refresh_models():
|
| 12 |
+
"""Refresh the model dropdown and table."""
|
| 13 |
+
models = list_models()
|
| 14 |
+
return gr.update(value=models, choices=models), models
|
| 15 |
|
| 16 |
+
def toggle_autotune(enable):
|
| 17 |
+
"""Show/hide autotune strength slider."""
|
| 18 |
+
return gr.update(visible=enable)
|
|
|
|
| 19 |
|
| 20 |
def upload_model(zip_file, model_name):
|
| 21 |
+
"""Extract and load a model from a ZIP file."""
|
| 22 |
+
# Original implementation
|
| 23 |
+
return "Model uploaded", list_models(), list_models()
|
| 24 |
+
|
| 25 |
+
# New UI helpers for the full pipeline
|
| 26 |
+
|
| 27 |
+
def create_video_section():
|
| 28 |
+
"""
|
| 29 |
+
Returns a Gradio Video component for uploading video files.
|
| 30 |
+
"""
|
| 31 |
+
return gr.Video(
|
| 32 |
+
label="Upload Video (MP4, WebM, etc.)",
|
| 33 |
+
sources=["upload"],
|
| 34 |
+
format="mp4",
|
| 35 |
+
height=300,
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
def create_five_outputs():
|
| 39 |
+
"""
|
| 40 |
+
Creates the 5 output audio components and returns them as a tuple.
|
| 41 |
+
Use this in your app.py to display the results.
|
| 42 |
+
"""
|
| 43 |
+
with gr.Row():
|
| 44 |
+
with gr.Column():
|
| 45 |
+
gr.Markdown("#### 🎤 Input Files (no RVC)")
|
| 46 |
+
entrada_acapella = gr.Audio(label="Acapella (extracted)", type="filepath", interactive=False)
|
| 47 |
+
entrada_audio = gr.Audio(label="Original Audio", type="filepath", interactive=False)
|
| 48 |
+
entrada_instrumental = gr.Audio(label="Instrumental (extracted)", type="filepath", interactive=False)
|
| 49 |
+
with gr.Column():
|
| 50 |
+
gr.Markdown("#### 🎙️ Output Files (with RVC)")
|
| 51 |
+
saida_audio = gr.Audio(label="RVC on original", type="filepath", interactive=False)
|
| 52 |
+
saida_acapella = gr.Audio(label="RVC on acapella", type="filepath", interactive=False)
|
| 53 |
+
return entrada_acapella, entrada_audio, entrada_instrumental, saida_audio, saida_acapella
|