From bc9cb993231c6d158181fa3e43a35019e312d816 Mon Sep 17 00:00:00 2001 From: Kevin-lou Date: Sun, 17 Mar 2024 13:48:20 +0800 Subject: [PATCH] =?UTF-8?q?Modify=20the=20my=5Futils.clean=5Fpath()=20func?= =?UTF-8?q?tion=20to=20correctly=20handle=20paths=20from=20different=20ope?= =?UTF-8?q?rating=20systems;=20supplement=20the=20input=20directories=20fo?= =?UTF-8?q?r=20each=20project=20to=20make=20the=20operation=20process=20sm?= =?UTF-8?q?oother.=E4=BF=AE=E6=94=B9my=5Futils.clean=5Fpath()=E5=87=BD?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E4=BD=BF=E5=85=B6=E8=83=BD=E5=A4=9F=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E5=A4=84=E7=90=86=E4=B8=8D=E5=90=8C=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=B7=AF=E5=BE=84=EF=BC=9B=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E5=90=84=E9=A1=B9=E7=9B=AE=E7=9A=84=E8=BE=93=E5=85=A5=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=EF=BC=8C=E8=AE=A9=E6=93=8D=E4=BD=9C=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=9B=B4=E9=A1=BA=E7=95=85=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/my_utils.py | 8 +++++--- webui.py | 24 +++++++++++++++++------- 2 files changed, 22 insertions(+), 10 deletions(-) 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文件里的绝对全路径。") )