Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions examples/online_serving/qwen3_tts/gradio_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def _build_player_js(sample_rate: int) -> str:
node.port.postMessage({{ type: 'clear' }});

gen = true;
st = {{ t0: performance.now(), chunks: 0, samples: 0, ttfp: null }};
st = {{ t0: null, chunks: 0, samples: 0, ttfp: null }};
setStatus('Connecting...', '#4A90D9');
const bEl = document.getElementById('tts-stop-btn');
if (bEl) bEl.style.display = 'inline-block';
Expand All @@ -231,6 +231,7 @@ def _build_player_js(sample_rate: int) -> str:

try {{
console.log('fetch payload:', JSON.stringify({{input: payload.input?.slice(0,30), task: payload.task_type, has_ref: !!payload.ref_audio, stream: payload.stream}}));
st.t0 = performance.now();
const r = await fetch('/proxy/v1/audio/speech', {{
method: 'POST',
headers: {{ 'Content-Type': 'application/json' }},
Expand Down Expand Up @@ -362,21 +363,8 @@ async def proxy_speech(request: Request):
req_id = body.get("_req_id")
if req_id and req_id in _pending_payloads:
body = _pending_payloads.pop(req_id)
# Pre-download ref_audio URL so TTFP only measures synthesis time
ref = body.get("ref_audio", "")
if isinstance(ref, str) and ref.startswith("http"):
try:
async with httpx.AsyncClient(timeout=30) as dl:
r = await dl.get(ref)
r.raise_for_status()
import base64

b64 = base64.b64encode(r.content).decode()
ct = r.headers.get("content-type", "audio/wav")
body["ref_audio"] = f"data:{ct};base64,{b64}"
logger.info("Pre-downloaded ref_audio: %d bytes", len(r.content))
except Exception:
logger.exception("Failed to pre-download ref_audio, passing URL as-is")
# Pass ref_audio URL directly to vLLM server (it handles URL resolution).
# Pre-downloading and re-encoding adds ~2-3s to TTFP for large files.
Comment on lines +366 to +367
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep proxy-side fallback for unreachable reference URLs

Passing ref_audio URLs straight through in proxy_speech removes the previous behavior where the proxy could fetch and inline audio as a data URI, which means Base cloning now fails whenever the Gradio host can access the URL but the upstream --api-base server cannot (e.g., restricted egress or different network zone). This is a functional regression from the prior implementation for split-network deployments, so the proxy should retain a fallback path instead of always delegating URL fetches upstream.

Useful? React with 👍 / 👎.

logger.info(
"Proxy request: %s",
{k: (f"<{len(str(v))} chars>" if k == "ref_audio" else v) for k, v in body.items()},
Expand Down
Loading