@apicity/elevenlabs 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +190 -0
- package/dist/src/elevenlabs.d.ts +3 -0
- package/dist/src/elevenlabs.d.ts.map +1 -0
- package/dist/src/elevenlabs.js +168 -0
- package/dist/src/elevenlabs.js.map +1 -0
- package/dist/src/example.d.ts +8 -0
- package/dist/src/example.d.ts.map +1 -0
- package/dist/src/example.js +94 -0
- package/dist/src/example.js.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/types.d.ts +79 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +14 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/zod.d.ts +122 -0
- package/dist/src/zod.d.ts.map +1 -0
- package/dist/src/zod.js +69 -0
- package/dist/src/zod.js.map +1 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Justin Tanner
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# @apicity/elevenlabs
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@apicity/elevenlabs)
|
|
4
|
+
[](package.json)
|
|
5
|
+
[](tsconfig.json)
|
|
6
|
+
|
|
7
|
+
ElevenLabs provider for sound effect generation, text-to-speech, and audio APIs.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @apicity/elevenlabs
|
|
13
|
+
# or
|
|
14
|
+
pnpm add @apicity/elevenlabs
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { elevenlabs as createElevenlabs } from "@apicity/elevenlabs";
|
|
21
|
+
|
|
22
|
+
const elevenlabs = createElevenlabs({ apiKey: process.env.ELEVENLABS_API_KEY! });
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Real-world example: generate a sound effect, then run it through Scribe v2
|
|
26
|
+
|
|
27
|
+
ElevenLabs' two flagship audio surfaces fit together cleanly: text-to-
|
|
28
|
+
sound-effects spits out raw MP3 bytes, and Scribe v2 hands back a typed
|
|
29
|
+
transcript with word-level timestamps plus tagged audio events. The
|
|
30
|
+
round-trip below — generate a UI click, then transcribe a separate clip
|
|
31
|
+
with `tag_audio_events: true` — mirrors what
|
|
32
|
+
[`tests/integration/elevenlabs-sound-generation.test.ts`](../../../tests/integration/elevenlabs-sound-generation.test.ts)
|
|
33
|
+
and
|
|
34
|
+
[`tests/integration/elevenlabs-speech-to-text.test.ts`](../../../tests/integration/elevenlabs-speech-to-text.test.ts)
|
|
35
|
+
replay against
|
|
36
|
+
[`tests/recordings/elevenlabs_2379486140/`](../../../tests/recordings/elevenlabs_2379486140/),
|
|
37
|
+
so every payload, response field, and byte count below comes straight
|
|
38
|
+
from the recorded HARs.
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
42
|
+
import { elevenlabs as createElevenlabs } from "@apicity/elevenlabs";
|
|
43
|
+
import type { ElevenLabsTranscript } from "@apicity/elevenlabs";
|
|
44
|
+
|
|
45
|
+
const elevenlabs = createElevenlabs({ apiKey: process.env.ELEVENLABS_API_KEY! });
|
|
46
|
+
|
|
47
|
+
// 1. Generate a 0.5s UI click. soundGeneration returns the raw MP3 as
|
|
48
|
+
// an ArrayBuffer — there's no JSON wrapper, the response body is
|
|
49
|
+
// audio/mpeg straight off the wire. duration_seconds (0.5–30) caps
|
|
50
|
+
// the clip length and prompt_influence (0–1) trades prompt-fidelity
|
|
51
|
+
// for creative variation. The factory also accepts `output_format`
|
|
52
|
+
// on the same request object and silently moves it to the URL query.
|
|
53
|
+
const audio = await elevenlabs.v1.soundGeneration({
|
|
54
|
+
text: "soft ui click",
|
|
55
|
+
duration_seconds: 0.5,
|
|
56
|
+
prompt_influence: 0.3,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
writeFileSync("./click.mp3", new Uint8Array(audio));
|
|
60
|
+
console.log(`Generated ${audio.byteLength} bytes of audio/mpeg`);
|
|
61
|
+
// → "Generated 11764 bytes of audio/mpeg"
|
|
62
|
+
// ElevenLabs charged 10 characters for this call (visible in the
|
|
63
|
+
// `character-cost` response header on the original request).
|
|
64
|
+
|
|
65
|
+
// 2. Transcribe a separate audio clip with Scribe v2. The request goes
|
|
66
|
+
// up as multipart/form-data — pass a Blob and the rest as ergonomic
|
|
67
|
+
// fields; the factory packs the form, sets xi-api-key, and parses
|
|
68
|
+
// the JSON response. tag_audio_events: true tells Scribe to surface
|
|
69
|
+
// non-speech events ([phone beeping], [laughter], [applause]) inline
|
|
70
|
+
// with words instead of dropping them.
|
|
71
|
+
const phoneBeep = readFileSync("./phone-beeping.mp3"); // 2,528 bytes
|
|
72
|
+
const file = new Blob([phoneBeep], { type: "audio/mp3" });
|
|
73
|
+
|
|
74
|
+
const result = (await elevenlabs.v1.speechToText({
|
|
75
|
+
file,
|
|
76
|
+
model_id: "scribe_v2",
|
|
77
|
+
language_code: "eng",
|
|
78
|
+
tag_audio_events: true,
|
|
79
|
+
})) as ElevenLabsTranscript;
|
|
80
|
+
|
|
81
|
+
// 3. The transcript is rich. `text` is the human-readable form;
|
|
82
|
+
// `words` is the per-token breakdown with absolute timestamps and a
|
|
83
|
+
// `type` discriminator ("word" | "spacing" | "audio_event") plus a
|
|
84
|
+
// `logprob` confidence. `transcription_id` is durable — you can
|
|
85
|
+
// retrieve the same transcript later through the history API.
|
|
86
|
+
console.log(
|
|
87
|
+
`${result.language_code} · ${(result.language_probability * 100).toFixed(0)}% confident`,
|
|
88
|
+
);
|
|
89
|
+
// → "eng · 100% confident"
|
|
90
|
+
console.log(
|
|
91
|
+
`${result.audio_duration_secs}s · transcription_id=${result.transcription_id}`,
|
|
92
|
+
);
|
|
93
|
+
// → "0.5s · transcription_id=CeeidI2QJ8kkN1mcq8HX"
|
|
94
|
+
console.log(result.text);
|
|
95
|
+
// → "[phone beeping]"
|
|
96
|
+
|
|
97
|
+
// 4. Walk the words array, splitting audio events from spoken words
|
|
98
|
+
// via the `type` discriminator. On a clip with no speech every
|
|
99
|
+
// entry is an audio_event; on real speech you'll see "word" and
|
|
100
|
+
// "spacing" entries interleaved with bracketed events.
|
|
101
|
+
for (const w of result.words) {
|
|
102
|
+
const tag =
|
|
103
|
+
w.type === "audio_event"
|
|
104
|
+
? "event"
|
|
105
|
+
: w.type === "word"
|
|
106
|
+
? "word "
|
|
107
|
+
: "space";
|
|
108
|
+
console.log(
|
|
109
|
+
` ${tag} [${w.start.toFixed(2)}–${w.end.toFixed(2)}s] ${w.text}` +
|
|
110
|
+
(w.logprob !== undefined ? ` (logprob ${w.logprob.toFixed(3)})` : ""),
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
// → " event [0.00–0.44s] [phone beeping] (logprob -0.335)"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Notes**
|
|
117
|
+
|
|
118
|
+
- `soundGeneration` returns binary, not JSON — the provider already
|
|
119
|
+
reads it as `arrayBuffer()` and hands you an `ArrayBuffer`. Pass
|
|
120
|
+
`output_format: "mp3_44100_128"` (or any other ElevenLabs codec
|
|
121
|
+
string) on the request object and the factory will strip it from
|
|
122
|
+
the body and move it to the `?output_format=` URL query.
|
|
123
|
+
- `speechToText` accepts either a `file` Blob or a `cloud_storage_url`
|
|
124
|
+
(S3/GCS/HTTP). For long-form audio set `webhook: true` — the call
|
|
125
|
+
returns a small `ElevenLabsWebhookAcknowledgement` instead of the
|
|
126
|
+
transcript, and the finished result is delivered to your registered
|
|
127
|
+
webhook. Type-narrow the union with `"text" in result` before
|
|
128
|
+
reading transcript fields.
|
|
129
|
+
- Set `diarize: true` and `num_speakers` to label words by speaker;
|
|
130
|
+
the per-word `speaker_id` field gets populated in that mode. Combine
|
|
131
|
+
with `use_multi_channel: true` for stereo audio and the response
|
|
132
|
+
switches to `ElevenLabsMultichannelTranscript` (one transcript per
|
|
133
|
+
channel under `transcripts[]`).
|
|
134
|
+
- Errors throw `ElevenLabsError` with `status`, `code`, and the parsed
|
|
135
|
+
body attached. ElevenLabs returns either FastAPI's
|
|
136
|
+
`{ detail: [{msg, ...}] }` shape or `{ detail: { status, message } }`;
|
|
137
|
+
the client normalises both into `error.message`.
|
|
138
|
+
|
|
139
|
+
## API Reference
|
|
140
|
+
|
|
141
|
+
2 endpoints across 2 groups. Each method mirrors an upstream URL path.
|
|
142
|
+
|
|
143
|
+
### soundGeneration
|
|
144
|
+
|
|
145
|
+
<details>
|
|
146
|
+
<summary><code>POST</code> <b><code>elevenlabs.v1.soundGeneration</code></b></summary>
|
|
147
|
+
|
|
148
|
+
<code>POST https://api.elevenlabs.io/v1/sound-generation</code>
|
|
149
|
+
|
|
150
|
+
[Upstream docs ↗](https://elevenlabs.io/docs/api-reference/text-to-sound-effects/convert)
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
const res = await elevenlabs.v1.soundGeneration({ /* ... */ });
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Source: [`packages/provider/elevenlabs/src/elevenlabs.ts`](src/elevenlabs.ts)
|
|
157
|
+
|
|
158
|
+
</details>
|
|
159
|
+
|
|
160
|
+
### speechToText
|
|
161
|
+
|
|
162
|
+
<details>
|
|
163
|
+
<summary><code>POST</code> <b><code>elevenlabs.v1.speechToText</code></b></summary>
|
|
164
|
+
|
|
165
|
+
<code>POST https://api.elevenlabs.io/v1/speech-to-text</code>
|
|
166
|
+
|
|
167
|
+
[Upstream docs ↗](https://elevenlabs.io/docs/api-reference/speech-to-text/convert)
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
const res = await elevenlabs.v1.speechToText({ /* ... */ });
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Source: [`packages/provider/elevenlabs/src/elevenlabs.ts`](src/elevenlabs.ts)
|
|
174
|
+
|
|
175
|
+
</details>
|
|
176
|
+
|
|
177
|
+
## Middleware
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
import { elevenlabs as createElevenlabs, withRetry } from "@apicity/elevenlabs";
|
|
181
|
+
|
|
182
|
+
const elevenlabs = createElevenlabs({ apiKey: process.env.ELEVENLABS_API_KEY! });
|
|
183
|
+
const models = withRetry(elevenlabs.get.v1.models, { retries: 3 });
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Part of the [apicity](https://github.com/justintanner/apicity) monorepo.
|
|
187
|
+
|
|
188
|
+
## License
|
|
189
|
+
|
|
190
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elevenlabs.d.ts","sourceRoot":"","sources":["../../src/elevenlabs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAIjB,kBAAkB,EAEnB,MAAM,SAAS,CAAC;AAOjB,wBAAgB,UAAU,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB,CA6NtE"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { ElevenLabsError, } from "./types.js";
|
|
2
|
+
import { ElevenLabsSoundGenerationRequestSchema, ElevenLabsSpeechToTextRequestSchema, } from "./zod.js";
|
|
3
|
+
import { attachExamples } from "./example.js";
|
|
4
|
+
export function elevenlabs(opts) {
|
|
5
|
+
const baseURL = opts.baseURL ?? "https://api.elevenlabs.io";
|
|
6
|
+
const doFetch = opts.fetch ?? fetch;
|
|
7
|
+
const timeout = opts.timeout ?? 30000;
|
|
8
|
+
function attachAbortHandler(signal, controller) {
|
|
9
|
+
if (signal.aborted) {
|
|
10
|
+
controller.abort();
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
signal.addEventListener("abort", () => controller.abort(), { once: true });
|
|
14
|
+
}
|
|
15
|
+
// ElevenLabs returns either FastAPI 422 `{ detail: [{loc,msg,type}, ...] }` or
|
|
16
|
+
// the wider `{ detail: { status, message } }` shape. Surface whichever the
|
|
17
|
+
// server sent so the caller sees the real reason.
|
|
18
|
+
function formatErrorMessage(status, body) {
|
|
19
|
+
if (typeof body === "object" && body !== null && "detail" in body) {
|
|
20
|
+
const detail = body.detail;
|
|
21
|
+
if (Array.isArray(detail) && detail.length > 0) {
|
|
22
|
+
const first = detail[0];
|
|
23
|
+
if (first?.msg) {
|
|
24
|
+
return `ElevenLabs API error ${status}: ${first.msg}`;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (typeof detail === "object" && detail !== null) {
|
|
28
|
+
const d = detail;
|
|
29
|
+
if (d.message) {
|
|
30
|
+
return `ElevenLabs API error ${status}: ${d.message}`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (typeof detail === "string") {
|
|
34
|
+
return `ElevenLabs API error ${status}: ${detail}`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return `ElevenLabs API error: ${status}`;
|
|
38
|
+
}
|
|
39
|
+
function extractErrorCode(body) {
|
|
40
|
+
if (typeof body === "object" && body !== null && "detail" in body) {
|
|
41
|
+
const detail = body.detail;
|
|
42
|
+
if (typeof detail === "object" && detail !== null) {
|
|
43
|
+
const d = detail;
|
|
44
|
+
if (typeof d.status === "string")
|
|
45
|
+
return d.status;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
async function makeBinaryRequest(path, body, query, signal) {
|
|
51
|
+
const controller = new AbortController();
|
|
52
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
53
|
+
if (signal) {
|
|
54
|
+
attachAbortHandler(signal, controller);
|
|
55
|
+
}
|
|
56
|
+
const qs = query ? `?${new URLSearchParams(query).toString()}` : "";
|
|
57
|
+
try {
|
|
58
|
+
const res = await doFetch(`${baseURL}${path}${qs}`, {
|
|
59
|
+
method: "POST",
|
|
60
|
+
headers: {
|
|
61
|
+
"xi-api-key": opts.apiKey,
|
|
62
|
+
"Content-Type": "application/json",
|
|
63
|
+
},
|
|
64
|
+
body: JSON.stringify(body),
|
|
65
|
+
signal: controller.signal,
|
|
66
|
+
});
|
|
67
|
+
clearTimeout(timeoutId);
|
|
68
|
+
if (!res.ok) {
|
|
69
|
+
let resBody = null;
|
|
70
|
+
try {
|
|
71
|
+
resBody = await res.json();
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// ignore parse errors
|
|
75
|
+
}
|
|
76
|
+
throw new ElevenLabsError(formatErrorMessage(res.status, resBody), res.status, resBody, extractErrorCode(resBody));
|
|
77
|
+
}
|
|
78
|
+
return await res.arrayBuffer();
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
clearTimeout(timeoutId);
|
|
82
|
+
if (error instanceof ElevenLabsError)
|
|
83
|
+
throw error;
|
|
84
|
+
throw new ElevenLabsError(`ElevenLabs request failed: ${error}`, 500);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async function makeMultipartJsonRequest(path, form, query, signal) {
|
|
88
|
+
const controller = new AbortController();
|
|
89
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
90
|
+
if (signal) {
|
|
91
|
+
attachAbortHandler(signal, controller);
|
|
92
|
+
}
|
|
93
|
+
const qs = query ? `?${new URLSearchParams(query).toString()}` : "";
|
|
94
|
+
try {
|
|
95
|
+
const res = await doFetch(`${baseURL}${path}${qs}`, {
|
|
96
|
+
method: "POST",
|
|
97
|
+
headers: {
|
|
98
|
+
"xi-api-key": opts.apiKey,
|
|
99
|
+
},
|
|
100
|
+
body: form,
|
|
101
|
+
signal: controller.signal,
|
|
102
|
+
});
|
|
103
|
+
clearTimeout(timeoutId);
|
|
104
|
+
if (!res.ok) {
|
|
105
|
+
let resBody = null;
|
|
106
|
+
try {
|
|
107
|
+
resBody = await res.json();
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// ignore parse errors
|
|
111
|
+
}
|
|
112
|
+
throw new ElevenLabsError(formatErrorMessage(res.status, resBody), res.status, resBody, extractErrorCode(resBody));
|
|
113
|
+
}
|
|
114
|
+
return (await res.json());
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
clearTimeout(timeoutId);
|
|
118
|
+
if (error instanceof ElevenLabsError)
|
|
119
|
+
throw error;
|
|
120
|
+
throw new ElevenLabsError(`ElevenLabs request failed: ${error}`, 500);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function appendFormField(form, key, value) {
|
|
124
|
+
if (value === undefined || value === null)
|
|
125
|
+
return;
|
|
126
|
+
if (value instanceof Blob) {
|
|
127
|
+
form.append(key, value);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (typeof value === "string") {
|
|
131
|
+
form.append(key, value);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (typeof value === "boolean" || typeof value === "number") {
|
|
135
|
+
form.append(key, String(value));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
form.append(key, JSON.stringify(value));
|
|
139
|
+
}
|
|
140
|
+
// -- Endpoints -------------------------------------------------------------
|
|
141
|
+
// POST https://api.elevenlabs.io/v1/sound-generation
|
|
142
|
+
// Docs: https://elevenlabs.io/docs/api-reference/text-to-sound-effects/convert
|
|
143
|
+
const soundGeneration = Object.assign(async (req, signal) => {
|
|
144
|
+
const { output_format, ...body } = req;
|
|
145
|
+
const query = output_format ? { output_format } : undefined;
|
|
146
|
+
return makeBinaryRequest("/v1/sound-generation", body, query, signal);
|
|
147
|
+
}, { schema: ElevenLabsSoundGenerationRequestSchema });
|
|
148
|
+
// POST https://api.elevenlabs.io/v1/speech-to-text
|
|
149
|
+
// Docs: https://elevenlabs.io/docs/api-reference/speech-to-text/convert
|
|
150
|
+
const speechToText = Object.assign(async (req, signal) => {
|
|
151
|
+
const { enable_logging, ...body } = req;
|
|
152
|
+
const query = enable_logging !== undefined
|
|
153
|
+
? { enable_logging: String(enable_logging) }
|
|
154
|
+
: undefined;
|
|
155
|
+
const form = new FormData();
|
|
156
|
+
for (const [key, value] of Object.entries(body)) {
|
|
157
|
+
appendFormField(form, key, value);
|
|
158
|
+
}
|
|
159
|
+
return makeMultipartJsonRequest("/v1/speech-to-text", form, query, signal);
|
|
160
|
+
}, { schema: ElevenLabsSpeechToTextRequestSchema });
|
|
161
|
+
const postV1 = { soundGeneration, speechToText };
|
|
162
|
+
const v1 = { soundGeneration, speechToText };
|
|
163
|
+
return attachExamples({
|
|
164
|
+
v1,
|
|
165
|
+
post: { v1: post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CAAC;CAClB;AAED,QAAA,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAS7C,CAAC;AAEF,eAAe,QAAQ,CAAC;AAOxB,wBAAgB,cAAc,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CA6ChD"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Auto-generated by `pnpm run gen:examples` — do not edit by hand.
|
|
2
|
+
// Source: tests/recordings/<provider>_*/<test>_*/recording.har
|
|
3
|
+
//
|
|
4
|
+
// Each entry is the green-path payload for one endpoint, mined from a real
|
|
5
|
+
// integration-test recording. `attachExamples` walks the provider tree and
|
|
6
|
+
// hangs the matching entry off each endpoint function as `.example`.
|
|
7
|
+
const EXAMPLES = {
|
|
8
|
+
"POST v1.soundGeneration": {
|
|
9
|
+
"source": "elevenlabs/sound-generation",
|
|
10
|
+
"payload": {
|
|
11
|
+
"text": "soft ui click",
|
|
12
|
+
"duration_seconds": 0.5,
|
|
13
|
+
"prompt_influence": 0.3
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export default EXAMPLES;
|
|
18
|
+
// Walks each "<METHOD> <dotPath>" key onto the provider's tree. Tries the
|
|
19
|
+
// standard `provider.<method>.<dotPath>` shape first, then a few fallbacks
|
|
20
|
+
// to cover providers with non-standard layouts (fal's `.run.` namespace,
|
|
21
|
+
// kie's sub-providers, `free`'s flat root). Returns the same provider for
|
|
22
|
+
// drop-in use as `return attachExamples({ ... });`.
|
|
23
|
+
export function attachExamples(provider) {
|
|
24
|
+
const root = provider;
|
|
25
|
+
const HTTP_KEYS = new Set(["post", "get", "put", "delete", "patch", "head"]);
|
|
26
|
+
for (const [key, example] of Object.entries(EXAMPLES)) {
|
|
27
|
+
const sp = key.indexOf(" ");
|
|
28
|
+
if (sp < 0)
|
|
29
|
+
continue;
|
|
30
|
+
const method = key.slice(0, sp).toLowerCase();
|
|
31
|
+
const segs = key.slice(sp + 1).split(".");
|
|
32
|
+
const candidates = [
|
|
33
|
+
root[method],
|
|
34
|
+
root[method]?.run,
|
|
35
|
+
root,
|
|
36
|
+
];
|
|
37
|
+
if (segs.length > 1) {
|
|
38
|
+
const sub = root[segs[0]];
|
|
39
|
+
if (sub && typeof sub === "object") {
|
|
40
|
+
const subMethod = sub[method];
|
|
41
|
+
if (subMethod)
|
|
42
|
+
candidates.push({ __nested: subMethod, __segs: segs.slice(1) });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
let attached = false;
|
|
46
|
+
for (const c of candidates) {
|
|
47
|
+
const fn = walkToFn(c, segs);
|
|
48
|
+
if (fn) {
|
|
49
|
+
Object.assign(fn, { example });
|
|
50
|
+
attached = true;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (attached)
|
|
55
|
+
continue;
|
|
56
|
+
for (const k of Object.keys(root)) {
|
|
57
|
+
if (HTTP_KEYS.has(k))
|
|
58
|
+
continue;
|
|
59
|
+
if (!segs.includes(k))
|
|
60
|
+
continue;
|
|
61
|
+
const sub = root[k];
|
|
62
|
+
if (!sub || typeof sub !== "object")
|
|
63
|
+
continue;
|
|
64
|
+
const subMethod = sub[method];
|
|
65
|
+
if (!subMethod)
|
|
66
|
+
continue;
|
|
67
|
+
const fn = walkToFn(subMethod, segs);
|
|
68
|
+
if (fn) {
|
|
69
|
+
Object.assign(fn, { example });
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return provider;
|
|
75
|
+
}
|
|
76
|
+
function walkToFn(start, segs) {
|
|
77
|
+
if (start && typeof start === "object" && "__nested" in start) {
|
|
78
|
+
const wrapper = start;
|
|
79
|
+
return walkToFn(wrapper.__nested, wrapper.__segs);
|
|
80
|
+
}
|
|
81
|
+
let cur = start;
|
|
82
|
+
for (const seg of segs) {
|
|
83
|
+
if (cur === null || cur === undefined)
|
|
84
|
+
return null;
|
|
85
|
+
const t = typeof cur;
|
|
86
|
+
if (t !== "object" && t !== "function")
|
|
87
|
+
return null;
|
|
88
|
+
cur = cur[seg];
|
|
89
|
+
}
|
|
90
|
+
return typeof cur === "function"
|
|
91
|
+
? cur
|
|
92
|
+
: null;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=example.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.js","sourceRoot":"","sources":["../../src/example.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,+DAA+D;AAC/D,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAC3E,qEAAqE;AAOrE,MAAM,QAAQ,GAAoC;IAChD,yBAAyB,EAAE;QACzB,QAAQ,EAAE,6BAA6B;QACvC,SAAS,EAAE;YACT,MAAM,EAAE,eAAe;YACvB,kBAAkB,EAAE,GAAG;YACvB,kBAAkB,EAAE,GAAG;SACxB;KACF;CACF,CAAC;AAEF,eAAe,QAAQ,CAAC;AAExB,0EAA0E;AAC1E,2EAA2E;AAC3E,yEAAyE;AACzE,0EAA0E;AAC1E,oDAAoD;AACpD,MAAM,UAAU,cAAc,CAAI,QAAW;IAC3C,MAAM,IAAI,GAAG,QAAmC,CAAC;IACjD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7E,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtD,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,EAAE,GAAG,CAAC;YAAE,SAAS;QACrB,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAC9C,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC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absOptions, ElevenLabsSoundGenerationRequest, ElevenLabsSoundGenerationMethod, ElevenLabsSpeechToTextRequest, ElevenLabsSpeechToTextResponse, ElevenLabsSpeechToTextMethod, ElevenLabsTranscript, ElevenLabsTranscriptWord, ElevenLabsTranscriptWordType, ElevenLabsTranscriptCharacter, ElevenLabsTranscriptAdditionalFormat, ElevenLabsTranscriptEntity, ElevenLabsMultichannelTranscript, ElevenLabsWebhookAcknowledgement, ElevenLabsV1Namespace, ElevenLabsPostNamespace, ElevenLabsProvider, } from "./types";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,YAAY,EACV,iBAAiB,EACjB,gCAAgC,EAChC,+BAA+B,EAC/B,6BAA6B,EAC7B,8BAA8B,EAC9B,4BAA4B,EAC5B,oBAAoB,EACpB,wBAAwB,EACxB,4BAA4B,EAC5B,6BAA6B,EAC7B,oCAAoC,EACpC,0BAA0B,EAC1B,gCAAgC,EAChC,gCAAgC,EAChC,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { ElevenLabsSoundGenerationRequest, ElevenLabsSpeechToTextRequest } from "./zod";
|
|
3
|
+
export type { ElevenLabsOptions, ElevenLabsSoundGenerationRequest, ElevenLabsSpeechToTextRequest, } from "./zod";
|
|
4
|
+
export declare class ElevenLabsError extends Error {
|
|
5
|
+
readonly status: number;
|
|
6
|
+
readonly body: unknown;
|
|
7
|
+
readonly code?: string;
|
|
8
|
+
constructor(message: string, status: number, body?: unknown, code?: string);
|
|
9
|
+
}
|
|
10
|
+
export type ElevenLabsTranscriptWordType = "word" | "spacing" | "audio_event";
|
|
11
|
+
export interface ElevenLabsTranscriptCharacter {
|
|
12
|
+
text: string;
|
|
13
|
+
start: number;
|
|
14
|
+
end: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ElevenLabsTranscriptWord {
|
|
17
|
+
text: string;
|
|
18
|
+
start: number;
|
|
19
|
+
end: number;
|
|
20
|
+
type: ElevenLabsTranscriptWordType;
|
|
21
|
+
speaker_id: string | null;
|
|
22
|
+
logprob?: number;
|
|
23
|
+
characters?: ElevenLabsTranscriptCharacter[];
|
|
24
|
+
}
|
|
25
|
+
export interface ElevenLabsTranscriptAdditionalFormat {
|
|
26
|
+
requested_format: string;
|
|
27
|
+
file_extension: string;
|
|
28
|
+
content_type: string;
|
|
29
|
+
is_base64_encoded: boolean;
|
|
30
|
+
content: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ElevenLabsTranscriptEntity {
|
|
33
|
+
text: string;
|
|
34
|
+
entity_type: string;
|
|
35
|
+
start_char: number;
|
|
36
|
+
end_char: number;
|
|
37
|
+
}
|
|
38
|
+
export interface ElevenLabsTranscript {
|
|
39
|
+
language_code: string;
|
|
40
|
+
language_probability: number;
|
|
41
|
+
text: string;
|
|
42
|
+
words: ElevenLabsTranscriptWord[];
|
|
43
|
+
channel_index: number;
|
|
44
|
+
additional_formats?: ElevenLabsTranscriptAdditionalFormat[];
|
|
45
|
+
transcription_id: string | null;
|
|
46
|
+
entities?: ElevenLabsTranscriptEntity[];
|
|
47
|
+
audio_duration_secs: number;
|
|
48
|
+
}
|
|
49
|
+
export interface ElevenLabsMultichannelTranscript {
|
|
50
|
+
transcripts: ElevenLabsTranscript[];
|
|
51
|
+
transcription_id: string | null;
|
|
52
|
+
audio_duration_secs: number;
|
|
53
|
+
}
|
|
54
|
+
export interface ElevenLabsWebhookAcknowledgement {
|
|
55
|
+
message: string;
|
|
56
|
+
request_id: string;
|
|
57
|
+
transcription_id: string | null;
|
|
58
|
+
}
|
|
59
|
+
export type ElevenLabsSpeechToTextResponse = ElevenLabsTranscript | ElevenLabsMultichannelTranscript | ElevenLabsWebhookAcknowledgement;
|
|
60
|
+
export interface ElevenLabsSoundGenerationMethod {
|
|
61
|
+
(req: ElevenLabsSoundGenerationRequest, signal?: AbortSignal): Promise<ArrayBuffer>;
|
|
62
|
+
schema: z.ZodType<ElevenLabsSoundGenerationRequest>;
|
|
63
|
+
}
|
|
64
|
+
export interface ElevenLabsSpeechToTextMethod {
|
|
65
|
+
(req: ElevenLabsSpeechToTextRequest, signal?: AbortSignal): Promise<ElevenLabsSpeechToTextResponse>;
|
|
66
|
+
schema: z.ZodType<ElevenLabsSpeechToTextRequest>;
|
|
67
|
+
}
|
|
68
|
+
export interface ElevenLabsV1Namespace {
|
|
69
|
+
soundGeneration: ElevenLabsSoundGenerationMethod;
|
|
70
|
+
speechToText: ElevenLabsSpeechToTextMethod;
|
|
71
|
+
}
|
|
72
|
+
export interface ElevenLabsPostNamespace {
|
|
73
|
+
v1: ElevenLabsV1Namespace;
|
|
74
|
+
}
|
|
75
|
+
export interface ElevenLabsProvider {
|
|
76
|
+
v1: ElevenLabsV1Namespace;
|
|
77
|
+
post: ElevenLabsPostNamespace;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EACV,gCAAgC,EAChC,6BAA6B,EAC9B,MAAM,OAAO,CAAC;AAEf,YAAY,EACV,i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AAE,EAAE,qBAAqB,CAAC;IAC1B,IAAI,EAAE,uBAAuB,CAAC;CAC/B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// -- Error -------------------------------------------------------------------
|
|
2
|
+
export class ElevenLabsError extends Error {
|
|
3
|
+
status;
|
|
4
|
+
body;
|
|
5
|
+
code;
|
|
6
|
+
constructor(message, status, body, code) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "ElevenLabsError";
|
|
9
|
+
this.status = status;
|
|
10
|
+
this.body = body ?? null;
|
|
11
|
+
this.code = code;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAYA,+EAA+E;AAE/E,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,MAAM,CAAS;IACf,IAAI,CAAU;IACd,IAAI,CAAU;IAEvB,YAAY,OAAe,EAAE,MAAc,EAAE,IAAc,EAAE,IAAa;QACxE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ElevenLabsOptionsSchema: z.ZodObject<{
|
|
3
|
+
apiKey: z.ZodString;
|
|
4
|
+
baseURL: z.ZodOptional<z.ZodString>;
|
|
5
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
fetch: z.ZodOptional<z.ZodType<typeof fetch, z.ZodTypeDef, typeof fetch>>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
apiKey: string;
|
|
9
|
+
baseURL?: string | undefined;
|
|
10
|
+
timeout?: number | undefined;
|
|
11
|
+
fetch?: typeof fetch | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
apiKey: string;
|
|
14
|
+
baseURL?: string | undefined;
|
|
15
|
+
timeout?: number | undefined;
|
|
16
|
+
fetch?: typeof fetch | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
export type ElevenLabsOptions = z.infer<typeof ElevenLabsOptionsSchema>;
|
|
19
|
+
export declare const ElevenLabsSoundGenerationRequestSchema: z.ZodObject<{
|
|
20
|
+
text: z.ZodString;
|
|
21
|
+
model_id: z.ZodOptional<z.ZodString>;
|
|
22
|
+
duration_seconds: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
23
|
+
prompt_influence: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
24
|
+
loop: z.ZodOptional<z.ZodBoolean>;
|
|
25
|
+
output_format: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
text: string;
|
|
28
|
+
model_id?: string | undefined;
|
|
29
|
+
duration_seconds?: number | null | undefined;
|
|
30
|
+
prompt_influence?: number | null | undefined;
|
|
31
|
+
loop?: boolean | undefined;
|
|
32
|
+
output_format?: string | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
text: string;
|
|
35
|
+
model_id?: string | undefined;
|
|
36
|
+
duration_seconds?: number | null | undefined;
|
|
37
|
+
prompt_influence?: number | null | undefined;
|
|
38
|
+
loop?: boolean | undefined;
|
|
39
|
+
output_format?: string | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
export type ElevenLabsSoundGenerationRequest = z.infer<typeof ElevenLabsSoundGenerationRequestSchema>;
|
|
42
|
+
export declare const ElevenLabsSpeechToTextRequestSchema: z.ZodObject<{
|
|
43
|
+
model_id: z.ZodEnum<["scribe_v1", "scribe_v2"]>;
|
|
44
|
+
file: z.ZodOptional<z.ZodType<Blob, z.ZodTypeDef, Blob>>;
|
|
45
|
+
cloud_storage_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
46
|
+
source_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
47
|
+
language_code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
tag_audio_events: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
+
num_speakers: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
50
|
+
timestamps_granularity: z.ZodOptional<z.ZodEnum<["none", "word", "character"]>>;
|
|
51
|
+
diarize: z.ZodOptional<z.ZodBoolean>;
|
|
52
|
+
diarization_threshold: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
53
|
+
additional_formats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
|
|
54
|
+
file_format: z.ZodOptional<z.ZodEnum<["pcm_s16le_16", "other"]>>;
|
|
55
|
+
webhook: z.ZodOptional<z.ZodBoolean>;
|
|
56
|
+
webhook_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
57
|
+
webhook_metadata: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>>;
|
|
58
|
+
temperature: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
59
|
+
seed: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
60
|
+
use_multi_channel: z.ZodOptional<z.ZodBoolean>;
|
|
61
|
+
entity_detection: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>>;
|
|
62
|
+
entity_redaction: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>>;
|
|
63
|
+
entity_redaction_mode: z.ZodOptional<z.ZodEnum<["redacted", "entity_type", "enumerated_entity_type"]>>;
|
|
64
|
+
no_verbatim: z.ZodOptional<z.ZodBoolean>;
|
|
65
|
+
detect_speaker_roles: z.ZodOptional<z.ZodBoolean>;
|
|
66
|
+
keyterms: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
67
|
+
enable_logging: z.ZodOptional<z.ZodBoolean>;
|
|
68
|
+
}, "strip", z.ZodTypeAny, {
|
|
69
|
+
model_id: "scribe_v1" | "scribe_v2";
|
|
70
|
+
file?: Blob | undefined;
|
|
71
|
+
cloud_storage_url?: string | null | undefined;
|
|
72
|
+
source_url?: string | null | undefined;
|
|
73
|
+
language_code?: string | null | undefined;
|
|
74
|
+
tag_audio_events?: boolean | undefined;
|
|
75
|
+
num_speakers?: number | null | undefined;
|
|
76
|
+
timestamps_granularity?: "none" | "word" | "character" | undefined;
|
|
77
|
+
diarize?: boolean | undefined;
|
|
78
|
+
diarization_threshold?: number | null | undefined;
|
|
79
|
+
additional_formats?: Record<string, unknown>[] | undefined;
|
|
80
|
+
file_format?: "pcm_s16le_16" | "other" | undefined;
|
|
81
|
+
webhook?: boolean | undefined;
|
|
82
|
+
webhook_id?: string | null | undefined;
|
|
83
|
+
webhook_metadata?: string | Record<string, unknown> | null | undefined;
|
|
84
|
+
temperature?: number | null | undefined;
|
|
85
|
+
seed?: number | null | undefined;
|
|
86
|
+
use_multi_channel?: boolean | undefined;
|
|
87
|
+
entity_detection?: string | string[] | null | undefined;
|
|
88
|
+
entity_redaction?: string | string[] | null | undefined;
|
|
89
|
+
entity_redaction_mode?: "redacted" | "entity_type" | "enumerated_entity_type" | undefined;
|
|
90
|
+
no_verbatim?: boolean | undefined;
|
|
91
|
+
detect_speaker_roles?: boolean | undefined;
|
|
92
|
+
keyterms?: string[] | undefined;
|
|
93
|
+
enable_logging?: boolean | undefined;
|
|
94
|
+
}, {
|
|
95
|
+
model_id: "scribe_v1" | "scribe_v2";
|
|
96
|
+
file?: Blob | undefined;
|
|
97
|
+
cloud_storage_url?: string | null | undefined;
|
|
98
|
+
source_url?: string | null | undefined;
|
|
99
|
+
language_code?: string | null | undefined;
|
|
100
|
+
tag_audio_events?: boolean | undefined;
|
|
101
|
+
num_speakers?: number | null | undefined;
|
|
102
|
+
timestamps_granularity?: "none" | "word" | "character" | undefined;
|
|
103
|
+
diarize?: boolean | undefined;
|
|
104
|
+
diarization_threshold?: number | null | undefined;
|
|
105
|
+
additional_formats?: Record<string, unknown>[] | undefined;
|
|
106
|
+
file_format?: "pcm_s16le_16" | "other" | undefined;
|
|
107
|
+
webhook?: boolean | undefined;
|
|
108
|
+
webhook_id?: string | null | undefined;
|
|
109
|
+
webhook_metadata?: string | Record<string, unknown> | null | undefined;
|
|
110
|
+
temperature?: number | null | undefined;
|
|
111
|
+
seed?: number | null | undefined;
|
|
112
|
+
use_multi_channel?: boolean | undefined;
|
|
113
|
+
entity_detection?: string | string[] | null | undefined;
|
|
114
|
+
entity_redaction?: string | string[] | null | undefined;
|
|
115
|
+
entity_redaction_mode?: "redacted" | "entity_type" | "enumerated_entity_type" | undefined;
|
|
116
|
+
no_verbatim?: boolean | undefined;
|
|
117
|
+
detect_speaker_roles?: boolean | undefined;
|
|
118
|
+
keyterms?: string[] | undefined;
|
|
119
|
+
enable_logging?: boolean | undefined;
|
|
120
|
+
}>;
|
|
121
|
+
export type ElevenLabsSpeechToTextRequest = z.infer<typeof ElevenLabsSpeechToTextRequestSchema>;
|
|
122
|
+
//# sourceMappingURL=zod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../src/zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;EAKlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AASxE,eAAO,MAAM,sCAAsC;;;;;;;;;;;;;;;;;;;;;EAOjD,CAAC;AAEH,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CACpD,OAAO,sCAAsC,CAC9C,CAAC;AASF,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqC9C,CAAC;AAEH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CACjD,OAAO,mCAAmC,CAC3C,CAAC"}
|
package/dist/src/zod.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// ---------------------------------------------------------------------------
|
|
3
|
+
// Provider options
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
export const ElevenLabsOptionsSchema = z.object({
|
|
6
|
+
apiKey: z.string(),
|
|
7
|
+
baseURL: z.string().optional(),
|
|
8
|
+
timeout: z.number().optional(),
|
|
9
|
+
fetch: z.custom().optional(),
|
|
10
|
+
});
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// POST /v1/sound-generation
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// `output_format` is a query-string parameter, not a body field. We carry it on
|
|
15
|
+
// the same request object for ergonomics; the factory strips it out and moves
|
|
16
|
+
// it to the URL query before serialising the body.
|
|
17
|
+
export const ElevenLabsSoundGenerationRequestSchema = z.object({
|
|
18
|
+
text: z.string().min(1),
|
|
19
|
+
model_id: z.string().optional(),
|
|
20
|
+
duration_seconds: z.number().min(0.5).max(30).nullable().optional(),
|
|
21
|
+
prompt_influence: z.number().min(0).max(1).nullable().optional(),
|
|
22
|
+
loop: z.boolean().optional(),
|
|
23
|
+
output_format: z.string().optional(),
|
|
24
|
+
});
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
// POST /v1/speech-to-text
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// Multipart form: exactly one of `file` or `cloud_storage_url` is required.
|
|
29
|
+
// `enable_logging` is a query-string parameter; the factory strips it from the
|
|
30
|
+
// body and moves it to the URL.
|
|
31
|
+
export const ElevenLabsSpeechToTextRequestSchema = z.object({
|
|
32
|
+
model_id: z.enum(["scribe_v1", "scribe_v2"]),
|
|
33
|
+
file: z.custom().optional(),
|
|
34
|
+
cloud_storage_url: z.string().url().nullable().optional(),
|
|
35
|
+
source_url: z.string().url().nullable().optional(),
|
|
36
|
+
language_code: z.string().nullable().optional(),
|
|
37
|
+
tag_audio_events: z.boolean().optional(),
|
|
38
|
+
num_speakers: z.number().int().min(1).max(32).nullable().optional(),
|
|
39
|
+
timestamps_granularity: z.enum(["none", "word", "character"]).optional(),
|
|
40
|
+
diarize: z.boolean().optional(),
|
|
41
|
+
diarization_threshold: z.number().min(0).max(2).nullable().optional(),
|
|
42
|
+
additional_formats: z.array(z.record(z.unknown())).optional(),
|
|
43
|
+
file_format: z.enum(["pcm_s16le_16", "other"]).optional(),
|
|
44
|
+
webhook: z.boolean().optional(),
|
|
45
|
+
webhook_id: z.string().nullable().optional(),
|
|
46
|
+
webhook_metadata: z
|
|
47
|
+
.union([z.string(), z.record(z.unknown())])
|
|
48
|
+
.nullable()
|
|
49
|
+
.optional(),
|
|
50
|
+
temperature: z.number().min(0).max(2).nullable().optional(),
|
|
51
|
+
seed: z.number().int().min(0).max(2147483647).nullable().optional(),
|
|
52
|
+
use_multi_channel: z.boolean().optional(),
|
|
53
|
+
entity_detection: z
|
|
54
|
+
.union([z.string(), z.array(z.string())])
|
|
55
|
+
.nullable()
|
|
56
|
+
.optional(),
|
|
57
|
+
entity_redaction: z
|
|
58
|
+
.union([z.string(), z.array(z.string())])
|
|
59
|
+
.nullable()
|
|
60
|
+
.optional(),
|
|
61
|
+
entity_redaction_mode: z
|
|
62
|
+
.enum(["redacted", "entity_type", "enumerated_entity_type"])
|
|
63
|
+
.optional(),
|
|
64
|
+
no_verbatim: z.boolean().optional(),
|
|
65
|
+
detect_speaker_roles: z.boolean().optional(),
|
|
66
|
+
keyterms: z.array(z.string().max(50)).max(1000).optional(),
|
|
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EAAE;IACb,qBAAqB,EAAE,CAAC;SACrB,IAAI,CAAC,CAAC,UAAU,EAAE,aAAa,EAAE,wBAAwB,CAAC,CAAC;SAC3D,QAAQ,EAAE;IACb,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACnC,oBAAoB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC5C,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;IAC1D,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CACvC,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@apicity/elevenlabs",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"description": "ElevenLabs provider for sound effect generation, text-to-speech, and audio APIs.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/justintanner/apicity.git",
|
|
9
|
+
"directory": "provider/elevenlabs"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "dist/src/index.js",
|
|
16
|
+
"types": "dist/src/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"import": "./dist/src/index.js",
|
|
20
|
+
"types": "./dist/src/index.d.ts"
|
|
21
|
+
},
|
|
22
|
+
"./zod": {
|
|
23
|
+
"import": "./dist/src/zod.js",
|
|
24
|
+
"types": "./dist/src/zod.d.ts"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"zod": "^3.24.0"
|
|
29
|
+
},
|
|
30
|
+
"peerDependenciesMeta": {
|
|
31
|
+
"zod": {
|
|
32
|
+
"optional": true
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"README.md",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"sideEffects": false,
|
|
41
|
+
"keywords": [
|
|
42
|
+
"ai",
|
|
43
|
+
"elevenlabs",
|
|
44
|
+
"sound-effects",
|
|
45
|
+
"sfx",
|
|
46
|
+
"text-to-speech",
|
|
47
|
+
"tts",
|
|
48
|
+
"audio",
|
|
49
|
+
"apicity"
|
|
50
|
+
],
|
|
51
|
+
"author": "Justin Tanner",
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=18.0.0"
|
|
54
|
+
},
|
|
55
|
+
"homepage": "https://github.com/justintanner/apicity#readme",
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "https://github.com/justintanner/apicity/issues"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "tsc -p tsconfig.json && node scripts/dist.mjs"
|
|
61
|
+
}
|
|
62
|
+
}
|