[Enhancement]: TTS Streaming: Audio should play progressively while chunks are being received #12566
jxdabc
started this conversation in
Feature Requests & Suggestions
Replies: 1 comment
|
Feel free to open a PR if you get something working but this is not a priority item to implement |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
What features would you like to see added?
Audio should play progressively while chunks are being received
More details
Problem
When using TTS (text-to-speech) with streaming-enabled backends (like edge-tts), audio data is transferred in chunks (chunked transfer encoding), but LibreChat waits for the entire transfer to complete before starting playback.
Expected Behavior
Audio should start playing as soon as the first chunk is received, not after all chunks are transferred. This is especially important for longer texts where the delay is noticeable.
Current Implementation
In
client/src/hooks/Input/useTextToSpeechExternal.ts:103-106:The ArrayBuffer received is the complete audio even if the backend streams it. The Blob is only created after the entire response is received.
Suggested Solution
Replace the useTextToSpeechMutation approach with a streaming-capable fetch that feeds audio chunks to HTMLAudioElement as they arrive. For example:
Environment
Which components are impacted by your request?
No response
Pictures
No response
Code of Conduct
All reactions