#which endpoint can generate my own cloned voice ?
1 messages · Page 1 of 1 (latest)
To generate your own cloned voice, you can use the "Add Voice" API endpoint. This API supports Instant Voice Clones, allowing you to create a voice clone using short audio samples. For more detailed information, you can refer to the API documentation.
great, create an example in js for this endpoint with the payload json neeeded
To generate speech using your own cloned voice with the ElevenLabs API in JavaScript, you can use the following example. This example uses the axios library to make a POST request to the text-to-speech endpoint with the necessary payload:
const axios = require('axios');
const apiKey = 'YOUR_API_KEY';
const voiceId = 'YOUR_CLONED_VOICE_ID';
const text = 'This is a test of my cloned voice.';
axios.post(`https://api.elevenlabs.io/v1/text-to-speech/${voiceId}`,
{ text: text },
{
headers: {
'xi-api-key': apiKey,
'Content-Type': 'application/json'
},
responseType: 'arraybuffer'
})
.then(response => {
// Handle audio data
console.log('Audio data received:', response.data);
})
.catch(error => {
console.error('Error:', error);
});
Make sure to replace 'YOUR_API_KEY' and 'YOUR_CLONED_VOICE_ID' with your actual API key and cloned voice ID. This code will send a request to generate speech from the provided text using your cloned voice.
i don't have a voice id, i need to create a new voice id by uploading my own voice , and getting a new voice id.....that will be generated, this is not clear, please explain again and modify the code if needed.
To create a new voice ID by uploading your own voice, you need use the "Add Voice" endpoint. After successfully uploading your voice, you can generate a preview using the text-to-speech tool on the Eleven Labs website. Here's an example of how you might set up a request in JavaScript to add a voice:
const axios = require('axios');
const apiKey = 'YOUR_API_KEY';
const voiceName = 'Your Voice Name';
const voiceFile = 'path/to/your/voice/file.wav'; // Path to your voice file
const formData = new FormData();
formData.append('name', voiceName);
formData.append('file', fs.createReadStream(voiceFile));
axios.post('https://api.elevenlabs.io/v1/voices/add', formData, {
headers: {
'xi-api-key': apiKey,
'Content-Type': 'multipart/form-data'
}
})
.then(response => {
console.log('Voice added successfully:', response.data);
})
.catch(error => {
console.error('Error adding voice:', error);
});
Make sure to replace 'YOUR_API_KEY' with your actual API key and 'path/to/your/voice/file.wav' with the path to your voice file. After adding the voice, use the text-to-speech tool to generate a short sentence, which will trigger the preview generation. The preview should be available within about an hour.
how long should of a text should the user read as a sample, write a nice fun and engaging motivational story with a nice moral about business and relationship with people that the user would read and use for the voice sample.