Spaces:
Running
Running
Aitron Emper
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,135 +1,135 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import sys
|
3 |
-
import os
|
4 |
-
import logging
|
5 |
-
|
6 |
-
now_dir = os.getcwd()
|
7 |
-
sys.path.append(now_dir)
|
8 |
-
|
9 |
-
# Tabs
|
10 |
-
from tabs.inference.inference import inference_tab
|
11 |
-
from tabs.train.train import train_tab
|
12 |
-
from tabs.extra.extra import extra_tab
|
13 |
-
from tabs.report.report import report_tab
|
14 |
-
from tabs.download.download import download_tab
|
15 |
-
from tabs.tts.tts import tts_tab
|
16 |
-
from tabs.voice_blender.voice_blender import voice_blender_tab
|
17 |
-
from tabs.settings.presence import presence_tab, load_config_presence
|
18 |
-
from tabs.settings.flask_server import flask_server_tab
|
19 |
-
from tabs.settings.fake_gpu import fake_gpu_tab, gpu_available, load_fake_gpu
|
20 |
-
from tabs.settings.themes import theme_tab
|
21 |
-
from tabs.plugins.plugins import plugins_tab
|
22 |
-
from tabs.settings.version import version_tab
|
23 |
-
from tabs.settings.lang import lang_tab
|
24 |
-
from tabs.settings.restart import restart_tab
|
25 |
-
|
26 |
-
# Assets
|
27 |
-
import assets.themes.loadThemes as loadThemes
|
28 |
-
from assets.i18n.i18n import I18nAuto
|
29 |
-
import assets.installation_checker as installation_checker
|
30 |
-
from assets.discord_presence import RPCManager
|
31 |
-
from assets.flask.server import start_flask, load_config_flask
|
32 |
-
from core import run_prerequisites_script
|
33 |
-
|
34 |
-
run_prerequisites_script("False", "True", "True", "True")
|
35 |
-
|
36 |
-
i18n = I18nAuto()
|
37 |
-
if load_config_presence() == True:
|
38 |
-
RPCManager.start_presence()
|
39 |
-
installation_checker.check_installation()
|
40 |
-
logging.getLogger("uvicorn").disabled = True
|
41 |
-
logging.getLogger("fairseq").disabled = True
|
42 |
-
if load_config_flask() == True:
|
43 |
-
print("Starting Flask server")
|
44 |
-
start_flask()
|
45 |
-
|
46 |
-
my_applio = loadThemes.load_json()
|
47 |
-
if my_applio:
|
48 |
-
pass
|
49 |
-
else:
|
50 |
-
my_applio = "ParityError/Interstellar"
|
51 |
-
|
52 |
-
with gr.Blocks(theme=my_applio, title="Applio") as Applio:
|
53 |
-
gr.Markdown("# Applio")
|
54 |
-
gr.Markdown(
|
55 |
-
i18n(
|
56 |
-
"Ultimate voice cloning tool, meticulously optimized for unrivaled power, modularity, and user-friendly experience."
|
57 |
-
)
|
58 |
-
)
|
59 |
-
gr.Markdown(
|
60 |
-
i18n(
|
61 |
-
"[Support](https://discord.gg/IAHispano) β [Discord Bot](https://discord.com/oauth2/authorize?client_id=1144714449563955302&permissions=1376674695271&scope=bot%20applications.commands) β [Find Voices](https://applio.org/models) β [GitHub](https://github.com/IAHispano/Applio)"
|
62 |
-
)
|
63 |
-
)
|
64 |
-
with gr.Tab(i18n("Inference")):
|
65 |
-
inference_tab()
|
66 |
-
|
67 |
-
with gr.Tab(i18n("Train")):
|
68 |
-
if gpu_available() or load_fake_gpu():
|
69 |
-
train_tab()
|
70 |
-
else:
|
71 |
-
gr.Markdown(
|
72 |
-
i18n(
|
73 |
-
"Training is currently unsupported due to the absence of a GPU. To activate the training tab, navigate to the settings tab and enable the 'Fake GPU' option."
|
74 |
-
)
|
75 |
-
)
|
76 |
-
|
77 |
-
with gr.Tab(i18n("TTS")):
|
78 |
-
tts_tab()
|
79 |
-
|
80 |
-
with gr.Tab(i18n("Voice Blender")):
|
81 |
-
voice_blender_tab()
|
82 |
-
|
83 |
-
with gr.Tab(i18n("Plugins")):
|
84 |
-
plugins_tab()
|
85 |
-
|
86 |
-
with gr.Tab(i18n("Download")):
|
87 |
-
download_tab()
|
88 |
-
|
89 |
-
with gr.Tab(i18n("Report a Bug")):
|
90 |
-
report_tab()
|
91 |
-
|
92 |
-
with gr.Tab(i18n("Extra")):
|
93 |
-
extra_tab()
|
94 |
-
|
95 |
-
with gr.Tab(i18n("Settings")):
|
96 |
-
presence_tab()
|
97 |
-
flask_server_tab()
|
98 |
-
if not gpu_available():
|
99 |
-
fake_gpu_tab()
|
100 |
-
theme_tab()
|
101 |
-
version_tab()
|
102 |
-
lang_tab()
|
103 |
-
restart_tab()
|
104 |
-
|
105 |
-
|
106 |
-
def launch_gradio(port):
|
107 |
-
Applio.launch(
|
108 |
-
favicon_path="assets/ICON.ico",
|
109 |
-
share="--share" in sys.argv,
|
110 |
-
inbrowser="--open" in sys.argv,
|
111 |
-
server_port=port,
|
112 |
-
)
|
113 |
-
|
114 |
-
|
115 |
-
if __name__ == "__main__":
|
116 |
-
port = 6969
|
117 |
-
if "--port" in sys.argv:
|
118 |
-
port_index = sys.argv.index("--port") + 1
|
119 |
-
if port_index < len(sys.argv):
|
120 |
-
port = int(sys.argv[port_index])
|
121 |
-
|
122 |
-
launch_gradio(port)
|
123 |
-
|
124 |
-
else:
|
125 |
-
# if launch fails, decrement port number and try again (up to 10 times)
|
126 |
-
for i in range(10):
|
127 |
-
try:
|
128 |
-
launch_gradio(port)
|
129 |
-
break
|
130 |
-
except OSError:
|
131 |
-
print("Failed to launch on port", port, "- trying again...")
|
132 |
-
port -= 1
|
133 |
-
except Exception as e:
|
134 |
-
print(f"Unexpected error during launch: {e}")
|
135 |
-
break
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import sys
|
3 |
+
import os
|
4 |
+
import logging
|
5 |
+
|
6 |
+
now_dir = os.getcwd()
|
7 |
+
sys.path.append(now_dir)
|
8 |
+
|
9 |
+
# Tabs
|
10 |
+
from tabs.inference.inference import inference_tab
|
11 |
+
from tabs.train.train import train_tab
|
12 |
+
from tabs.extra.extra import extra_tab
|
13 |
+
from tabs.report.report import report_tab
|
14 |
+
from tabs.download.download import download_tab
|
15 |
+
from tabs.tts.tts import tts_tab
|
16 |
+
from tabs.voice_blender.voice_blender import voice_blender_tab
|
17 |
+
from tabs.settings.presence import presence_tab, load_config_presence
|
18 |
+
from tabs.settings.flask_server import flask_server_tab
|
19 |
+
from tabs.settings.fake_gpu import fake_gpu_tab, gpu_available, load_fake_gpu
|
20 |
+
from tabs.settings.themes import theme_tab
|
21 |
+
from tabs.plugins.plugins import plugins_tab
|
22 |
+
from tabs.settings.version import version_tab
|
23 |
+
from tabs.settings.lang import lang_tab
|
24 |
+
from tabs.settings.restart import restart_tab
|
25 |
+
|
26 |
+
# Assets
|
27 |
+
import assets.themes.loadThemes as loadThemes
|
28 |
+
from assets.i18n.i18n import I18nAuto
|
29 |
+
import assets.installation_checker as installation_checker
|
30 |
+
from assets.discord_presence import RPCManager
|
31 |
+
from assets.flask.server import start_flask, load_config_flask
|
32 |
+
from core import run_prerequisites_script
|
33 |
+
|
34 |
+
run_prerequisites_script("False", "True", "True", "True")
|
35 |
+
|
36 |
+
i18n = I18nAuto()
|
37 |
+
if load_config_presence() == True:
|
38 |
+
RPCManager.start_presence()
|
39 |
+
installation_checker.check_installation()
|
40 |
+
logging.getLogger("uvicorn").disabled = True
|
41 |
+
logging.getLogger("fairseq").disabled = True
|
42 |
+
if load_config_flask() == True:
|
43 |
+
print("Starting Flask server")
|
44 |
+
start_flask()
|
45 |
+
|
46 |
+
my_applio = loadThemes.load_json()
|
47 |
+
if my_applio:
|
48 |
+
pass
|
49 |
+
else:
|
50 |
+
my_applio = "ParityError/Interstellar"
|
51 |
+
|
52 |
+
with gr.Blocks(theme=my_applio, title="Applio") as Applio:
|
53 |
+
gr.Markdown("# Applio")
|
54 |
+
gr.Markdown(
|
55 |
+
i18n(
|
56 |
+
"Ultimate voice cloning tool, meticulously optimized for unrivaled power, modularity, and user-friendly experience."
|
57 |
+
)
|
58 |
+
)
|
59 |
+
gr.Markdown(
|
60 |
+
i18n(
|
61 |
+
"[Support](https://discord.gg/IAHispano) β [Discord Bot](https://discord.com/oauth2/authorize?client_id=1144714449563955302&permissions=1376674695271&scope=bot%20applications.commands) β [Find Voices](https://applio.org/models) β [GitHub](https://github.com/IAHispano/Applio)"
|
62 |
+
)
|
63 |
+
)
|
64 |
+
with gr.Tab(i18n("Inference")):
|
65 |
+
inference_tab()
|
66 |
+
|
67 |
+
with gr.Tab(i18n("Train")):
|
68 |
+
if gpu_available() or load_fake_gpu():
|
69 |
+
train_tab()
|
70 |
+
else:
|
71 |
+
gr.Markdown(
|
72 |
+
i18n(
|
73 |
+
"Training is currently unsupported due to the absence of a GPU. To activate the training tab, navigate to the settings tab and enable the 'Fake GPU' option."
|
74 |
+
)
|
75 |
+
)
|
76 |
+
|
77 |
+
with gr.Tab(i18n("TTS")):
|
78 |
+
tts_tab()
|
79 |
+
|
80 |
+
# with gr.Tab(i18n("Voice Blender")):
|
81 |
+
# voice_blender_tab()
|
82 |
+
|
83 |
+
# with gr.Tab(i18n("Plugins")):
|
84 |
+
# plugins_tab()
|
85 |
+
|
86 |
+
with gr.Tab(i18n("Download")):
|
87 |
+
download_tab()
|
88 |
+
|
89 |
+
with gr.Tab(i18n("Report a Bug")):
|
90 |
+
report_tab()
|
91 |
+
|
92 |
+
with gr.Tab(i18n("Extra")):
|
93 |
+
extra_tab()
|
94 |
+
|
95 |
+
# with gr.Tab(i18n("Settings")):
|
96 |
+
# presence_tab()
|
97 |
+
# flask_server_tab()
|
98 |
+
# if not gpu_available():
|
99 |
+
# fake_gpu_tab()
|
100 |
+
# theme_tab()
|
101 |
+
# version_tab()
|
102 |
+
# lang_tab()
|
103 |
+
# restart_tab()
|
104 |
+
|
105 |
+
|
106 |
+
def launch_gradio(port):
|
107 |
+
Applio.launch(
|
108 |
+
favicon_path="assets/ICON.ico",
|
109 |
+
share="--share" in sys.argv,
|
110 |
+
inbrowser="--open" in sys.argv,
|
111 |
+
server_port=port,
|
112 |
+
)
|
113 |
+
|
114 |
+
|
115 |
+
if __name__ == "__main__":
|
116 |
+
port = 6969
|
117 |
+
if "--port" in sys.argv:
|
118 |
+
port_index = sys.argv.index("--port") + 1
|
119 |
+
if port_index < len(sys.argv):
|
120 |
+
port = int(sys.argv[port_index])
|
121 |
+
|
122 |
+
launch_gradio(port)
|
123 |
+
|
124 |
+
else:
|
125 |
+
# if launch fails, decrement port number and try again (up to 10 times)
|
126 |
+
for i in range(10):
|
127 |
+
try:
|
128 |
+
launch_gradio(port)
|
129 |
+
break
|
130 |
+
except OSError:
|
131 |
+
print("Failed to launch on port", port, "- trying again...")
|
132 |
+
port -= 1
|
133 |
+
except Exception as e:
|
134 |
+
print(f"Unexpected error during launch: {e}")
|
135 |
+
break
|