From cb2b844f45e9186734a5ae50d856dd81e367c1ed Mon Sep 17 00:00:00 2001 From: Kaning123 Date: Sat, 4 Apr 2026 14:17:07 +0800 Subject: [PATCH] feat: Added ReturnWay option to get_tts_wav --- GPT_SoVITS/inference_webui.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/GPT_SoVITS/inference_webui.py b/GPT_SoVITS/inference_webui.py index 3eed1b35..709b5d56 100644 --- a/GPT_SoVITS/inference_webui.py +++ b/GPT_SoVITS/inference_webui.py @@ -838,6 +838,8 @@ def get_tts_wav( SaveOutputAsUndecoded=False, SaveOutputAsUndecodedName="output.voice", AddRandomSaltToSaveOutputAsUndecodedName=False, + + ReturnWay = "yield", # "yield" or "return" ): global cache if ref_wav_path: @@ -1197,10 +1199,15 @@ def get_tts_wav( audio_opt /= max_audio else: audio_opt = audio_opt.cpu().detach().numpy() - yield opt_sr, (audio_opt * 32767).astype(np.int16) + + if ReturnWay == "yield": + yield opt_sr, (audio_opt * 32767).astype(np.int16) + else: + return opt_sr, (audio_opt * 32767).astype(np.int16) + def close_serv(): - if running_on == "local" + if running_on == "local": sys.exit(0) else: gr.Warning(i18n("服务器环境下该功能不可用"))