|
1 | | -import os,shutil,sys,pdb |
| 1 | +import os,shutil,sys,pdb,re |
2 | 2 | now_dir = os.getcwd() |
3 | 3 | sys.path.append(now_dir) |
4 | 4 | import json,yaml,warnings,torch |
@@ -85,9 +85,16 @@ def get_weights_names(): |
85 | 85 | os.makedirs(GPT_weight_root,exist_ok=True) |
86 | 86 | SoVITS_names,GPT_names = get_weights_names() |
87 | 87 |
|
| 88 | +def custom_sort_key(s): |
| 89 | + # 使用正则表达式提取字符串中的数字部分和非数字部分 |
| 90 | + parts = re.split('(\d+)', s) |
| 91 | + # 将数字部分转换为整数,非数字部分保持不变 |
| 92 | + parts = [int(part) if part.isdigit() else part for part in parts] |
| 93 | + return parts |
| 94 | + |
88 | 95 | def change_choices(): |
89 | 96 | SoVITS_names, GPT_names = get_weights_names() |
90 | | - return {"choices": sorted(SoVITS_names), "__type__": "update"}, {"choices": sorted(GPT_names), "__type__": "update"} |
| 97 | + return {"choices": sorted(SoVITS_names,key=custom_sort_key), "__type__": "update"}, {"choices": sorted(GPT_names,key=custom_sort_key), "__type__": "update"} |
91 | 98 |
|
92 | 99 | p_label=None |
93 | 100 | p_uvr5=None |
@@ -733,8 +740,8 @@ def close1abc(): |
733 | 740 | with gr.TabItem(i18n("1C-推理")): |
734 | 741 | gr.Markdown(value=i18n("选择训练完存放在SoVITS_weights和GPT_weights下的模型。默认的一个是底模,体验5秒Zero Shot TTS用。")) |
735 | 742 | with gr.Row(): |
736 | | - GPT_dropdown = gr.Dropdown(label=i18n("*GPT模型列表"), choices=sorted(GPT_names),value=pretrained_gpt_name) |
737 | | - SoVITS_dropdown = gr.Dropdown(label=i18n("*SoVITS模型列表"), choices=sorted(SoVITS_names),value=pretrained_sovits_name) |
| 743 | + GPT_dropdown = gr.Dropdown(label=i18n("*GPT模型列表"), choices=sorted(GPT_names,key=custom_sort_key),value=pretrained_gpt_name,interactive=True) |
| 744 | + SoVITS_dropdown = gr.Dropdown(label=i18n("*SoVITS模型列表"), choices=sorted(SoVITS_names,key=custom_sort_key),value=pretrained_sovits_name,interactive=True) |
738 | 745 | gpu_number_1C=gr.Textbox(label=i18n("GPU卡号,只能填1个整数"), value=gpus, interactive=True) |
739 | 746 | refresh_button = gr.Button(i18n("刷新模型路径"), variant="primary") |
740 | 747 | refresh_button.click(fn=change_choices,inputs=[],outputs=[SoVITS_dropdown,GPT_dropdown]) |
|
0 commit comments