neopy-neorvc / app.py
NeoPy's picture
Upload folder using huggingface_hub
8bb5911 verified
import argparse
import logging
import os
import sys
import os
from functools import lru_cache
import gradio as gr
# non module import
from tabs.typing_extra import ALLOWED_DIR, CONFIG
import assets.theme.loadThemes as loadThemes
from assets.theme.applio import Applio
from tabs.infer.infer import inference_tab
from tabs.models.model import download_tab, model_manage_tab
from tabs.help.help import help_tab
# Configure logging
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
handlers=[logging.StreamHandler(), logging.FileHandler('neorvc.log')]
)
logger = logging.getLogger(__name__)
# Base directory setup
BASE_DIR = os.getcwd()
sys.path.append(BASE_DIR)
def build_ui():
"""Build the Gradio UI with separated tab functions."""
with gr.Blocks(
title="Neo RVC",
theme=Applio(),
fill_height=True,
) as app:
gr.Markdown("# Neo RVC: AI Voice extension")
status_message = gr.Textbox(
label="Status",
lines=2,
interactive=False,
elem_classes=["success", "error"],
visible=False
)
# Placeholder for rvc_model to be shared across tabs
rvc_model = gr.State(value=None)
with gr.Tabs():
rvc_model = inference_tab(status_message, rvc_model)
with gr.TabItem("Models Options"):
download_tab(status_message, rvc_model)
model_manage_tab(status_message, rvc_model)
help_tab()
return app
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Neo RVC GUI')
parser.add_argument("--share", action="store_true", help="Enable public sharing")
parser.add_argument("--listen", action="store_true", help="Make WebUI reachable from local network")
parser.add_argument('--listen-host', type=str, default='0.0.0.0', help='Server hostname')
parser.add_argument('--listen-port', type=int, default=7860, help='Server port')
args = parser.parse_args()
try:
app = build_ui()
print("* launching WebUI....")
app.launch(
share=args.share,
server_name=args.listen_host if args.listen else '127.0.0.1',
server_port=args.listen_port,
favicon_path=os.path.join("assets", "favicon.ico"),
allowed_paths=[ALLOWED_DIR],
show_error=True,
max_file_size=CONFIG['max_upload_size_mb'] * 1024 * 1024
)
except Exception as e:
logger.error(f"Failed to launch application: {e}\n{format_exc()}")
print(f"Error launching application: {e}. Check neorvc.log for details.")
sys.exit(1)