mirror of
https://github.com/RVC-Boss/GPT-SoVITS.git
synced 2025-04-05 19:41:56 +08:00
Merge 0c8516422a01fb66780d71f73745026f6c382602 into 11a0d9a265004a25281ae1370b63f8b4077b6def
This commit is contained in:
commit
06f627b5a5
@ -895,6 +895,7 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app:
|
||||
# button4.click(cut4, [text_inp], [text_opt])
|
||||
# button5.click(cut5, [text_inp], [text_opt])
|
||||
# gr.Markdown(html_center(i18n("后续将支持转音素、手工修改音素、语音合成分步执行。")))
|
||||
i18n.translate_blocks(app)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.queue().launch(#concurrency_count=511, max_size=1022
|
||||
|
@ -326,6 +326,8 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app:
|
||||
cut_text.click(to_cut, [text_inp, _how_to_cut], [text_opt])
|
||||
gr.Markdown(value=i18n("后续将支持转音素、手工修改音素、语音合成分步执行。"))
|
||||
|
||||
i18n.translate_blocks(app)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.queue().launch(#concurrency_count=511, max_size=1022
|
||||
server_name="0.0.0.0",
|
||||
|
@ -35,6 +35,7 @@ ko_pron
|
||||
opencc; sys_platform != 'linux'
|
||||
opencc==1.1.1; sys_platform == 'linux'
|
||||
python_mecab_ko; sys_platform != 'win32'
|
||||
gradio-i18n
|
||||
fastapi<0.112.2
|
||||
x_transformers
|
||||
torchmetrics<=1.5
|
||||
|
@ -2,35 +2,60 @@ import json
|
||||
import locale
|
||||
import os
|
||||
|
||||
I18N_JSON_DIR : os.PathLike = os.path.join(os.path.dirname(os.path.relpath(__file__)), 'locale')
|
||||
import gradio_i18n
|
||||
|
||||
I18N_JSON_DIR: os.PathLike = os.path.join(
|
||||
os.path.dirname(os.path.relpath(__file__)), "locale"
|
||||
)
|
||||
|
||||
|
||||
def load_language_list(language):
|
||||
with open(os.path.join(I18N_JSON_DIR, f"{language}.json"), "r", encoding="utf-8") as f:
|
||||
with open(
|
||||
os.path.join(I18N_JSON_DIR, f"{language}.json"), "r", encoding="utf-8"
|
||||
) as f:
|
||||
language_list = json.load(f)
|
||||
return language_list
|
||||
|
||||
|
||||
def scan_language_list():
|
||||
language_list = []
|
||||
for name in os.listdir(I18N_JSON_DIR):
|
||||
if name.endswith(".json"):language_list.append(name.split('.')[0])
|
||||
if name.endswith(".json"):
|
||||
language_list.append(name.split(".")[0])
|
||||
return language_list
|
||||
|
||||
|
||||
class I18nAuto:
|
||||
def __init__(self, language=None):
|
||||
if language in ["Auto", None]:
|
||||
language = locale.getdefaultlocale()[0]
|
||||
# getlocale can't identify the system's language ((None, None))
|
||||
if not os.path.exists(os.path.join(I18N_JSON_DIR, f"{language}.json")):
|
||||
language = "en_US"
|
||||
self.language = language
|
||||
self.language_map = load_language_list(language)
|
||||
if language in ["Auto", None] or not os.path.exists(
|
||||
os.path.join(I18N_JSON_DIR, f"{language}.json")
|
||||
):
|
||||
self.language = "Auto"
|
||||
else:
|
||||
self.language = language
|
||||
self.language_map = load_language_list(language)
|
||||
|
||||
def __call__(self, key):
|
||||
return self.language_map.get(key, key)
|
||||
if self.language == "Auto":
|
||||
return gradio_i18n.gettext(key)
|
||||
else:
|
||||
return self.language_map.get(key, key)
|
||||
|
||||
def __repr__(self):
|
||||
return "Use Language: " + self.language
|
||||
|
||||
def translate_blocks(self, block):
|
||||
translation = {}
|
||||
for lang in scan_language_list():
|
||||
short_lang = lang.partition("_")[0]
|
||||
if short_lang == "zh" and "CN" not in lang:
|
||||
continue
|
||||
|
||||
translation[short_lang] = load_language_list(lang)
|
||||
|
||||
gradio_i18n.translate_blocks(block, translation)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
i18n = I18nAuto(language='en_US')
|
||||
print(i18n)
|
||||
i18n = I18nAuto(language="en_US")
|
||||
print(i18n)
|
||||
|
@ -32,12 +32,12 @@ is_share=eval(sys.argv[4])
|
||||
|
||||
def html_left(text, label='p'):
|
||||
return f"""<div style="text-align: left; margin: 0; padding: 0;">
|
||||
<{label} style="margin: 0; padding: 0;">{text}</{label}>
|
||||
<{label} style="margin: 0; padding: 0;">""" + text + f"""</{label}>
|
||||
</div>"""
|
||||
|
||||
def html_center(text, label='p'):
|
||||
return f"""<div style="text-align: center; margin: 100; padding: 50;">
|
||||
<{label} style="margin: 0; padding: 0;">{text}</{label}>
|
||||
<{label} style="margin: 0; padding: 0;">""" + text + f"""</{label}>
|
||||
</div>"""
|
||||
|
||||
def uvr(model_name, inp_root, save_root_vocal, paths, save_root_ins, agg, format0):
|
||||
@ -199,6 +199,8 @@ with gr.Blocks(title="UVR5 WebUI") as app:
|
||||
[vc_output4],
|
||||
api_name="uvr_convert",
|
||||
)
|
||||
|
||||
i18n.translate_blocks(app)
|
||||
app.queue().launch(#concurrency_count=511, max_size=1022
|
||||
server_name="0.0.0.0",
|
||||
inbrowser=True,
|
||||
|
1
webui.py
1
webui.py
@ -1096,6 +1096,7 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app:
|
||||
close_tts.click(change_tts_inference, [bert_pretrained_dir,cnhubert_base_dir,gpu_number_1C,GPT_dropdown,SoVITS_dropdown, batched_infer_enabled], [tts_info,open_tts,close_tts])
|
||||
version_checkbox.change(switch_version,[version_checkbox],[pretrained_s2G,pretrained_s2D,pretrained_s1,GPT_dropdown,SoVITS_dropdown,batch_size,total_epoch,save_every_epoch,text_low_lr_rate, if_grad_ckpt, batched_infer_enabled])
|
||||
with gr.TabItem(i18n("2-GPT-SoVITS-变声")):gr.Markdown(value=i18n("施工中,请静候佳音"))
|
||||
i18n.translate_blocks(app)
|
||||
app.queue().launch(#concurrency_count=511, max_size=1022
|
||||
server_name="0.0.0.0",
|
||||
inbrowser=True,
|
||||
|
Loading…
x
Reference in New Issue
Block a user