-
Notifications
You must be signed in to change notification settings - Fork 241
Open
Description
<title>Streaming Audio Playback</title>
<textarea id="promptInput" rows="4" cols="50" placeholder="Type your prompt here" required></textarea>
Play Audio <script> const base_url = `https://`;
</script>
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));
});
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels