/elevenlabs-node

Eleven Labs text to speech package for NodeJS.

Primary LanguageJavaScriptMIT LicenseMIT

Eleven Labs

Eleven Labs Node

Eleven Labs NodeJS package for converting text to speech!

GitHub Contributors Issues GitHub pull requests

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 (apiKey, voiceID, fileName, textInput, stability, similarityBoost, modelId) /v1/text-to-speech/{voice_id}
textToSpeechStream (apiKey, voiceID, textInput, stability, similarityBoost, modelId) /v1/text-to-speech/{voice_id}/stream
getVoices (apiKey) /v1/voices
getDefaultVoiceSettings N/A /v1/voices/settings/default
getVoiceSettings (apiKey, voiceID) /v1/voices/{voice_id}/settings
getVoice (apiKey, voiceID) /v1/voices/{voice_id}
deleteVoice (apiKey, voiceID) /v1/voices/{voice_id}
editVoiceSettings (apiKey, voiceID, stability, similarityBoost) /v1/voices/{voice_id}/settings/edit

Requirements

Get Started

To install the Elevenlabs package, run the following command:

npm install elevenlabs-node

Usage

Getting voice details.

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

const apiKey = "0e2c037kl8561005671b1de345s8765c"; // Your API key from Elevenlabs
const voiceID = "pNInz6obpgDQGcFmaJgB"; // The ID of the voice you want to get

const voiceResponse = voice.getVoice(apiKey, voiceID).then((res) => {
  console.log(res);
});

Generating an audio file from text

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

const apiKey = "0e2c037kl8561005671b1de345s8765c"; // Your API key from Elevenlabs
const voiceID = "pNInz6obpgDQGcFmaJgB"; // The ID of the voice you want to get
const fileName = "audio.mp3"; // The name of your audio file
const textInput = "mozzy is cool"; // The text you wish to convert to speech

voice.textToSpeech(apiKey, voiceID, fileName, textInput).then((res) => {
  console.log(res);
});

Generating an audio stream from text

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

const apiKey = "0e2c037kl8561005671b1de345s8765c"; // Your API key from Elevenlabs
const voiceID = "pNInz6obpgDQGcFmaJgB"; // The ID of the voice you want to get
const fileName = "audio.mp3"; // The name of your audio file
const textInput = "mozzy is cool"; // The text you wish to convert to speech

voice.textToSpeechStream(apiKey, voiceID, textInput).then((res) => {
  res.pipe(fs.createWriteStream(fileName));
});

Contributing

Contributions are welcome :)

Read our CONTRIBUTING.md to learn more.