diff --git a/tools/my_utils.py b/tools/my_utils.py index a7755d6d..6d6daa73 100644 --- a/tools/my_utils.py +++ b/tools/my_utils.py @@ -26,6 +26,8 @@ def load_audio(file, sr): def clean_path(path_str): - if platform.system() == 'Windows': - path_str = path_str.replace('/', '\\') - return path_str.strip(" ").strip('"').strip("\n").strip('"').strip(" ") + # 获取当前工作目录 + current_dir = os.getcwd() + # 将相对路径转换为绝对路径 + absolute_path = os.path.join(current_dir, os.path.normpath(path_str)) + return absolute_path diff --git a/webui.py b/webui.py index e1c36e1e..c88bcba2 100644 --- a/webui.py +++ b/webui.py @@ -670,6 +670,12 @@ def close1abc(): ps1abc=[] return "已终止所有一键三连进程", {"__type__": "update", "visible": True}, {"__type__": "update", "visible": False} +def select_list(): + list_files = [f for f in os.listdir("output/asr_opt/") if f.endswith('.list')] + if len(list_files) == 0: + return ["无可用列表文件,请先生成列表文件"] + return list_files + with gr.Blocks(title="GPT-SoVITS WebUI") as app: gr.Markdown( value= @@ -707,7 +713,7 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app: with gr.Row(): open_denoise_button = gr.Button(i18n("开启语音降噪"), variant="primary",visible=True) close_denoise_button = gr.Button(i18n("终止语音降噪进程"), variant="primary",visible=False) - denoise_input_dir=gr.Textbox(label=i18n("降噪音频文件输入文件夹"),value="") + denoise_input_dir=gr.Textbox(label=i18n("降噪音频文件输入文件夹"),value="output/slicer_opt") denoise_output_dir=gr.Textbox(label=i18n("降噪结果输出文件夹"),value="output/denoise_opt") denoise_info = gr.Textbox(label=i18n("语音降噪进程输出信息")) gr.Markdown(value=i18n("0c-中文批量离线ASR工具")) @@ -717,8 +723,8 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app: with gr.Column(): with gr.Row(): asr_inp_dir = gr.Textbox( - label=i18n("输入文件夹路径"), - value="D:\\GPT-SoVITS\\raw\\xxx", + label=i18n("输入文件夹路径(若降噪处理过,选output/denoise_opt)"), + value="output/slicer_opt", interactive=True, ) asr_opt_dir = gr.Textbox( @@ -762,7 +768,7 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app: if_label = gr.Checkbox(label=i18n("是否开启打标WebUI"),show_label=True) path_list = gr.Textbox( label=i18n(".list标注文件的路径"), - value="D:\\RVC1006\\GPT-SoVITS\\raw\\xxx.list", + value=select_list()[0], interactive=True, ) label_info = gr.Textbox(label=i18n("打标工具进程输出信息")) @@ -785,10 +791,14 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app: with gr.TabItem(i18n("1A-训练集格式化工具")): gr.Markdown(value=i18n("输出logs/实验名目录下应有23456开头的文件和文件夹")) with gr.Row(): - inp_text = gr.Textbox(label=i18n("*文本标注文件"),value=r"D:\RVC1006\GPT-SoVITS\raw\xxx.list",interactive=True) + inp_text = gr.Textbox( + label=i18n("*文本标注文件"), + value=select_list()[0], + interactive=True + ) inp_wav_dir = gr.Textbox( - label=i18n("*训练集音频文件目录"), - # value=r"D:\RVC1006\GPT-SoVITS\raw\xxx", + label=i18n("*训练集音频文件目录(若降噪处理过,选output/denoise_opt)"), + value=r"output/slicer_opt", interactive=True, placeholder=i18n("填切割后音频所在目录!读取的音频文件完整路径=该目录-拼接-list文件里波形对应的文件名(不是全路径)。如果留空则使用.list文件里的绝对全路径。") )