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-node

v2.0.3

Published

This is an open source Eleven Labs NodeJS package for converting text to speech using the Eleven Labs API

Downloads

6,973

Readme

About

This is an open source Eleven Labs NodeJS package for converting text to speech using the Eleven Labs API.

Features

| Function | Parameters | Endpoint | | --------------------------------------- | --------------------------------------------------------------------------- | -------------------------------------- | | textToSpeech | ({voiceId, fileName, textInput, stability, similarityBoost, modelId, style, speakerBoost}) | /v1/text-to-speech/{voice_id} | | textToSpeechStream | ({voiceId, textInput, stability, similarityBoost, modelId, responseType, style, speakerBoost}) | /v1/text-to-speech/{voice_id}/stream | | editVoiceSettings | ({voiceId, stability, similarityBoost}) | /v1/voices/{voice_id}/settings/edit | | getVoiceSettings | ({voiceId}) | /v1/voices/{voice_id}/settings | | deleteVoice | ({voiceId}) | /v1/voices/{voice_id} | | getVoice | ({voiceId}) | /v1/voices/{voice_id} | | getVoices | N/A | /v1/voices | | getModels | N/A | /v1/models | | getUserInfo | N/A | /v1/user | | getUserSubscription | N/A | /v1/user/subscription | | getDefaultVoiceSettings | N/A | /v1/voices/settings/default |

Parameters

| Variable | Description | Type | | --------------------------------------- | --------------------------------------------------------------------------- | -------------------------------------- | | fileName | Name and file path for your audio file e.g (./gen/hello) | String | | textInput | Text to be converted into audio e.g (Hello) | String | | stability | Stability for Text to Speech default (0) | Float | | similarityBoost | Similarity Boost for Text to Speech default (0) | Float | | voiceId | ElevenLabs Voice ID e.g (pNInz6obpgDQGcFmaJgB) | String | | modelId | ElevenLabs Model ID e.g (eleven_multilingual_v2) | String | | responseType | Streaming response type e.g (stream) | String | | speakerBoost | Speaker Boost for Text to Speech e.g (true) | Boolean | | style | Style Exaggeration for Text to Speech (0-100) default (0) | Integer |

Requirements

Get Started

To install the Elevenlabs package, run the following command:

npm install elevenlabs-node

Setup

Setup the ElevenLabs configurations for your project.

| Variable | Description | Default | | --------------------------------------- | --------------------------------------------------------------------------- | -------------------------------------- | | apiKey | (Required) Your API key from Elevenlabs | N/A | | voiceId | (Optional) A Voice ID from Elevenlabs | Adam (pNInz6obpgDQGcFmaJgB) |

const ElevenLabs = require("elevenlabs-node");

const voice = new ElevenLabs(
    {
        apiKey:  "0e2c037kl8561005671b1de345s8765c", // Your API key from Elevenlabs
        voiceId: "pNInz6obpgDQGcFmaJgB",             // A Voice ID from Elevenlabs
    }
);

Usage

Text To Speech

Generating an audio file from text.

const ElevenLabs = require("elevenlabs-node");

const voice = new ElevenLabs(
    {
        apiKey:  "0e2c037kl8561005671b1de345s8765c", // Your API key from Elevenlabs
        voiceId: "pNInz6obpgDQGcFmaJgB",             // A Voice ID from Elevenlabs
    }
);

voice.textToSpeech({
    // Required Parameters
    fileName:        "audio.mp3",                    // The name of your audio file
    textInput:       "mozzy is cool",                // The text you wish to convert to speech

    // Optional Parameters
    voiceId:         "21m00Tcm4TlvDq8ikWAM",         // A different Voice ID from the default
    stability:       0.5,                            // The stability for the converted speech
    similarityBoost: 0.5,                            // The similarity boost for the converted speech
    modelId:         "eleven_multilingual_v2",       // The ElevenLabs Model ID
    style:           1,                              // The style exaggeration for the converted speech
    speakerBoost:    true                            // The speaker boost for the converted speech
  }).then((res) => {
    console.log(res);
});

Text To Speech Stream

Generating an audio stream from text.

const ElevenLabs = require("elevenlabs-node");
const fs = require("fs-extra");

const voice = new ElevenLabs(
    {
        apiKey:  "0e2c037kl8561005671b1de345s8765c", // Your API key from Elevenlabs
        voiceId: "pNInz6obpgDQGcFmaJgB",             // A Voice ID from Elevenlabs
    }
);

const voiceResponse = voice.textToSpeechStream({
    // Required Parameters
    textInput:       "mozzy is cool",                // The text you wish to convert to speech

    // Optional Parameters
    voiceId:         "21m00Tcm4TlvDq8ikWAM",         // A different Voice ID from the default
    stability:       0.5,                            // The stability for the converted speech
    similarityBoost: 0.5,                            // The similarity boost for the converted speech
    modelId:         "eleven_multilingual_v2",       // The ElevenLabs Model ID
    style:           1,                              // The style exaggeration for the converted speech
    responseType:    "stream",                       // The streaming type (arraybuffer, stream, json)
    speakerBoost:    true                            // The speaker boost for the converted speech
  }).then((res) => {
    res.pipe(fs.createWriteStream(fileName));
});

Edit Voice Settings

Editing voice settings.

const ElevenLabs = require("elevenlabs-node");

const voice = new ElevenLabs(
    {
        apiKey:  "0e2c037kl8561005671b1de345s8765c", // Your API key from Elevenlabs
    }
);

const voiceResponse = voice.editVoiceSettings({
    // Required Parameters
    voiceId:         "pNInz6obpgDQGcFmaJgB",         // The ID of the voice you want to edit
    stabilityBoost:  0.5,                            // The Stability Boost for the voice
    similarityBoost: 0.5,                            // The Similarity Boost for the voice
  }).then((res) => {
    console.log(res);
});

Get Voice Settings

Getting voice settings.

const ElevenLabs = require("elevenlabs-node");

const voice = new ElevenLabs(
    {
        apiKey:  "0e2c037kl8561005671b1de345s8765c", // Your API key from Elevenlabs
    }
);

const voiceResponse = voice.getVoiceSettings({
    // Required Parameters
    voiceId:         "pNInz6obpgDQGcFmaJgB"          // The ID of the voice you want to get
  }).then((res) => {
    console.log(res);
});

Delete Voice

Delete voice.

const ElevenLabs = require("elevenlabs-node");

const voice = new ElevenLabs(
    {
        apiKey:  "0e2c037kl8561005671b1de345s8765c", // Your API key from Elevenlabs
    }
);

const voiceResponse = voice.deleteVoice({
    // Required Parameters
    voiceId:         "pNInz6obpgDQGcFmaJgB"          // The ID of the voice you want to delete
  }).then((res) => {
    console.log(res);
});

Get Voice

Getting voice details.

const ElevenLabs = require("elevenlabs-node");

const voice = new ElevenLabs(
    {
        apiKey:  "0e2c037kl8561005671b1de345s8765c", // Your API key from Elevenlabs
    }
);

const voiceResponse = voice.getVoice({
    // Required Parameters
    voiceId:         "pNInz6obpgDQGcFmaJgB"          // The ID of the voice you want to get
  }).then((res) => {
    console.log(res);
});

Get Voices

Getting all voice details.

const ElevenLabs = require("elevenlabs-node");

const voice = new ElevenLabs(
    {
        apiKey:  "0e2c037kl8561005671b1de345s8765c", // Your API key from Elevenlabs
    }
);

const voiceResponse = voice.getVoices().then((res) => {
  console.log(res);
});

Get Models

Getting all model details.

const ElevenLabs = require("elevenlabs-node");

const voice = new ElevenLabs(
    {
        apiKey:  "0e2c037kl8561005671b1de345s8765c", // Your API key from Elevenlabs
    }
);

const voiceResponse = voice.getModels().then((res) => {
  console.log(res);
});

Get User Info

Getting user info associated with the API Key.

const ElevenLabs = require("elevenlabs-node");

const voice = new ElevenLabs(
    {
        apiKey:  "0e2c037kl8561005671b1de345s8765c", // Your API key from Elevenlabs
    }
);

const voiceResponse = voice.getUserInfo().then((res) => {
  console.log(res);
});

Get User Subscription

Getting user subscription info associated with the API Key.

const ElevenLabs = require("elevenlabs-node");

const voice = new ElevenLabs(
    {
        apiKey:  "0e2c037kl8561005671b1de345s8765c", // Your API key from Elevenlabs
    }
);

const voiceResponse = voice.getUserSubscription().then((res) => {
  console.log(res);
});

Get Default Voice Settings

Getting default voice settings.

const ElevenLabs = require("elevenlabs-node");

const voice = new ElevenLabs(
    {
        apiKey:  "0e2c037kl8561005671b1de345s8765c", // Your API key from Elevenlabs
    }
);

const voiceResponse = voice.getDefaultVoiceSettings().then((res) => {
    console.log(res);
});

Contributing

Contributions are welcome :)

Read our CONTRIBUTING.md to learn more.