Spaces:
Running
on
Zero
Running
on
Zero
File size: 4,724 Bytes
374f426 bf13828 374f426 b473486 bf13828 ae79826 da8d589 374f426 ae79826 374f426 bf13828 374f426 0cb7b72 374f426 8c22399 374f426 8c22399 bf13828 374f426 bf13828 374f426 ae79826 374f426 da8d589 374f426 b473486 374f426 bf13828 374f426 |
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 |
import logging
import os
import torch
import gradio as gr
from modules import config
from modules.webui import gradio_extensions, localization, webui_config, gradio_hijack
from modules.webui.changelog_tab import create_changelog_tab
from modules.webui.localization_runtime import ENLocalizationVars, ZHLocalizationVars
from modules.webui.ssml.podcast_tab import create_ssml_podcast_tab
from modules.webui.system_tab import create_system_tab
from modules.webui.tts_tab import create_tts_interface
from modules.webui.ssml.ssml_tab import create_ssml_interface
from modules.webui.ssml.spliter_tab import create_spliter_tab
from modules.webui.speaker_tab import create_speaker_panel
from modules.webui.readme_tab import create_readme_tab
logger = logging.getLogger(__name__)
def webui_init():
# fix: If the system proxy is enabled in the Windows system, you need to skip these
os.environ["NO_PROXY"] = "localhost,127.0.0.1,0.0.0.0"
torch._dynamo.config.cache_size_limit = 64
torch._dynamo.config.suppress_errors = True
torch.set_float32_matmul_precision("high")
if config.runtime_env_vars.language == "en":
webui_config.localization = ENLocalizationVars()
else:
webui_config.localization = ZHLocalizationVars()
logger.info("WebUI module initialized")
def create_app_footer():
gradio_version = gr.__version__
git_tag = os.environ.get("V_GIT_TAG") or config.versions.git_tag
git_commit = os.environ.get("V_GIT_COMMIT") or config.versions.git_commit
git_branch = os.environ.get("V_GIT_BRANCH") or config.versions.git_branch
python_version = config.versions.python_version
torch_version = config.versions.torch_version
config.versions.gradio_version = gradio_version
footer_items = ["🍦 [ChatTTS-Forge](https://github.com/lenML/ChatTTS-Forge)"]
footer_items.append(
f"version: [{git_tag}](https://github.com/lenML/ChatTTS-Forge/commit/{git_commit})"
)
footer_items.append(f"branch: `{git_branch}`")
footer_items.append(f"python: `{python_version}`")
footer_items.append(f"torch: `{torch_version}`")
if config.runtime_env_vars.api and not config.runtime_env_vars.no_docs:
footer_items.append(f"[API](/docs)")
gr.Markdown(
" | ".join(footer_items),
elem_classes=["no-translate"],
)
def create_interface():
gradio_extensions.reload_javascript()
js_func = """
function refresh() {
const url = new URL(window.location);
if (url.searchParams.get('__theme') !== 'dark') {
url.searchParams.set('__theme', 'dark');
window.location.href = url.href;
}
}
"""
head_js = """
<script>
</script>
"""
with gr.Blocks(js=js_func, head=head_js, title="ChatTTS Forge WebUI") as demo:
css = """
<style>
.big-button {
height: 80px;
}
#input_title div.eta-bar {
display: none !important; transform: none !important;
}
footer {
display: none !important;
}
</style>
"""
gr.HTML(css)
with gr.Tabs() as tabs:
with gr.TabItem("TTS"):
create_tts_interface()
with gr.TabItem("SSML", id="ssml"):
with gr.Tabs() as ssml_tabs:
with gr.TabItem("Editor", id="ssml.editor"):
ssml_input = create_ssml_interface()
with gr.TabItem("Spilter"):
create_spliter_tab(
ssml_input=ssml_input, tabs1=tabs, tabs2=ssml_tabs
)
with gr.TabItem("Podcast"):
create_ssml_podcast_tab(
ssml_input=ssml_input, tabs1=tabs, tabs2=ssml_tabs
)
with gr.TabItem("Speaker"):
create_speaker_panel()
with gr.TabItem("Inpainting", visible=webui_config.experimental):
gr.Markdown("🚧 Under construction")
with gr.TabItem("ASR", visible=webui_config.experimental):
gr.Markdown("🚧 Under construction")
with gr.TabItem("System"):
create_system_tab()
with gr.TabItem("README"):
with gr.Tabs():
with gr.TabItem("readme"):
create_readme_tab()
with gr.TabItem("changelog"):
create_changelog_tab()
create_app_footer()
# Dump the English config for the localization
# ** JUST for developer
# localization.dump_english_config(gradio_hijack.all_components)
return demo
|