complexity
complexity copied to clipboard
[Feature Request]: Enhancement: Automatically Download TTS Output as WAV File
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.
10/10 Feedback post. Well formatted and clear. This has been suggested many times over the last year, but this might be the most direct/detailed feature request for it.