diff --git a/demo/web/app.py b/demo/web/app.py index 887d62b..e0af798 100644 --- a/demo/web/app.py +++ b/demo/web/app.py @@ -363,11 +363,22 @@ def streaming_tts(text: str, **kwargs) -> Iterator[np.ndarray]: @app.websocket("/stream") async def websocket_stream(ws: WebSocket) -> None: await ws.accept() - text = ws.query_params.get("text", "") - print(f"Client connected, text={text!r}") - cfg_param = ws.query_params.get("cfg") - steps_param = ws.query_params.get("steps") - voice_param = ws.query_params.get("voice") + + # Receive initial configuration message from client + try: + config_message = await ws.receive_text() + config = json.loads(config_message) + except Exception as e: + print(f"Error receiving config: {e}") + await ws.close(code=1003, reason="Invalid configuration") + return + + text = config.get("text", "") + cfg_param = config.get("cfg") + steps_param = config.get("steps") + voice_param = config.get("voice") + + print(f"Client connected, text length={len(text)}, cfg={cfg_param}, steps={steps_param}, voice={voice_param}") try: cfg_scale = float(cfg_param) if cfg_param is not None else 1.5 diff --git a/demo/web/index.html b/demo/web/index.html index daf9df8..5adc0f9 100644 --- a/demo/web/index.html +++ b/demo/web/index.html @@ -918,22 +918,30 @@

VibeVoice-Realtime TTS Demo

updateButtonLabel(); createAudioChain(); - const params = new URLSearchParams(); - params.set('text', textValue); + // Prepare configuration object to send via WebSocket message instead of URL + const config = { + text: textValue, + }; if (!Number.isNaN(cfgValue)) { - params.set('cfg', cfgValue.toFixed(3)); + config.cfg = cfgValue.toFixed(3); } if (!Number.isNaN(stepsValue)) { - params.set('steps', stepsValue.toString()); + config.steps = stepsValue.toString(); } if (voiceValue) { - params.set('voice', voiceValue); + config.voice = voiceValue; } - const wsUrl = `${location.origin.replace(/^http/, 'ws')}/stream?${params.toString()}`; + + const wsUrl = `${location.origin.replace(/^http/, 'ws')}/stream`; socket = new WebSocket(wsUrl); socket.binaryType = 'arraybuffer'; + socket.onopen = () => { + // Send configuration as first message after connection opens + socket.send(JSON.stringify(config)); + }; + socket.onmessage = event => { if (typeof event.data === 'string') { handleLogMessage(event.data);