#hi
1 messages · Page 1 of 1 (latest)
how do I pass the voice models to the voice/add url in nodejs
To add a new voice using the ElevenLabs API in Node.js, you would make a POST request to the /v1/voices/add endpoint. The request should include your API key in the headers and the necessary data in the body.
Here's an example using the request library:
const request = require('request');
const options = {
url: 'https://api.elevenlabs.io/v1/voices/add',
headers: {
'xi-api-key': 'your-api-key'
},
formData: {
name: 'voice-name',
files: ['file-path-1', 'file-path-2'], // paths to audio files
description: 'voice-description',
labels: 'serialized-labels-dictionary' // serialized labels dictionary for the voice
}
};
request.post(options, function(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log('Upload successful! Server responded with:', body);
});
Replace 'your-api-key' with your actual API key, 'voice-name' with the name of the voice, ['file-path-1', 'file-path-2'] with the paths to the audio files you want to use for voice cloning, 'voice-description' with a description of the voice, and 'serialized-labels-dictionary' with a serialized labels dictionary for the voice.
Please note that the request library has been deprecated, and it's recommended to use other libraries like axios or node-fetch for making HTTP requests. The example above is for illustrative purposes.
Can I pass the files in base64?