mirror of
https://github.com/2noise/ChatTTS.git
synced 2026-08-29 02:10:59 +08:00
fix(webui): audio not the same at each generation
This commit is contained in:
+16
-15
@@ -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():
|
||||
|
||||
@@ -177,6 +177,7 @@ def main():
|
||||
top_k_slider,
|
||||
spk_emb_text,
|
||||
stream_mode_checkbox,
|
||||
audio_seed_input,
|
||||
],
|
||||
outputs=audio_output,
|
||||
).then(
|
||||
|
||||
Reference in New Issue
Block a user