Skip to content

Commit

Permalink
fix(webui): audio not the same at each generation
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Jul 5, 2024
1 parent 72b2719 commit 3edd47c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
31 changes: 16 additions & 15 deletions examples/web/funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("蘁淰"):
Expand All @@ -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():
Expand Down
1 change: 1 addition & 0 deletions examples/web/webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def make_audio(autoplay, stream):
top_k_slider,
spk_emb_text,
stream_mode_checkbox,
audio_seed_input,
],
outputs=audio_output,
).then(
Expand Down

0 comments on commit 3edd47c

Please sign in to comment.