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

elevenlabs

Package Overview
Dependencies
Maintainers
2
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elevenlabs - npm Package Compare versions

Comparing version 0.0.4 to 0.1.0

api/errors/index.d.ts

27

dist/index.d.ts

@@ -1,23 +0,4 @@

type ElevenLabsOptions = {
apiKey?: string;
voiceId?: string;
baseUrl?: string;
};
type TextToSpeechOptions = {
text: string;
modelId?: string;
stability?: number;
similarityBoost?: number;
style?: number;
speakerBoost?: boolean;
};
declare class ElevenLabs {
readonly apiKey?: string;
readonly voiceId: string;
readonly baseUrl: string;
constructor(options?: ElevenLabsOptions);
textToSpeech(options: TextToSpeechOptions): Promise<Buffer>;
}
export { ElevenLabs, type ElevenLabsOptions, type TextToSpeechOptions };
export * as ElevenLabs from "./api";
export { ElevenLabsClient } from "./Client";
export { ElevenLabsEnvironment } from "./environments";
export { ElevenLabsError, ElevenLabsTimeoutError } from "./errors";
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/index.ts
var src_exports = {};
__export(src_exports, {
ElevenLabs: () => ElevenLabs
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
module.exports = __toCommonJS(src_exports);
// src/elevenlabs.ts
var import_axios = __toESM(require("axios"));
var ElevenLabs = class {
constructor(options) {
this.apiKey = (options == null ? void 0 : options.apiKey) || process.env.ELEVENLABS_API_KEY || void 0;
this.voiceId = (options == null ? void 0 : options.voiceId) ? options.voiceId : "pFZP5JQG7iQjIQuC4Bku";
this.baseUrl = (options == null ? void 0 : options.baseUrl) ? options.baseUrl : "https://api.elevenlabs.io/v1";
if (!this.apiKey) {
throw new Error("No API key provided");
}
}
textToSpeech(options) {
return __async(this, null, function* () {
var _a, _b, _c, _d, _e;
const voiceId = this.voiceId;
const voiceURL = `${this.baseUrl}/text-to-speech/${voiceId}`;
const text = options.text;
const stability = (_a = options.stability) != null ? _a : 0.5;
const similarityBoost = (_b = options.similarityBoost) != null ? _b : 0.75;
const style = (_c = options.style) != null ? _c : 0;
const speakerBoost = (_d = options.speakerBoost) != null ? _d : true;
const modelId = (_e = options.modelId) != null ? _e : "eleven_multilingual_v2";
if (!text) {
throw new Error("Missing parameter: text");
}
const { data } = yield (0, import_axios.default)({
method: "POST",
url: voiceURL,
data: {
text,
voice_settings: {
stability,
similarity_boost: similarityBoost,
style,
use_speaker_boost: speakerBoost
},
model_id: modelId
},
headers: {
Accept: "audio/mpeg",
"xi-api-key": this.apiKey,
"Content-Type": "application/json"
},
responseType: "arraybuffer"
});
return data;
});
}
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ElevenLabs
});
Object.defineProperty(exports, "__esModule", { value: true });
exports.ElevenLabsTimeoutError = exports.ElevenLabsError = exports.ElevenLabsEnvironment = exports.ElevenLabsClient = exports.ElevenLabs = void 0;
exports.ElevenLabs = __importStar(require("./api"));
var Client_1 = require("./Client");
Object.defineProperty(exports, "ElevenLabsClient", { enumerable: true, get: function () { return Client_1.ElevenLabsClient; } });
var environments_1 = require("./environments");
Object.defineProperty(exports, "ElevenLabsEnvironment", { enumerable: true, get: function () { return environments_1.ElevenLabsEnvironment; } });
var errors_1 = require("./errors");
Object.defineProperty(exports, "ElevenLabsError", { enumerable: true, get: function () { return errors_1.ElevenLabsError; } });
Object.defineProperty(exports, "ElevenLabsTimeoutError", { enumerable: true, get: function () { return errors_1.ElevenLabsTimeoutError; } });
{
"name": "elevenlabs",
"version": "0.0.4",
"description": "ElevenLabs",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"devDependencies": {
"@changesets/cli": "^2.27.1",
"@types/node": "^20.10.3",
"dotenv": "^16.3.1",
"tsup": "^8.0.1",
"tsx": "^4.6.2",
"typescript": "^5.3.2"
},
"keywords": [
"elevenlabs"
],
"author": {
"name": "Marcel Thomas",
"url": "https://marcelthomas.co.uk"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/marcelthomas5/elevenlabs.git"
},
"bugs": {
"url": "https://github.com/marcelthomas5/elevenlabs/issues"
},
"homepage": "https://github.com/marcelthomas5/elevenlabs",
"dependencies": {
"axios": "^1.6.2"
},
"scripts": {
"dev": "tsx watch dev/index.ts",
"build": "tsup src/index.ts --format cjs,esm --dts",
"lint": "tsc",
"changeset": "changeset",
"release": "changeset publish"
}
"name": "elevenlabs",
"version": "0.1.0",
"private": false,
"repository": "https://github.com/elevenlabs/elevenlabs-js",
"main": "./index.js",
"types": "./index.d.ts",
"scripts": {
"format": "prettier --write 'src/**/*.ts'",
"build": "tsc",
"prepack": "cp -rv dist/. ."
},
"dependencies": {
"url-join": "4.0.1",
"form-data": "4.0.0",
"node-fetch": "2.7.0",
"qs": "6.11.2",
"command-exists": "^1.2.9",
"execa": "^5.1.1"
},
"devDependencies": {
"@types/url-join": "4.0.1",
"@types/qs": "6.9.8",
"@types/node-fetch": "2.6.9",
"@types/node": "17.0.33",
"prettier": "2.7.1",
"typescript": "4.6.4",
"jest": "^29.7.0",
"@types/jest": "^29.5.5",
"ts-jest": "^29.1.1",
"@types/command-exists": "^1.2.3"
}
}

@@ -1,1 +0,154 @@

# elevenlabs
# ElevenLabs JS Library
![LOGO](https://github.com/elevenlabs/elevenlabs-python/assets/12028621/21267d89-5e82-4e7e-9c81-caf30b237683)
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen)](https://buildwithfern.com/?utm_source=fern-elevenlabs/elevenlabs-python/readme)
[![Discord](https://badgen.net/badge/black/ElevenLabs/icon?icon=discord&label)](https://discord.gg/elevenlabs)
[![Twitter](https://badgen.net/badge/black/elevenlabsio/icon?icon=twitter&label)](https://twitter.com/elevenlabsio)
[![npm shield](https://img.shields.io/npm/v/elevenlabs)](https://www.npmjs.com/package/elevenlabs)
The official JS API for [ElevenLabs](https://elevenlabs.io/) [text-to-speech software.](https://elevenlabs.io/text-to-speech) Eleven brings the most compelling, rich and lifelike voices to creators and developers in just a few lines of code.
## 📖 API & Docs
Check out the [HTTP API documentation](https://elevenlabs.io/docs/api-reference).
## ⚙️ Install
```bash
npm install elevenlabs
# or
yarn add elevenlabs
```
## 🗣️ Usage
[![Open in Spaces](https://img.shields.io/badge/🤗-Open%20in%20Spaces-blue.svg)](https://huggingface.co/spaces/elevenlabs/tts)
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/gist/flavioschneider/49468d728a816c6538fd2f56b3b50b96/elevenlabs-python.ipynb)
We support two main models: the newest `eleven_multilingual_v2`, a single foundational model supporting 29 languages including English, Chinese, Spanish, Hindi, Portuguese, French, German, Japanese, Arabic, Korean, Indonesian, Italian, Dutch, Turkish, Polish, Swedish, Filipino, Malay, Russian, Romanian, Ukrainian, Greek, Czech, Danish, Finnish, Bulgarian, Croatian, Slovak, and Tamil; and `eleven_monolingual_v1`, a low-latency model specifically trained for English speech.
```ts
import { ElevenLabsClient, play } from "elevenlabs";
const elevenlabs = new ElevenLabsClient({
apiKey: "YOUR_API_KEY" // Defaults to process.env.ELEVENLABS_API_KEY
})
const audio = await elevenlabs.generate({
voice: "Rachel",
text: "Hello! 你好! Hola! नमस्ते! Bonjour! こんにちは! مرحبا! 안녕하세요! Ciao! Cześć! Привіт! வணக்கம்!",
model_id: "eleven_multilingual_v2"
});
await play(audio);
```
<details> <summary> Play </summary>
<i> Don't forget to unmute the player! </i>
[audio (3).webm](https://github.com/elevenlabs/elevenlabs-python/assets/12028621/778fd3ed-0a3a-4d66-8f73-faee099dfdd6)
</details>
## 🗣️ Voices
List all your available voices with `voices()`.
```ts
import { ElevenLabsClient } from "elevenlabs";
const elevenlabs = new ElevenLabsClient({
apiKey: "YOUR_API_KEY" // Defaults to process.env.ELEVENLABS_API_KEY
})
const voices = await elevenlabs.voices.getAll();
```
<details> <summary> Show output </summary>
```ts
{
voices: [
{
voice_id: '21m00Tcm4TlvDq8ikWAM',
name: 'Rachel',
samples: null,
category: 'premade',
fine_tuning: [Object],
labels: [Object],
description: null,
preview_url: 'https://storage.googleapis.com/eleven-public-prod/premade/voices/21m00Tcm4TlvDq8ikWAM/df6788f9-5c96-470d-8312-aab3b3d8f50a.mp3',
available_for_tiers: [],
settings: null,
sharing: null,
high_quality_base_model_ids: []
},
{
voice_id: '29vD33N1CtxCmqQRPOHJ',
name: 'Drew',
samples: null,
category: 'premade',
fine_tuning: [Object],
labels: [Object],
description: null,
preview_url: 'https://storage.googleapis.com/eleven-public-prod/premade/voices/29vD33N1CtxCmqQRPOHJ/e8b52a3f-9732-440f-b78a-16d5e26407a1.mp3',
available_for_tiers: [],
settings: null,
sharing: null,
high_quality_base_model_ids: []
},
...
]
}
```
</details>
## 🚿 Streaming
Stream audio in real-time, as it's being generated.
```ts
import { ElevenLabsClient, stream } from "elevenlabs";
const audioStream = await elevenlabs.generate({
stream: true,
voice: "Bella",
text: "This is a... streaming voice",
model_id: "eleven_multilingual_v2"
});
stream(audioStream)
```
## HTTP Client
The SDK also exposes an HTTP client that you can use to query our
various endpoints directly.
```ts
import { ElevenLabsClient, stream } from "@elevenlabs/api";
const models = await eleven.models.getAll();
const audioStream = await elevenlabs.textToSpeech.convert('21m00Tcm4TlvDq8ikWAM', {
text: "This is a... streaming voice!!",
model_id: "eleven_multilingual_v2"
});
stream(audioStream)
```
## Elevenlabs Namespace
All of the ElevenLabs models are nested within the `ElevenLabs` namespace.
![Alt text](assets/namespace.png)
## Languages Supported
We support 29 languages and 100+ accents. Explore [all languages](https://elevenlabs.io/languages).
<img src="https://github.com/fern-elevenlabs/elevenlabs-python/assets/83524670/ea02a0a8-2691-4403-bbb1-ec14993a0adf" width="900">
## Contributing
While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!
On the other hand, contributions to the README are always very welcome!
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