elevenlabs
Advanced tools
Comparing version 0.0.4 to 0.1.0
@@ -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" | ||
} | ||
} |
155
README.md
@@ -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! |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
637382
497
11483
155
6
10
1
2
2
3
6
+ Addedcommand-exists@^1.2.9
+ Addedexeca@^5.1.1
+ Addedform-data@4.0.0
+ Addednode-fetch@2.7.0
+ Addedqs@6.11.2
+ Addedurl-join@4.0.1
+ Addedcall-bind@1.0.7(transitive)
+ Addedcommand-exists@1.2.9(transitive)
+ Addedcross-spawn@7.0.6(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedexeca@5.1.1(transitive)
+ Addedform-data@4.0.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedget-stream@6.0.1(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhuman-signals@2.1.0(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedmerge-stream@2.0.0(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addednpm-run-path@4.0.1(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedqs@6.11.2(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstrip-final-newline@2.0.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedurl-join@4.0.1(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
+ Addedwhich@2.0.2(transitive)
- Removedaxios@^1.6.2
- Removedaxios@1.7.8(transitive)
- Removedfollow-redirects@1.15.9(transitive)
- Removedform-data@4.0.1(transitive)
- Removedproxy-from-env@1.1.0(transitive)