feat: Added ReturnWay option to get_tts_wav

This commit is contained in:
Kaning123 2026-04-04 14:17:07 +08:00
parent 5c03499fcf
commit cb2b844f45

View File

@ -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()
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("服务器环境下该功能不可用"))