-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
183 lines (142 loc) · 4.79 KB
/
app.py
File metadata and controls
183 lines (142 loc) · 4.79 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# Plataform config
from rvc.lib.platform import platform_config
platform_config()
import gradio as gr
import sys
import os
import pathlib
import logging
from typing import Any
DEFAULT_SERVER_NAME = "127.0.0.1"
DEFAULT_PORT = 6969
MAX_PORT_ATTEMPTS = 10
# Set up logging
logging.getLogger("uvicorn").setLevel(logging.WARNING)
logging.getLogger("httpx").setLevel(logging.WARNING)
# Add current directory to sys.path
now_dir = os.getcwd()
sys.path.append(now_dir)
# Zluda hijack
import rvc.lib.zluda
# Import Tabs
from tabs.inference.inference import inference_tab
from tabs.train.train import train_tab
from tabs.extra.extra import extra_tab
from tabs.report.report import report_tab
from tabs.download.download import download_tab
from tabs.tts.tts import tts_tab
from tabs.voice_blender.voice_blender import voice_blender_tab
from tabs.plugins.plugins import plugins_tab
from tabs.settings.settings import settings_tab
from tabs.realtime.realtime import realtime_tab
from tabs.console.console import console_tab
# Run prerequisites (non-blocking: if offline/unreachable, app still starts; user can retry from Train tab)
from core import run_prerequisites_script
try:
run_prerequisites_script(
pretraineds_hifigan=True,
models=True,
exe=True,
)
except Exception as e:
print(f"Prerequisites check/download skipped (will retry when online): {e}")
# Initialize i18n
from assets.i18n.i18n import I18nAuto
i18n = I18nAuto()
# Start Discord presence if enabled
from tabs.settings.sections.presence import load_config_presence
if load_config_presence():
from assets.discord_presence import RPCManager
RPCManager.start_presence()
# Check installation
import assets.installation_checker as installation_checker
installation_checker.check_installation()
# Load theme
import assets.themes.loadThemes as loadThemes
my_applio = loadThemes.load_theme() or "ParityError/Interstellar"
client_mode = "--client" in sys.argv
# Define Gradio interface
with gr.Blocks(
theme=my_applio,
title="Applio",
css="footer{display:none !important}",
js=(
pathlib.Path(os.path.join(now_dir, "tabs", "realtime", "main.js")).read_text()
if client_mode
else None
),
) as Applio:
gr.Markdown("# Applio")
gr.Markdown(
i18n(
"A simple, high-quality voice conversion tool focused on ease of use and performance."
)
)
gr.Markdown(
i18n(
"[Support](https://discord.gg/urxFjYmYYh) — [GitHub](https://github.com/IAHispano/Applio)"
)
)
with gr.Tab(i18n("Inference")):
inference_tab()
with gr.Tab(i18n("Training")):
train_tab()
with gr.Tab(i18n("TTS")):
tts_tab()
with gr.Tab(i18n("Voice Blender")):
voice_blender_tab()
with gr.Tab(i18n("Realtime")):
realtime_tab()
with gr.Tab(i18n("Plugins")):
plugins_tab()
with gr.Tab(i18n("Download")):
download_tab()
with gr.Tab(i18n("Console")):
console_tab()
with gr.Tab(i18n("Report a Bug")):
report_tab()
with gr.Tab(i18n("Extra")):
extra_tab()
with gr.Tab(i18n("Settings")):
settings_tab()
gr.Markdown("""
<div style="text-align: center; font-size: 0.9em; text-color: a3a3a3;">
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.
</div>
""")
def launch_gradio(server_name: str, server_port: int) -> None:
app, _, _ = Applio.launch(
favicon_path="assets/ICON.ico",
share="--share" in sys.argv,
inbrowser="--open" in sys.argv,
server_name=server_name,
server_port=server_port,
prevent_thread_lock=client_mode,
)
if client_mode:
import time
from rvc.realtime.client import app as fastapi_app
app.mount("/api", fastapi_app)
while True:
time.sleep(5)
def get_value_from_args(key: str, default: Any = None) -> Any:
if key in sys.argv:
index = sys.argv.index(key) + 1
if index < len(sys.argv):
return sys.argv[index]
return default
if __name__ == "__main__":
port = int(get_value_from_args("--port", DEFAULT_PORT))
server = get_value_from_args("--server-name", DEFAULT_SERVER_NAME)
for _ in range(MAX_PORT_ATTEMPTS):
try:
launch_gradio(server, 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