Skip to content

[Feature Request]: Enhancement: Automatically Download TTS Output as WAV File #110

@easyrider

Description

@easyrider

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:

  1. 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.
  2. Modify the startSession() method to reset both the temporary audio chunks (audioChunks) and the persistent buffer (savedChunks).
  3. In the addChunk() method, in addition to pushing the chunk to audioChunks, also push it to savedChunks.
  4. 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.
  5. In the onComplete() callback (or at an appropriate point when the session is finished), trigger downloadAudio() so that the automatic download occurs.

Please review this draft and let me know if any further adjustments are needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions