-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
65 lines (53 loc) · 1.83 KB
/
main.py
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
import gradio as gr
import sys, os
from tabs.full_inference import full_inference_tab
from tabs.download_model import download_model_tab
from tabs.download_music import download_music_tab
from tabs.settings import select_themes_tab
now_dir = os.getcwd()
sys.path.append(now_dir)
DEFAULT_PORT = 7755
MAX_PORT_ATTEMPTS = 10
from assets.i18n.i18n import I18nAuto
i18n = I18nAuto()
import assets.themes.loadThemes as loadThemes
rvc_theme = loadThemes.load_json() or "ParityError/Interstellar"
with gr.Blocks(
theme=rvc_theme, title="RVC AI Cover Maker", css="footer{display:none !important}"
) as RVCAICoverMaker:
gr.Markdown("# RVC AI Cover Maker")
with gr.Tab(i18n("Full Inference")):
full_inference_tab()
with gr.Tab(i18n("Download Music")):
download_music_tab()
with gr.Tab(i18n("Download Model")):
download_model_tab()
with gr.Tab(i18n("Settings")):
select_themes_tab()
def launch(port):
RVCAICoverMaker.launch(
favicon_path=os.path.join(now_dir, "assets", "logo.ico"),
share="--share" in sys.argv,
inbrowser="--open" in sys.argv,
server_port=port,
)
def get_port_from_args():
if "--port" in sys.argv:
port_index = sys.argv.index("--port") + 1
if port_index < len(sys.argv):
return int(sys.argv[port_index])
return DEFAULT_PORT
if __name__ == "__main__":
port = get_port_from_args()
for _ in range(MAX_PORT_ATTEMPTS):
try:
launch(port)
break
except OSError:
print(
f"Failed to launch on port {port}, trying again on port {port - 1}..."
)
port -= 1
except Exception as error:
print(f"An error occurred launching Gradio: {error}")
break