• Stars
    star
    162
  • Rank 230,819 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 1 year ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Eleven Labs text to speech package for NodeJS.

Eleven Labs Logo

Eleven Labs Node

Eleven Labs NodeJS package for converting text to speech!

GitHub Contributors Issues GitHub pull requests

NPM Package Build

Report Bug ยท Request Feature

Drop us a โญ on GitHub to help the project improve!

Stars

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.

More Repositories

1

TiktokChatGPT

A conversational bot for tiktok livestreams built on ChatGPT.
JavaScript
10
star
2

TinderAI

A data science and Artificial Intelligence based project that entailed the development of a model that I used to optimize and collect data from online dating sites.The main goal of the project was to track my online behaviors, automate the social interaction on these sites and and identify social patterns from my data.
Python
7
star
3

Copresenter

A virtual co-host that makes presentations a breeze by using AI to read out your slides, freeing you from prep hassles and letting you focus on delivery
TypeScript
6
star
4

MHENGA

An implementation of Swahili and Node JS to create a Twitter Bot that posts Swahili sayings
JavaScript
5
star
5

RhumbaBot

A bot designed to help me exercise by playing rhumba music at random intervals
Python
3
star
6

ComplimentBot

A Twitter bot that generates and posts randomized compliments on the user timeline.
Python
3
star
7

vercel-postgress

Trying out Vercel Ship goodies ๐Ÿ˜‹
TypeScript
2
star
8

vercel-terraform

Vercel deployment with Terraform infrastructure setup
TypeScript
2
star
9

VoiceLauncher2

Learn how to create a Java application that will allow you to launch programs and execute tasks using only your voice. The application will make the use of a Sphinx Java library to recognize and process vocal input into text that is then linked to user customized commands
Java
2
star
10

ASP-jQueryAjax

A simple recreation of the project as shown in https://www.youtube.com/watch?v=DI_YppvLgJ8
JavaScript
1
star
11

nuxt-test

Vue
1
star
12

sveltekit-openai

CSS
1
star
13

fundi-showcase

JavaScript
1
star
14

who-am-i

My personal dev portfolio. Built in Next.JS, hosted on GitHub pages ๐Ÿ“ฐ & Vercel ๐Ÿ”บ
JavaScript
1
star
15

a-star

A* pathfinder algo
Python
1
star
16

journal_exer

A simple journaling website
Python
1
star
17

py-sample

A slice of .py
1
star
18

FelixWaweru

1
star
19

ASP-MVC-practice

A simple recreation of the project created on https://www.youtube.com/watch?v=E7Voso411Vs
JavaScript
1
star
20

Becks_Depression_Inventory

A simple questionnaire based on the Beck's depression inventory that prompts for user input and grades their mood from 'Normal' to 'Extreme Depression'.
Python
1
star