soiz1 commited on
Commit
ef743d8
·
verified ·
1 Parent(s): d59bbc9

Update app.py

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