File size: 2,713 Bytes
8bb5911
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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)