From 1304f9af021692062fb4a3e6f648aa6dd4cbf55c Mon Sep 17 00:00:00 2001 From: Sangonomiya Kokomi <128172330+go22220203@users.noreply.github.com> Date: Mon, 3 Apr 2023 16:46:38 +0800 Subject: [PATCH] Update webUI.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加在网页端推理完成的音频自动储存到项目目录的raw文件夹内 --- webUI.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/webUI.py b/webUI.py index f396273b..2a199c71 100644 --- a/webUI.py +++ b/webUI.py @@ -16,6 +16,7 @@ from scipy.io import wavfile import librosa import torch +import time logging.getLogger('numba').setLevel(logging.WARNING) logging.getLogger('markdown_it').setLevel(logging.WARNING) @@ -47,6 +48,10 @@ def vc_fn(sid, input_audio, vc_transform, auto_f0,cluster_ratio, slice_db, noise _audio = model.slice_inference(temp_path, sid, vc_transform, slice_db, cluster_ratio, auto_f0, noise_scale,pad_seconds,cl_num,lg_num,lgr_num) model.clear_empty() os.remove(temp_path) + #构建保存文件的路径,并保存到raw文件夹内 + timestamp = str(int(time.time())) + output_file = os.path.join("raw", sid + "_" + timestamp + ".wav") + soundfile.write(output_file, _audio, model.target_sample, format="wav") return "Success", (model.target_sample, _audio) except Exception as e: return "异常信息:"+str(e)+"\n请排障后重试",None @@ -54,6 +59,7 @@ def vc_fn(sid, input_audio, vc_transform, auto_f0,cluster_ratio, slice_db, noise def tts_func(_text,_rate): #使用edge-tts把文字转成音频 # voice = "zh-CN-XiaoyiNeural"#女性,较高音 + # voice = "zh-CN-YunxiNeural"#男性 voice = "zh-CN-YunxiNeural"#男性 output_file = _text[0:10]+".wav" # communicate = edge_tts.Communicate(_text, voice) @@ -163,4 +169,3 @@ def modelAnalysis(model_path,config_path,cluster_model_path,device): app.launch() -