Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

New features #51

Open
wants to merge 2 commits into
base: test
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,51 @@ ElevenLabs.prototype.getVoice = async function({voiceId}) {

/**

Function that adds a voice on ElevenLabs.

@param {string} description - The description of the voice to create.

@param {array} files - One or more audio files to clone the voice from.

@param {number} labels - The serialized labels dictionary for the voice.

@param {string} name - The name that identifies this voice. This will be displayed in the dropdown of the website.

@returns {Object} - An object containing the status of the add operation.
*/
ElevenLabs.prototype.addVoice = async function({
description,
files,
labels,
name
}){
try {
if (!files) {
console.log("ERR: Missing parameter {files}");
return;
} else if (!name) {
console.log("ERR: Missing parameter {name}");
return;
}

const voiceURL = `${elevenLabsAPIV1}/voices/add`;

const response = await axios({
method: "POST",
url: voiceURL,
headers: {
"xi-api-key": this.apiKey,
},
});

return response.data;
} catch (error) {
console.log(error);
}
};

/**

Function that returns an object containing the status of the delete operation.

@param {string} voiceId - The ID of the voice to use for the text-to-speech conversion.
Expand Down Expand Up @@ -433,4 +478,4 @@ ElevenLabs.prototype.getUserSubscription = async function() {
}
};

module.exports = ElevenLabs;
module.exports = ElevenLabs;