Skip to content

Commit

Permalink
[Update to v1.3.0 - Part 4] — Added offline interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Bebra777228 committed Nov 21, 2024
1 parent ed31e92 commit ae856db
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions app_offline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import os
import sys

import gradio as gr

from tabs.conversion.conversion import conversion_tab
from tabs.install.install_models import files_upload, zip_upload
from tabs.uvr.uvr import uvr_tab
from tabs.welcome import welcome_tab

DEFAULT_PORT = 4000
MAX_PORT_ATTEMPTS = 10


with gr.Blocks(
title="PolGen - Politrees",
css="footer{display:none !important}",
theme=gr.themes.Soft(
primary_hue="green",
secondary_hue="green",
neutral_hue="neutral",
spacing_size="sm",
radius_size="lg",
),
) as PolGen:

with gr.Tab("Велком/Контакты"):
welcome_tab()

with gr.Tab("Преобразование голоса (RVC)"):
conversion_tab()

with gr.Tab("Разделение аудио (UVR)"):
uvr_tab()

with gr.Tab("Загрузка RVC моделей"):
zip_upload()
files_upload()


def launch(port):
PolGen.launch(
favicon_path=os.path.join(os.getcwd(), "assets", "logo.ico"),
share="--share" in sys.argv,
inbrowser="--open" in sys.argv,
server_port=port,
)


def get_port_from_args():
if "--port" in sys.argv:
port_index = sys.argv.index("--port") + 1
if port_index < len(sys.argv):
return int(sys.argv[port_index])
return DEFAULT_PORT


if __name__ == "__main__":
port = get_port_from_args()
for _ in range(MAX_PORT_ATTEMPTS):
try:
launch(port)
break
except OSError:
print(
f"Не удалось запустить на порту {port}, повторяем попытку на порту {port - 1}..."
)
port -= 1
except Exception as error:
print(f"Произошла ошибка при запуске Gradio: {error}")
break

0 comments on commit ae856db

Please sign in to comment.