Yoshitaka16 commited on
Commit
e3dad9c
·
verified ·
1 Parent(s): 29bf423

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +154 -0
app.py ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import sys
3
+ import os
4
+ import logging
5
+
6
+ from typing import Any
7
+
8
+ DEFAULT_SERVER_NAME = "127.0.0.1"
9
+ DEFAULT_PORT = 6969
10
+ MAX_PORT_ATTEMPTS = 10
11
+
12
+ # Set up logging
13
+ logging.getLogger("uvicorn").setLevel(logging.WARNING)
14
+ logging.getLogger("httpx").setLevel(logging.WARNING)
15
+
16
+ # Add current directory to sys.path
17
+ now_dir = os.getcwd()
18
+ sys.path.append(now_dir)
19
+
20
+ # Zluda hijack
21
+ import rvc.lib.zluda
22
+
23
+ # Import Tabs
24
+ from tabs.inference.inference import inference_tab
25
+ from tabs.train.train import train_tab
26
+ from tabs.extra.extra import extra_tab
27
+ from tabs.report.report import report_tab
28
+ from tabs.download.download import download_tab
29
+ from tabs.tts.tts import tts_tab
30
+ from tabs.voice_blender.voice_blender import voice_blender_tab
31
+ from tabs.plugins.plugins import plugins_tab
32
+ from tabs.settings.settings import settings_tab
33
+ from tabs.realtime.realtime import realtime_tab
34
+
35
+ # Run prerequisites
36
+ from core import run_prerequisites_script
37
+
38
+ run_prerequisites_script(
39
+ pretraineds_hifigan=True,
40
+ models=True,
41
+ exe=True,
42
+ )
43
+
44
+ # Initialize i18n
45
+ from assets.i18n.i18n import I18nAuto
46
+
47
+ i18n = I18nAuto()
48
+
49
+ # Start Discord presence if enabled
50
+ from tabs.settings.sections.presence import load_config_presence
51
+
52
+ if load_config_presence():
53
+ from assets.discord_presence import RPCManager
54
+
55
+ RPCManager.start_presence()
56
+
57
+ # Check installation
58
+ import assets.installation_checker as installation_checker
59
+
60
+ installation_checker.check_installation()
61
+
62
+ # Load theme
63
+ import assets.themes.loadThemes as loadThemes
64
+
65
+ my_applio = loadThemes.load_theme() or "ParityError/Interstellar"
66
+
67
+ # Define Gradio interface
68
+ with gr.Blocks(
69
+ theme=my_applio, title="Applio", css="footer{display:none !important}"
70
+ ) as Applio:
71
+ gr.Markdown("# Applio")
72
+ gr.Markdown(
73
+ i18n(
74
+ "A simple, high-quality voice conversion tool focused on ease of use and performance."
75
+ )
76
+ )
77
+ gr.Markdown(
78
+ i18n(
79
+ "[Support](https://discord.gg/urxFjYmYYh) — [GitHub](https://github.com/IAHispano/Applio)"
80
+ )
81
+ )
82
+ with gr.Tab(i18n("Inference")):
83
+ inference_tab()
84
+
85
+ with gr.Tab(i18n("Training")):
86
+ train_tab()
87
+
88
+ with gr.Tab(i18n("TTS")):
89
+ tts_tab()
90
+
91
+ with gr.Tab(i18n("Voice Blender")):
92
+ voice_blender_tab()
93
+
94
+ with gr.Tab(i18n("Realtime")):
95
+ realtime_tab()
96
+
97
+ with gr.Tab(i18n("Plugins")):
98
+ plugins_tab()
99
+
100
+ with gr.Tab(i18n("Download")):
101
+ download_tab()
102
+
103
+ with gr.Tab(i18n("Report a Bug")):
104
+ report_tab()
105
+
106
+ with gr.Tab(i18n("Extra")):
107
+ extra_tab()
108
+
109
+ with gr.Tab(i18n("Settings")):
110
+ settings_tab()
111
+
112
+ gr.Markdown(
113
+ """
114
+ <div style="text-align: center; font-size: 0.9em; text-color: a3a3a3;">
115
+ By using Applio, you agree to comply with ethical and legal standards, respect intellectual property and privacy rights, avoid harmful or prohibited uses, and accept full responsibility for any outcomes, while Applio disclaims liability and reserves the right to amend these terms.
116
+ </div>
117
+ """
118
+ )
119
+
120
+
121
+ def launch_gradio(server_name: str, server_port: int) -> None:
122
+ Applio.launch(
123
+ favicon_path="assets/ICON.ico",
124
+ share="--share" in sys.argv,
125
+ inbrowser="--open" in sys.argv,
126
+ server_name=server_name,
127
+ server_port=server_port,
128
+ )
129
+
130
+
131
+ def get_value_from_args(key: str, default: Any = None) -> Any:
132
+ if key in sys.argv:
133
+ index = sys.argv.index(key) + 1
134
+ if index < len(sys.argv):
135
+ return sys.argv[index]
136
+ return default
137
+
138
+
139
+ if __name__ == "__main__":
140
+ port = int(get_value_from_args("--port", DEFAULT_PORT))
141
+ server = get_value_from_args("--server-name", DEFAULT_SERVER_NAME)
142
+
143
+ for _ in range(MAX_PORT_ATTEMPTS):
144
+ try:
145
+ launch_gradio(server, port)
146
+ break
147
+ except OSError:
148
+ print(
149
+ f"Failed to launch on port {port}, trying again on port {port - 1}..."
150
+ )
151
+ port -= 1
152
+ except Exception as error:
153
+ print(f"An error occurred launching Gradio: {error}")
154
+ break