Fix Qwen3-TTS gradio demo (#2372)

Signed-off-by: noobhappylife <aratar1991@hotmail.com>
This commit is contained in:
noobHappylife authored and GitHub committed 2026-03-31 11:42:09 +00:00
1 parent de1ac5ee88
commit 7cb7b3e8ad
2 files changed
+11 -7

No files matched your search

@@ -125,7 +125,7 @@ PLAYER_HTML = """
def _build_player_js(sample_rate: int) -> str:
"""Build the JavaScript that powers the AudioWorklet player."""
return f"""
() => {{
<script>
const SR = {sample_rate};
const WC = {json.dumps(WORKLET_JS)};
let ctx = null, node = null, abort = null, gen = false, st = {{}};
@@ -284,7 +284,7 @@ def _build_player_js(sample_rate: int) -> str:
}}
}}
}};
}}
</script>
"""
@@ -435,10 +435,7 @@ def create_app(api_base: str):
)
with gr.Blocks(
css=css,
title="Qwen3-TTS Demo",
js=_build_player_js(PCM_SAMPLE_RATE),
theme=theme,
) as demo:
gr.HTML(f"""
<div style="display:flex; align-items:center; gap:16px; margin-bottom:8px;">
@@ -773,7 +770,14 @@ def create_app(api_base: str):
demo.queue()
return gr.mount_gradio_app(fastapi_app, demo, path="/")
return gr.mount_gradio_app(
fastapi_app,
demo,
path="/",
css=css,
theme=theme,
head=_build_player_js(PCM_SAMPLE_RATE),
)
def parse_args():
@@ -103,7 +103,7 @@ def build_payload(
if task_type == "CustomVoice":
if voice:
payload["speaker"] = voice
payload["voice"] = voice
if instructions and instructions.strip():
payload["instructions"] = instructions.strip()