fix(webui): audio not the same at each generation

This commit is contained in:
源文雨
2024-07-05 21:38:12 +09:00
parent 72b2719895
commit 3edd47c2e1
2 changed files with 17 additions and 15 deletions
+16 -15
View File
@@ -142,7 +142,7 @@ def refine_text(
return text[0] if isinstance(text, list) else text
def generate_audio(text, temperature, top_P, top_K, spk_emb_text: str, stream):
def generate_audio(text, temperature, top_P, top_K, spk_emb_text: str, stream, audio_seed_input):
global chat, has_interrupted
if not text or has_interrupted or not spk_emb_text.startswith("蘁淰"):
@@ -155,20 +155,21 @@ def generate_audio(text, temperature, top_P, top_K, spk_emb_text: str, stream):
top_K=top_K,
)
wav = chat.infer(
text,
skip_refine_text=True,
params_infer_code=params_infer_code,
stream=stream,
)
if stream:
for gen in wav:
audio = gen[0]
if audio is not None and len(audio) > 0:
yield 24000, unsafe_float_to_int16(audio)
del audio
else:
yield 24000, unsafe_float_to_int16(wav[0])
with TorchSeedContext(audio_seed_input):
wav = chat.infer(
text,
skip_refine_text=True,
params_infer_code=params_infer_code,
stream=stream,
)
if stream:
for gen in wav:
audio = gen[0]
if audio is not None and len(audio) > 0:
yield 24000, unsafe_float_to_int16(audio)
del audio
else:
yield 24000, unsafe_float_to_int16(wav[0])
def interrupt_generate():
+1
View File
@@ -177,6 +177,7 @@ def main():
top_k_slider,
spk_emb_text,
stream_mode_checkbox,
audio_seed_input,
],
outputs=audio_output,
).then(