This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const voiceId = '' // Pick any voice ID from https://docs.elevenlabs.io/api-reference/voices | |
const model = 'eleven_monolingual_v1' | |
const elUrl = `https://api.elevenlabs.io/v1/text-to-speech/${voiceId}/stream?optimize_streaming_latency=3` // Optimize for latency | |
const codec = 'audio/mpeg' | |
const maxBufferDuration = 60 // Maximum buffer duration in seconds | |
const maxConcurrentRequests = 3 // Maximum concurrent requests allowed | |
// Create a new MediaSource and Audio element | |
const mediaSource = new MediaSource() | |
const audioElement = new Audio() |