This is an Open Source NodeJS package for ElevenLabs Text to Speech API.
!elevenlabs-js
ElevenLabs.io API for NodeJS
============





This is an Open Source NodeJS package for elevenlabs.io Text to Speech API. You can
find the Official API document here: https://api.elevenlabs.io/docs
⭐⭐\
*If you like this project, please consider starring it. Stars are a way to show appreciation and interest in this
project. And who knows, I may be more inclined to improve it further.*\
⭐⭐
textToSpeech() | voiceId, text, modelId, voiceSettings | /v1/text-to-speech/{voice_id}/stream | POST |
getModels() | N/A | /v1/models | GET |
getVoices() | N/A | /v1/voices | GET |
getDefaultVoiceSettings() | N/A | /v1/voices/settings/default | GET |
getVoiceSettings() | voiceId | /v1/voices/{voiceId}/settings | GET |
getVoice() | voiceId, withSettings | /v1/voices/{voiceId} | GET |
deleteVoice() | voiceId | /v1/voices/{voiceId} | DELETE |
editVoiceSettings() | voiceId, voiceSettings | /v1/voices/{voiceId}/settings/edit | POST |
getUserSubscription() | N/A | /v1/user/subscription | GET |
getUser() | N/A | /v1/user | GET |
getVoices(). | Yes | N/A |
getModels(). | No | eleven_multilingual_v2 |
{stability: 0.95, similarity_boost: 0.75, style: 0.06, use_speaker_boost: true} |
npm i elevenlabs-js.
const elevenLabs = require('elevenlabs-js').
elevenLabs.setApiKey('YOUR_API_KEY').
js
const elevenLabs = require('elevenlabs-js');
const fs = require("fs");
// Set your API key
elevenLabs.setApiKey('YOUR_API_KEY');
elevenLabs.textToSpeech("YOUR_VOICE_ID", "Hello World!", "elevenlabs_multilingual_v2", {
stability: 0.95,
similarity_boost: 0.75,
style: 0.06,
use_speaker_boost: true
}).then(async (res) => {
// You can save the file
await res.saveFile("test.mp3")
// Or get the pipe and do whatever you want with it (like streaming it to the client)
const pipe = await res.pipe;
pipe(fs.createWriteStream("test-with-pipe.mp3"));
});
`
$3
Get a list of available models.
`js
const elevenLabs = require('elevenlabs-js');
// Set your API key
elevenLabs.setApiKey('YOUR_API_KEY');
elevenLabs.getModels().then((res) => {
console.log("models", res);
});
`
$3
Get a list of available voices.
`js
const elevenLabs = require('elevenlabs-js');
// Set your API key
elevenLabs.setApiKey('YOUR_API_KEY');
elevenLabs.getVoices().then((res) => {
console.log("voices", res);
});
`
$3
Get the default voice settings.
`js
const elevenLabs = require('elevenlabs-js');
// Set your API key
elevenLabs.setApiKey('YOUR_API_KEY');
elevenLabs.getDefaultVoiceSettings().then((res) => {
console.log("default voice settings", res);
});
`
$3
Get the voice settings of a voice.
`js
const elevenLabs = require('elevenlabs-js');
// Set your API key
elevenLabs.setApiKey('YOUR_API_KEY');
elevenLabs.getVoiceSettings("YOUR_VOICE_ID").then((res) => {
console.log("voice settings", res);
});
`
$3
Get a voice.
`js
const elevenLabs = require('elevenlabs-js');
// Set your API key
elevenLabs.setApiKey('YOUR_API_KEY');
elevenLabs.getVoice("YOUR_VOICE_ID").then((res) => {
console.log("voice", res);
});
`
$3
Delete a voice.
`js
const elevenLabs = require('elevenlabs-js');
// Set your API key
elevenLabs.setApiKey('YOUR_API_KEY');
elevenLabs.deleteVoice("YOUR_VOICE_ID").then((res) => {
console.log("voice", res);
});
`
$3
Edit the voice settings of a voice.
`js
const elevenLabs = require('elevenlabs-js');
// Set your API key
elevenLabs.setApiKey('YOUR_API_KEY');
elevenLabs.editVoiceSettings("YOUR_VOICE_ID", {
stability: 0.95,
similarity_boost: 0.75,
style: 0.06,
use_speaker_boost: true
}).then((res) => {
console.log("voice settings", res);
});
`
$3
Get the user subscription information.
`js
const elevenLabs = require('elevenlabs-js');
// Set your API key
elevenLabs.setApiKey('YOUR_API_KEY');
elevenLabs.getUserSubscription().then((res) => {
console.log("user subscription", res);
});
`
$3
Get the user information.
`js
const elevenLabs = require('elevenlabs-js');
// Set your API key
elevenLabs.setApiKey('YOUR_API_KEY');
elevenLabs.getUser().then((res) => {
console.log("user", res);
});
``