Yoshitaka16 commited on
Commit
403c29f
·
verified ·
1 Parent(s): 32af46f

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +112 -0
app.py ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import sys
3
+ import os
4
+ import logging
5
+
6
+ # Constants
7
+ DEFAULT_PORT = 7897
8
+ MAX_PORT_ATTEMPTS = 10
9
+
10
+ # Set up logging
11
+ logging.getLogger("uvicorn").setLevel(logging.WARNING)
12
+ logging.getLogger("httpx").setLevel(logging.WARNING)
13
+
14
+ # Add current directory to sys.path
15
+ now_dir = os.getcwd()
16
+ sys.path.append(now_dir)
17
+
18
+ # Zluda hijack
19
+ import rvc.lib.zluda
20
+
21
+ # Import Tabs
22
+ from tabs.inference.inference import inference_tab
23
+ from tabs.train.train import train_tab
24
+ from tabs.utilities.utilities import utilities_tab
25
+ from tabs.download.download import download_tab
26
+ from tabs.tts.tts import tts_tab
27
+ from tabs.voice_blender.voice_blender import voice_blender_tab
28
+ from tabs.settings.settings import settings_tab
29
+
30
+ # Run prerequisites
31
+ from core import run_prerequisites_script
32
+
33
+ run_prerequisites_script(
34
+ pretraineds_hifigan=True,
35
+ models=True,
36
+ exe=True,
37
+ )
38
+
39
+ # Check installation
40
+ import assets.installation_checker as installation_checker
41
+
42
+ installation_checker.check_installation()
43
+
44
+ # Load theme
45
+ import assets.themes.loadThemes as loadThemes
46
+
47
+ CodenameViolet = loadThemes.load_theme() or "ParityError/Interstellar"
48
+
49
+ # Define Gradio interface
50
+ with gr.Blocks(
51
+ theme=CodenameViolet, title="Codename-RVC-Fork 🍇", css="footer{display:none !important}"
52
+ ) as Applio:
53
+ gr.Markdown("# Codename-RVC-Fork 🍇 v4.0.7")
54
+ gr.Markdown(
55
+ "ㅤㅤBased on Applioㅤㅤ"
56
+ )
57
+ gr.Markdown(
58
+ "ㅤㅤㅤ[Support - Community Discord](https://discord.gg/xEqDU7C2z2) ㅤ/ ㅤ[GitHub](https://github.com/codename0og/codename-rvc-fork-4)"
59
+ )
60
+ with gr.Tab("Inference"):
61
+ inference_tab()
62
+
63
+ with gr.Tab("Training"):
64
+ train_tab()
65
+
66
+ with gr.Tab("TTS"):
67
+ tts_tab()
68
+
69
+ with gr.Tab("Voice Blender"):
70
+ voice_blender_tab()
71
+
72
+ with gr.Tab("Download"):
73
+ download_tab()
74
+
75
+ with gr.Tab("Utilities"):
76
+ utilities_tab()
77
+
78
+ with gr.Tab("Settings"):
79
+ settings_tab()
80
+
81
+
82
+ def launch_gradio(port):
83
+ Applio.launch(
84
+ favicon_path="assets/ICON.ico",
85
+ share="--share" in sys.argv,
86
+ inbrowser="--open" in sys.argv,
87
+ server_port=port,
88
+ )
89
+
90
+
91
+ def get_port_from_args():
92
+ if "--port" in sys.argv:
93
+ port_index = sys.argv.index("--port") + 1
94
+ if port_index < len(sys.argv):
95
+ return int(sys.argv[port_index])
96
+ return DEFAULT_PORT
97
+
98
+
99
+ if __name__ == "__main__":
100
+ port = get_port_from_args()
101
+ for _ in range(MAX_PORT_ATTEMPTS):
102
+ try:
103
+ launch_gradio(port)
104
+ break
105
+ except OSError:
106
+ print(
107
+ f"Failed to launch on port {port}, trying again on port {port - 1}..."
108
+ )
109
+ port -= 1
110
+ except Exception as error:
111
+ print(f"An error occurred launching Gradio: {error}")
112
+ break