Last active
October 30, 2024 08:50
-
-
Save TrejGun/de47f261a935c21d7aa313551df84070 to your computer and use it in GitHub Desktop.
ElevenLabs - get voices
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
;(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