Skip to content

decoding selection 2 #158

@chathun96

Description

@chathun96
<title>Streaming Audio Playback</title>

Streaming Audio Playback

Enter Prompt:
<textarea id="promptInput" rows="4" cols="50" placeholder="Type your prompt here" required></textarea>
Play Audio <script> const base_url = `https://`;
document.getElementById("promptForm").addEventListener("submit", function(event) {
  event.preventDefault();
  const prompt = document.getElementById("promptInput").value;
  const encodedPrompt = encodeURIComponent(prompt);
  const audioUrl = `${base_url}/tts?prompt=` + encodedPrompt;
  
  // Set the audio element's src to your endpoint to stream and play the audio data
  const audioPlayer = document.getElementById("audioPlayer");
  audioPlayer.src = audioUrl;
  audioPlayer.load();
  audioPlayer.play().catch(err => console.error("Playback error:", err));
});
</script>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions