-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix for long text inputs, send text as payload, not url parameter. #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -918,22 +918,30 @@ <h1>VibeVoice-Realtime TTS Demo</h1> | |||||||||||||||
| 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)); | ||||||||||||||||
|
Comment on lines
+940
to
+942
|
||||||||||||||||
| socket.onopen = () => { | |
| // Send configuration as first message after connection opens | |
| socket.send(JSON.stringify(config)); | |
| socket.onopen = event => { | |
| // Send configuration as first message after connection opens | |
| const ws = event.target; | |
| ws.send(JSON.stringify(config)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After
json.loads,configcan be any JSON type (string/list/null/etc). The subsequentconfig.get(...)calls andlen(text)will raise (AttributeError/TypeError) for valid-but-unexpected payloads like"foo"or{ "text": null }, resulting in a 500 and leaving the socket in a bad state. Validateconfigis a dict and thattextis a string (or coerce/reject) before accessing.get/len, and close the websocket with an appropriate code/reason on invalid types.