npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

elevenlabs-js

v1.2.6

Published

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

Downloads

1,104

Readme

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 :)

Table of Contents

Supported Methods

| Method | Parameters | EndPoint | HTTP Method | |-----------------------------|-----------------------------------------------|----------------------------------------|-------------| | 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 |

Parameters

| Parameter | Type | Description | Required | Default | |---------------|--------|-----------------------------------------------------------------------------------------|----------|-----------------------------------------------------------------------------------| | voiceId | String | The ID of the voice to use. You can get a list of available voices using getVoices(). | Yes | N/A | | text | String | The text to convert to speech. | Yes | N/A | | modelId | String | The ID of the model to use. You can get a list of available models using getModels(). | No | eleven_multilingual_v2 | | voiceSettings | Object | The settings to use for the voice. | No | {stability: 0.95, similarity_boost: 0.75, style: 0.06, use_speaker_boost: true} |

Voice Settings

| Parameter | Type | Description | Default | |-------------------|---------|--------------------------------------|---------| | stability | Float | The stability of the voice. | 0.95 | | similarity_boost | Float | The similarity boost of the voice. | 0.75 | | style | Float | The style of the voice. | 0.06 | | use_speaker_boost | Boolean | Whether 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.