Skip to content

Instantly share code, notes, and snippets.

@TrejGun
Last active October 30, 2024 08:50
Show Gist options
  • Save TrejGun/de47f261a935c21d7aa313551df84070 to your computer and use it in GitHub Desktop.
Save TrejGun/de47f261a935c21d7aa313551df84070 to your computer and use it in GitHub Desktop.
ElevenLabs - get voices
;(async () => {
const XI_API_KEY = 'sk_...'
const url = 'https://api.elevenlabs.io/v1/voices'
const headers = {
Accept: 'application/json',
'xi-api-key': XI_API_KEY,
'Content-Type': 'application/json',
}
const response = await fetch(url, { headers })
if (!response.ok) {
throw new Error('Something went wrong')
}
const data = await response.json()
console.log('export enum ElevenLabsVoiceId {')
for (const voice of data.voices) {
console.log(` ${voice.name} = "${voice.voice_id}"`)
}
console.log('};')
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment