From f2b4515d72a00c9f89a52e58ead1e6f798351020 Mon Sep 17 00:00:00 2001 From: ylzz1997 Date: Wed, 12 Apr 2023 00:05:24 +0800 Subject: [PATCH] Debug --- inference/infer_tool.py | 2 +- webUI.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/inference/infer_tool.py b/inference/infer_tool.py index 10c481df..6a2f4dfa 100644 --- a/inference/infer_tool.py +++ b/inference/infer_tool.py @@ -224,7 +224,7 @@ def clear_empty(self): def unload_model(self): # 卸载模型 del self.net_g_ms - if self.enhancer!=None: del self.enhancer + if hasattr(self,"enhancer"): del self.enhancer def slice_inference(self, raw_audio_path, diff --git a/webUI.py b/webUI.py index 7d5054d2..ad9042f9 100644 --- a/webUI.py +++ b/webUI.py @@ -17,6 +17,7 @@ import librosa import torch import time +import traceback logging.getLogger('numba').setLevel(logging.WARNING) logging.getLogger('markdown_it').setLevel(logging.WARNING) @@ -51,6 +52,7 @@ def modelAnalysis(model_path,config_path,cluster_model_path,device,enhance): msg += i + " " return sid.update(choices = spks,value=spks[0]), msg except Exception as e: + if debug: traceback.print_exc() raise gr.Error(e) @@ -90,8 +92,10 @@ def vc_fn(sid, input_audio, vc_transform, auto_f0,cluster_ratio, slice_db, noise soundfile.write(output_file, _audio, model.target_sample, format="wav") return f"推理成功,音频文件保存为results/{filename}", (model.target_sample, _audio) except Exception as e: + if debug: traceback.print_exc() raise gr.Error(e) except Exception as e: + if debug: traceback.print_exc() raise gr.Error(e) @@ -142,6 +146,8 @@ def vc_fn2(sid, input_audio, vc_transform, auto_f0,cluster_ratio, slice_db, nois os.remove(save_path2) return a,b +def debug_change(): + debug = debug_button.value with gr.Blocks( theme=gr.themes.Base( @@ -205,9 +211,15 @@ def vc_fn2(sid, input_audio, vc_transform, auto_f0,cluster_ratio, slice_db, nois vc_output1 = gr.Textbox(label="Output Message") with gr.Column(): vc_output2 = gr.Audio(label="Output Audio", interactive=False) - + with gr.Row(variant="panel"): + with gr.Column(): + gr.Markdown(value=""" + WebUI设置 + """) + debug_button = gr.Checkbox(label="Debug模式,如果向社区反馈BUG需要打开,打开后控制台可以显示具体错误提示", value=debug) vc_submit.click(vc_fn, [sid, vc_input3, vc_transform,auto_f0,cluster_ratio, slice_db, noise_scale,pad_seconds,cl_num,lg_num,lgr_num,F0_mean_pooling,enhancer_adaptive_key], [vc_output1, vc_output2]) vc_submit2.click(vc_fn2, [sid, vc_input3, vc_transform,auto_f0,cluster_ratio, slice_db, noise_scale,pad_seconds,cl_num,lg_num,lgr_num,text2tts,tts_rate,F0_mean_pooling,enhancer_adaptive_key], [vc_output1, vc_output2]) + debug_button.change(debug_change,[],[]) model_load_button.click(modelAnalysis,[model_path,config_path,cluster_model_path,device,enhance],[sid,sid_output]) model_unload_button.click(modelUnload,[],[sid,sid_output]) app.launch()