-
-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
This change request proposes a modification to the TTS functionality to automatically save the TTS output as a WAV file that can be automatically downloaded in the web browser.
Proposed Changes:
- Extend the TTS player class (PplxStreamingTtsPlayer in
perplexity/extension/src/plugins/thread-message-tts/utils/pplx-streaming-tts-player.ts
) to maintain a separate, persistent buffer (savedChunks) to collect all audio chunks. - Modify the
startSession()
method to reset both the temporary audio chunks (audioChunks) and the persistent buffer (savedChunks). - In the
addChunk()
method, in addition to pushing the chunk to audioChunks, also push it to savedChunks. - Add a new method
downloadAudio()
to the TTS player class that:- Concatenates all saved chunks into a single Int16Array.
- Creates a WAV blob using the existing
createWavBlob()
method. - Generates an object URL for the blob.
- Creates a temporary anchor element with a download attribute (e.g., filename including a timestamp).
- Programmatically clicks the anchor to trigger the file download in the browser.
- Cleans up by removing the temporary element and revoking the object URL.
- In the
onComplete()
callback (or at an appropriate point when the session is finished), triggerdownloadAudio()
so that the automatic download occurs.
Please review this draft and let me know if any further adjustments are needed.
para-droid-ai and mateus-s-a
Metadata
Metadata
Assignees
Labels
No labels