From 7e491c1e1aa16d13743f34c9e04ccef2b421fe20 Mon Sep 17 00:00:00 2001 From: Blaise Date: Sat, 21 Dec 2024 20:29:18 +0100 Subject: [PATCH] improve extra and settings tab --- tabs/extra/extra.py | 14 ++----- tabs/extra/{analyzer => sections}/analyzer.py | 0 .../f0_extractor.py | 42 +++++++++---------- .../{processing => sections}/processing.py | 12 ++---- tabs/settings/settings.py | 17 ++++---- 5 files changed, 38 insertions(+), 47 deletions(-) rename tabs/extra/{analyzer => sections}/analyzer.py (100%) rename tabs/extra/{f0_extractor => sections}/f0_extractor.py (59%) rename tabs/extra/{processing => sections}/processing.py (83%) diff --git a/tabs/extra/extra.py b/tabs/extra/extra.py index eeb25649d..99426015f 100644 --- a/tabs/extra/extra.py +++ b/tabs/extra/extra.py @@ -1,14 +1,13 @@ -import gradio as gr - import os import sys +import gradio as gr now_dir = os.getcwd() sys.path.append(now_dir) -from tabs.extra.processing.processing import processing_tab -from tabs.extra.analyzer.analyzer import analyzer_tab -from tabs.extra.f0_extractor.f0_extractor import f0_extractor_tab +from tabs.extra.sections.processing import processing_tab +from tabs.extra.sections.analyzer import analyzer_tab +from tabs.extra.sections.f0_extractor import f0_extractor_tab from assets.i18n.i18n import I18nAuto @@ -16,11 +15,6 @@ def extra_tab(): - gr.Markdown( - value=i18n( - "This section contains some extra utilities that often may be in experimental phases." - ) - ) with gr.TabItem(i18n("Model information")): processing_tab() diff --git a/tabs/extra/analyzer/analyzer.py b/tabs/extra/sections/analyzer.py similarity index 100% rename from tabs/extra/analyzer/analyzer.py rename to tabs/extra/sections/analyzer.py diff --git a/tabs/extra/f0_extractor/f0_extractor.py b/tabs/extra/sections/f0_extractor.py similarity index 59% rename from tabs/extra/f0_extractor/f0_extractor.py rename to tabs/extra/sections/f0_extractor.py index 96af31042..8a6c546c9 100644 --- a/tabs/extra/f0_extractor/f0_extractor.py +++ b/tabs/extra/sections/f0_extractor.py @@ -1,6 +1,6 @@ +import os import librosa import gradio as gr -import os from matplotlib import pyplot as plt from rvc.lib.predictors.F0Extractor import F0Extractor @@ -41,28 +41,26 @@ def extract_f0_curve(audio_path: str, method: str): def f0_extractor_tab(): - with gr.Accordion(label=i18n("Extract F0 Curve")): - with gr.Row(): - audio = gr.Audio(label=i18n("Upload Audio"), type="filepath") - f0_method = gr.Radio( - label=i18n("Pitch extraction algorithm"), - info=i18n( - "Pitch extraction algorithm to use for the audio conversion. The default algorithm is rmvpe, which is recommended for most cases." - ), - choices=["crepe", "fcpe", "rmvpe"], - value="rmvpe", - ) - button = gr.Button(i18n("Extract F0 Curve")) + audio = gr.Audio(label=i18n("Upload Audio"), type="filepath") + f0_method = gr.Radio( + label=i18n("Pitch extraction algorithm"), + info=i18n( + "Pitch extraction algorithm to use for the audio conversion. The default algorithm is rmvpe, which is recommended for most cases." + ), + choices=["crepe", "fcpe", "rmvpe"], + value="rmvpe", + ) + button = gr.Button(i18n("Extract F0 Curve")) - with gr.Accordion(label=i18n("Output Information")): + with gr.Row(): txt_output = gr.File(label="F0 Curve", type="filepath") image_output = gr.Image(type="filepath", interactive=False) - button.click( - fn=extract_f0_curve, - inputs=[ - audio, - f0_method, - ], - outputs=[image_output, txt_output], - ) + button.click( + fn=extract_f0_curve, + inputs=[ + audio, + f0_method, + ], + outputs=[image_output, txt_output], + ) diff --git a/tabs/extra/processing/processing.py b/tabs/extra/sections/processing.py similarity index 83% rename from tabs/extra/processing/processing.py rename to tabs/extra/sections/processing.py index 1d01a7106..631c0a016 100644 --- a/tabs/extra/processing/processing.py +++ b/tabs/extra/sections/processing.py @@ -1,4 +1,6 @@ -import os, sys +import os +import sys +import gradio as gr now_dir = os.getcwd() sys.path.append(now_dir) @@ -8,14 +10,8 @@ i18n = I18nAuto() -import gradio as gr - - def processing_tab(): - with gr.Accordion(label=i18n("View model information")): - with gr.Row(): - with gr.Column(): - model_view_model_path = gr.Textbox( + model_view_model_path = gr.Textbox( label=i18n("Path to Model"), info=i18n("Introduce the model pth path"), value="", diff --git a/tabs/settings/settings.py b/tabs/settings/settings.py index 02be8952f..85473274a 100644 --- a/tabs/settings/settings.py +++ b/tabs/settings/settings.py @@ -1,5 +1,6 @@ import os import sys +import gradio as gr now_dir = os.getcwd() sys.path.append(now_dir) @@ -14,10 +15,12 @@ def settings_tab(): - presence_tab() - precision_tab() - theme_tab() - version_tab() - lang_tab() - restart_tab() - model_author_tab() + with gr.TabItem(label="General"): + presence_tab() + theme_tab() + version_tab() + lang_tab() + restart_tab() + with gr.TabItem(label="Inference & Training"): + precision_tab() + model_author_tab()