Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

elevenlabs-js

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elevenlabs-js

This is an Open Source NodeJS package for ElevenLabs Text to Speech API.

  • 1.2.6
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
200
increased by47.06%
Maintainers
1
Weekly downloads
 
Created
Source

elevenlabs-js

ElevenLabs.io API for NodeJS

npm version GitHub Stars GitHub Issues tested with jest License: MIT

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.
⭐⭐

Buy me a coffee

Whether you use this project, have learned something from it, or just like it, please consider supporting it by buying me a coffee, so I can dedicate more time on open-source projects like this :)

Buy Me A Coffee

Table of Contents

Supported Methods

MethodParametersEndPointHTTP Method
textToSpeech()voiceId, text, modelId, voiceSettings/v1/text-to-speech/{voice_id}/streamPOST
getModels()N/A/v1/modelsGET
getVoices()N/A/v1/voicesGET
getDefaultVoiceSettings()N/A/v1/voices/settings/defaultGET
getVoiceSettings()voiceId/v1/voices/{voiceId}/settingsGET
getVoice()voiceId, withSettings/v1/voices/{voiceId}GET
deleteVoice()voiceId/v1/voices/{voiceId}DELETE
editVoiceSettings()voiceId, voiceSettings/v1/voices/{voiceId}/settings/editPOST
getUserSubscription()N/A/v1/user/subscriptionGET
getUser()N/A/v1/userGET

Parameters

ParameterTypeDescriptionRequiredDefault
voiceIdStringThe ID of the voice to use. You can get a list of available voices using getVoices().YesN/A
textStringThe text to convert to speech.YesN/A
modelIdStringThe ID of the model to use. You can get a list of available models using getModels().Noeleven_multilingual_v2
voiceSettingsObjectThe settings to use for the voice.No{stability: 0.95, similarity_boost: 0.75, style: 0.06, use_speaker_boost: true}

Voice Settings

ParameterTypeDescriptionDefault
stabilityFloatThe stability of the voice.0.95
similarity_boostFloatThe similarity boost of the voice.0.75
styleFloatThe style of the voice.0.06
use_speaker_boostBooleanWhether to use speaker boost or not.true

Getting Started

  • Install the package using npm i elevenlabs-js.
  • Import the package using const elevenLabs = require('elevenlabs-js').
  • Set your API key using elevenLabs.setApiKey('YOUR_API_KEY').
  • Utilize the available methods to interact with the elevenlabs.io API.

Usage

textToSpeech() Method

Generate a text to speech audio file. You can either save the file or get the pipe and do whatever you want with it.

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"));
});

getModels() Method

Get a list of available models.

const elevenLabs = require('elevenlabs-js');

// Set your API key
elevenLabs.setApiKey('YOUR_API_KEY');

elevenLabs.getModels().then((res) => {
    console.log("models", res);
});

getVoices() Method

Get a list of available voices.

const elevenLabs = require('elevenlabs-js');

// Set your API key
elevenLabs.setApiKey('YOUR_API_KEY');

elevenLabs.getVoices().then((res) => {
    console.log("voices", res);
});

getDefaultVoiceSettings() Method

Get the default voice settings.

const elevenLabs = require('elevenlabs-js');

// Set your API key
elevenLabs.setApiKey('YOUR_API_KEY');

elevenLabs.getDefaultVoiceSettings().then((res) => {
    console.log("default voice settings", res);
});

getVoiceSettings() Method

Get the voice settings of a voice.

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);
});

getVoice() Method

Get a voice.

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);
});

deleteVoice() Method

Delete a voice.

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);
});

editVoiceSettings() Method

Edit the voice settings of a voice.

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);
});

getUserSubscription() Method

Get the user subscription information.

const elevenLabs = require('elevenlabs-js');

// Set your API key
elevenLabs.setApiKey('YOUR_API_KEY');

elevenLabs.getUserSubscription().then((res) => {
    console.log("user subscription", res);
});

getUser() Method

Get the user information.

const elevenLabs = require('elevenlabs-js');

// Set your API key
elevenLabs.setApiKey('YOUR_API_KEY');

elevenLabs.getUser().then((res) => {
    console.log("user", res);
});

Other Languages

Also, you can find the other languages of this package here:

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords

FAQs

Package last updated on 12 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc