@ai-sdk/elevenlabs 3.0.0-beta.2 → 3.0.0-beta.21
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/CHANGELOG.md +163 -4
- package/README.md +2 -0
- package/dist/index.d.ts +18 -9
- package/dist/index.js +124 -112
- package/dist/index.js.map +1 -1
- package/package.json +7 -9
- package/src/elevenlabs-config.ts +1 -1
- package/src/elevenlabs-provider.ts +7 -7
- package/src/elevenlabs-speech-model.ts +25 -8
- package/src/elevenlabs-transcription-model.ts +25 -8
- package/dist/index.d.mts +0 -122
- package/dist/index.mjs +0 -423
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,164 @@
|
|
|
1
1
|
# @ai-sdk/elevenlabs
|
|
2
2
|
|
|
3
|
+
## 3.0.0-beta.21
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b3976a2: Add workflow serialization support to all provider models.
|
|
8
|
+
|
|
9
|
+
**`@ai-sdk/provider-utils`:** New `serializeModel()` helper that extracts only serializable properties from a model instance, filtering out functions and objects containing functions. Third-party provider authors can use this to add workflow support to their own models.
|
|
10
|
+
|
|
11
|
+
**All providers:** `headers` is now optional in provider config types. This is non-breaking — existing code that passes `headers` continues to work. Custom provider implementations that construct model configs manually can now omit `headers`, which is useful when models are deserialized from a workflow step boundary where auth is provided separately.
|
|
12
|
+
|
|
13
|
+
All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [b3976a2]
|
|
16
|
+
- Updated dependencies [ff5eba1]
|
|
17
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
18
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
19
|
+
|
|
20
|
+
## 3.0.0-beta.20
|
|
21
|
+
|
|
22
|
+
### Major Changes
|
|
23
|
+
|
|
24
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [ef992f8]
|
|
29
|
+
- @ai-sdk/provider@4.0.0-beta.11
|
|
30
|
+
- @ai-sdk/provider-utils@5.0.0-beta.19
|
|
31
|
+
|
|
32
|
+
## 3.0.0-beta.19
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [90e2d8a]
|
|
37
|
+
- @ai-sdk/provider-utils@5.0.0-beta.18
|
|
38
|
+
|
|
39
|
+
## 3.0.0-beta.18
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Updated dependencies [3ae1786]
|
|
44
|
+
- @ai-sdk/provider-utils@5.0.0-beta.17
|
|
45
|
+
|
|
46
|
+
## 3.0.0-beta.17
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- Updated dependencies [176466a]
|
|
51
|
+
- @ai-sdk/provider@4.0.0-beta.10
|
|
52
|
+
- @ai-sdk/provider-utils@5.0.0-beta.16
|
|
53
|
+
|
|
54
|
+
## 3.0.0-beta.16
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- Updated dependencies [e311194]
|
|
59
|
+
- @ai-sdk/provider@4.0.0-beta.9
|
|
60
|
+
- @ai-sdk/provider-utils@5.0.0-beta.15
|
|
61
|
+
|
|
62
|
+
## 3.0.0-beta.15
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- Updated dependencies [34bd95d]
|
|
67
|
+
- Updated dependencies [008271d]
|
|
68
|
+
- @ai-sdk/provider@4.0.0-beta.8
|
|
69
|
+
- @ai-sdk/provider-utils@5.0.0-beta.14
|
|
70
|
+
|
|
71
|
+
## 3.0.0-beta.14
|
|
72
|
+
|
|
73
|
+
### Patch Changes
|
|
74
|
+
|
|
75
|
+
- Updated dependencies [b0c2869]
|
|
76
|
+
- Updated dependencies [7e26e81]
|
|
77
|
+
- @ai-sdk/provider-utils@5.0.0-beta.13
|
|
78
|
+
|
|
79
|
+
## 3.0.0-beta.13
|
|
80
|
+
|
|
81
|
+
### Patch Changes
|
|
82
|
+
|
|
83
|
+
- Updated dependencies [46d1149]
|
|
84
|
+
- @ai-sdk/provider-utils@5.0.0-beta.12
|
|
85
|
+
|
|
86
|
+
## 3.0.0-beta.12
|
|
87
|
+
|
|
88
|
+
### Patch Changes
|
|
89
|
+
|
|
90
|
+
- Updated dependencies [6fd51c0]
|
|
91
|
+
- @ai-sdk/provider-utils@5.0.0-beta.11
|
|
92
|
+
- @ai-sdk/provider@4.0.0-beta.7
|
|
93
|
+
|
|
94
|
+
## 3.0.0-beta.11
|
|
95
|
+
|
|
96
|
+
### Patch Changes
|
|
97
|
+
|
|
98
|
+
- Updated dependencies [c29a26f]
|
|
99
|
+
- @ai-sdk/provider-utils@5.0.0-beta.10
|
|
100
|
+
- @ai-sdk/provider@4.0.0-beta.6
|
|
101
|
+
|
|
102
|
+
## 3.0.0-beta.10
|
|
103
|
+
|
|
104
|
+
### Patch Changes
|
|
105
|
+
|
|
106
|
+
- 38fc777: Add AI Gateway hint to provider READMEs
|
|
107
|
+
|
|
108
|
+
## 3.0.0-beta.9
|
|
109
|
+
|
|
110
|
+
### Patch Changes
|
|
111
|
+
|
|
112
|
+
- Updated dependencies [2e17091]
|
|
113
|
+
- @ai-sdk/provider-utils@5.0.0-beta.9
|
|
114
|
+
|
|
115
|
+
## 3.0.0-beta.8
|
|
116
|
+
|
|
117
|
+
### Patch Changes
|
|
118
|
+
|
|
119
|
+
- Updated dependencies [986c6fd]
|
|
120
|
+
- Updated dependencies [493295c]
|
|
121
|
+
- @ai-sdk/provider-utils@5.0.0-beta.8
|
|
122
|
+
|
|
123
|
+
## 3.0.0-beta.7
|
|
124
|
+
|
|
125
|
+
### Patch Changes
|
|
126
|
+
|
|
127
|
+
- Updated dependencies [1f509d4]
|
|
128
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
129
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
130
|
+
|
|
131
|
+
## 3.0.0-beta.6
|
|
132
|
+
|
|
133
|
+
### Patch Changes
|
|
134
|
+
|
|
135
|
+
- Updated dependencies [3887c70]
|
|
136
|
+
- @ai-sdk/provider-utils@5.0.0-beta.6
|
|
137
|
+
- @ai-sdk/provider@4.0.0-beta.4
|
|
138
|
+
|
|
139
|
+
## 3.0.0-beta.5
|
|
140
|
+
|
|
141
|
+
### Patch Changes
|
|
142
|
+
|
|
143
|
+
- Updated dependencies [776b617]
|
|
144
|
+
- @ai-sdk/provider-utils@5.0.0-beta.5
|
|
145
|
+
- @ai-sdk/provider@4.0.0-beta.3
|
|
146
|
+
|
|
147
|
+
## 3.0.0-beta.4
|
|
148
|
+
|
|
149
|
+
### Patch Changes
|
|
150
|
+
|
|
151
|
+
- Updated dependencies [61753c3]
|
|
152
|
+
- @ai-sdk/provider-utils@5.0.0-beta.4
|
|
153
|
+
|
|
154
|
+
## 3.0.0-beta.3
|
|
155
|
+
|
|
156
|
+
### Patch Changes
|
|
157
|
+
|
|
158
|
+
- Updated dependencies [f7d4f01]
|
|
159
|
+
- @ai-sdk/provider-utils@5.0.0-beta.3
|
|
160
|
+
- @ai-sdk/provider@4.0.0-beta.2
|
|
161
|
+
|
|
3
162
|
## 3.0.0-beta.2
|
|
4
163
|
|
|
5
164
|
### Patch Changes
|
|
@@ -219,13 +378,13 @@
|
|
|
219
378
|
Before
|
|
220
379
|
|
|
221
380
|
```ts
|
|
222
|
-
model.textEmbeddingModel(
|
|
381
|
+
model.textEmbeddingModel("my-model-id");
|
|
223
382
|
```
|
|
224
383
|
|
|
225
384
|
After
|
|
226
385
|
|
|
227
386
|
```ts
|
|
228
|
-
model.embeddingModel(
|
|
387
|
+
model.embeddingModel("my-model-id");
|
|
229
388
|
```
|
|
230
389
|
|
|
231
390
|
- 95f65c2: chore: use import \* from zod/v4
|
|
@@ -425,13 +584,13 @@
|
|
|
425
584
|
Before
|
|
426
585
|
|
|
427
586
|
```ts
|
|
428
|
-
model.textEmbeddingModel(
|
|
587
|
+
model.textEmbeddingModel("my-model-id");
|
|
429
588
|
```
|
|
430
589
|
|
|
431
590
|
After
|
|
432
591
|
|
|
433
592
|
```ts
|
|
434
|
-
model.embeddingModel(
|
|
593
|
+
model.embeddingModel("my-model-id");
|
|
435
594
|
```
|
|
436
595
|
|
|
437
596
|
- Updated dependencies [8d9e8ad]
|
package/README.md
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
The **[ElevenLabs provider](https://ai-sdk.dev/providers/ai-sdk-providers/elevenlabs)** for the [AI SDK](https://ai-sdk.dev/docs)
|
|
4
4
|
contains language model support for the ElevenLabs chat and completion APIs and embedding model support for the ElevenLabs embeddings API.
|
|
5
5
|
|
|
6
|
+
> **Deploying to Vercel?** With Vercel's AI Gateway you can access ElevenLabs (and hundreds of models from other providers) — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
|
|
7
|
+
|
|
6
8
|
## Setup
|
|
7
9
|
|
|
8
10
|
The ElevenLabs provider is available in the `@ai-sdk/elevenlabs` module. You can install it with
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
2
|
+
import { TranscriptionModelV4, ProviderV4, SpeechModelV4 } from '@ai-sdk/provider';
|
|
3
|
+
import { FetchFunction, WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@ai-sdk/provider-utils';
|
|
3
4
|
import { z } from 'zod/v4';
|
|
4
5
|
|
|
5
6
|
type ElevenLabsConfig = {
|
|
@@ -8,7 +9,7 @@ type ElevenLabsConfig = {
|
|
|
8
9
|
modelId: string;
|
|
9
10
|
path: string;
|
|
10
11
|
}) => string;
|
|
11
|
-
headers
|
|
12
|
+
headers?: () => Record<string, string | undefined>;
|
|
12
13
|
fetch?: FetchFunction;
|
|
13
14
|
generateId?: () => string;
|
|
14
15
|
};
|
|
@@ -36,31 +37,39 @@ interface ElevenLabsTranscriptionModelConfig extends ElevenLabsConfig {
|
|
|
36
37
|
currentDate?: () => Date;
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
|
-
declare class ElevenLabsTranscriptionModel implements
|
|
40
|
+
declare class ElevenLabsTranscriptionModel implements TranscriptionModelV4 {
|
|
40
41
|
readonly modelId: ElevenLabsTranscriptionModelId;
|
|
41
42
|
private readonly config;
|
|
42
|
-
readonly specificationVersion = "
|
|
43
|
+
readonly specificationVersion = "v4";
|
|
43
44
|
get provider(): string;
|
|
45
|
+
static [WORKFLOW_SERIALIZE](model: ElevenLabsTranscriptionModel): {
|
|
46
|
+
modelId: string;
|
|
47
|
+
config: _ai_sdk_provider.JSONObject;
|
|
48
|
+
};
|
|
49
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
50
|
+
modelId: ElevenLabsTranscriptionModelId;
|
|
51
|
+
config: ElevenLabsTranscriptionModelConfig;
|
|
52
|
+
}): ElevenLabsTranscriptionModel;
|
|
44
53
|
constructor(modelId: ElevenLabsTranscriptionModelId, config: ElevenLabsTranscriptionModelConfig);
|
|
45
54
|
private getArgs;
|
|
46
|
-
doGenerate(options: Parameters<
|
|
55
|
+
doGenerate(options: Parameters<TranscriptionModelV4['doGenerate']>[0]): Promise<Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>>;
|
|
47
56
|
}
|
|
48
57
|
|
|
49
58
|
type ElevenLabsSpeechModelId = 'eleven_v3' | 'eleven_multilingual_v2' | 'eleven_flash_v2_5' | 'eleven_flash_v2' | 'eleven_turbo_v2_5' | 'eleven_turbo_v2' | 'eleven_monolingual_v1' | 'eleven_multilingual_v1' | (string & {});
|
|
50
59
|
type ElevenLabsSpeechVoiceId = string;
|
|
51
60
|
|
|
52
|
-
interface ElevenLabsProvider extends
|
|
61
|
+
interface ElevenLabsProvider extends ProviderV4 {
|
|
53
62
|
(modelId: 'scribe_v1', settings?: {}): {
|
|
54
63
|
transcription: ElevenLabsTranscriptionModel;
|
|
55
64
|
};
|
|
56
65
|
/**
|
|
57
66
|
* Creates a model for transcription.
|
|
58
67
|
*/
|
|
59
|
-
transcription(modelId: ElevenLabsTranscriptionModelId):
|
|
68
|
+
transcription(modelId: ElevenLabsTranscriptionModelId): TranscriptionModelV4;
|
|
60
69
|
/**
|
|
61
70
|
* Creates a model for speech generation.
|
|
62
71
|
*/
|
|
63
|
-
speech(modelId: ElevenLabsSpeechModelId):
|
|
72
|
+
speech(modelId: ElevenLabsSpeechModelId): SpeechModelV4;
|
|
64
73
|
/**
|
|
65
74
|
* @deprecated Use `embeddingModel` instead.
|
|
66
75
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,71 +1,67 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
VERSION: () => VERSION,
|
|
24
|
-
createElevenLabs: () => createElevenLabs,
|
|
25
|
-
elevenlabs: () => elevenlabs
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
|
|
29
1
|
// src/elevenlabs-provider.ts
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
import {
|
|
3
|
+
NoSuchModelError
|
|
4
|
+
} from "@ai-sdk/provider";
|
|
5
|
+
import {
|
|
6
|
+
loadApiKey,
|
|
7
|
+
withUserAgentSuffix
|
|
8
|
+
} from "@ai-sdk/provider-utils";
|
|
32
9
|
|
|
33
10
|
// src/elevenlabs-transcription-model.ts
|
|
34
|
-
|
|
35
|
-
|
|
11
|
+
import {
|
|
12
|
+
combineHeaders,
|
|
13
|
+
convertBase64ToUint8Array,
|
|
14
|
+
createJsonResponseHandler,
|
|
15
|
+
mediaTypeToExtension,
|
|
16
|
+
parseProviderOptions,
|
|
17
|
+
postFormDataToApi,
|
|
18
|
+
serializeModelOptions,
|
|
19
|
+
WORKFLOW_SERIALIZE,
|
|
20
|
+
WORKFLOW_DESERIALIZE
|
|
21
|
+
} from "@ai-sdk/provider-utils";
|
|
22
|
+
import { z as z2 } from "zod/v4";
|
|
36
23
|
|
|
37
24
|
// src/elevenlabs-error.ts
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var elevenlabsErrorDataSchema =
|
|
41
|
-
error:
|
|
42
|
-
message:
|
|
43
|
-
code:
|
|
25
|
+
import { z } from "zod/v4";
|
|
26
|
+
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
27
|
+
var elevenlabsErrorDataSchema = z.object({
|
|
28
|
+
error: z.object({
|
|
29
|
+
message: z.string(),
|
|
30
|
+
code: z.number()
|
|
44
31
|
})
|
|
45
32
|
});
|
|
46
|
-
var elevenlabsFailedResponseHandler =
|
|
33
|
+
var elevenlabsFailedResponseHandler = createJsonErrorResponseHandler({
|
|
47
34
|
errorSchema: elevenlabsErrorDataSchema,
|
|
48
35
|
errorToMessage: (data) => data.error.message
|
|
49
36
|
});
|
|
50
37
|
|
|
51
38
|
// src/elevenlabs-transcription-model.ts
|
|
52
|
-
var elevenLabsTranscriptionModelOptionsSchema =
|
|
53
|
-
languageCode:
|
|
54
|
-
tagAudioEvents:
|
|
55
|
-
numSpeakers:
|
|
56
|
-
timestampsGranularity:
|
|
57
|
-
diarize:
|
|
58
|
-
fileFormat:
|
|
39
|
+
var elevenLabsTranscriptionModelOptionsSchema = z2.object({
|
|
40
|
+
languageCode: z2.string().nullish(),
|
|
41
|
+
tagAudioEvents: z2.boolean().nullish().default(true),
|
|
42
|
+
numSpeakers: z2.number().int().min(1).max(32).nullish(),
|
|
43
|
+
timestampsGranularity: z2.enum(["none", "word", "character"]).nullish().default("word"),
|
|
44
|
+
diarize: z2.boolean().nullish().default(false),
|
|
45
|
+
fileFormat: z2.enum(["pcm_s16le_16", "other"]).nullish().default("other")
|
|
59
46
|
});
|
|
60
|
-
var ElevenLabsTranscriptionModel = class {
|
|
47
|
+
var ElevenLabsTranscriptionModel = class _ElevenLabsTranscriptionModel {
|
|
61
48
|
constructor(modelId, config) {
|
|
62
49
|
this.modelId = modelId;
|
|
63
50
|
this.config = config;
|
|
64
|
-
this.specificationVersion = "
|
|
51
|
+
this.specificationVersion = "v4";
|
|
65
52
|
}
|
|
66
53
|
get provider() {
|
|
67
54
|
return this.config.provider;
|
|
68
55
|
}
|
|
56
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
57
|
+
return serializeModelOptions({
|
|
58
|
+
modelId: model.modelId,
|
|
59
|
+
config: model.config
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
63
|
+
return new _ElevenLabsTranscriptionModel(options.modelId, options.config);
|
|
64
|
+
}
|
|
69
65
|
async getArgs({
|
|
70
66
|
audio,
|
|
71
67
|
mediaType,
|
|
@@ -73,15 +69,15 @@ var ElevenLabsTranscriptionModel = class {
|
|
|
73
69
|
}) {
|
|
74
70
|
var _a, _b, _c, _d, _e;
|
|
75
71
|
const warnings = [];
|
|
76
|
-
const elevenlabsOptions = await
|
|
72
|
+
const elevenlabsOptions = await parseProviderOptions({
|
|
77
73
|
provider: "elevenlabs",
|
|
78
74
|
providerOptions,
|
|
79
75
|
schema: elevenLabsTranscriptionModelOptionsSchema
|
|
80
76
|
});
|
|
81
77
|
const formData = new FormData();
|
|
82
|
-
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([
|
|
78
|
+
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([convertBase64ToUint8Array(audio)]);
|
|
83
79
|
formData.append("model_id", this.modelId);
|
|
84
|
-
const fileExtension =
|
|
80
|
+
const fileExtension = mediaTypeToExtension(mediaType);
|
|
85
81
|
formData.append(
|
|
86
82
|
"file",
|
|
87
83
|
new File([blob], "audio", { type: mediaType }),
|
|
@@ -112,22 +108,22 @@ var ElevenLabsTranscriptionModel = class {
|
|
|
112
108
|
};
|
|
113
109
|
}
|
|
114
110
|
async doGenerate(options) {
|
|
115
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
111
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
116
112
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
117
113
|
const { formData, warnings } = await this.getArgs(options);
|
|
118
114
|
const {
|
|
119
115
|
value: response,
|
|
120
116
|
responseHeaders,
|
|
121
117
|
rawValue: rawResponse
|
|
122
|
-
} = await
|
|
118
|
+
} = await postFormDataToApi({
|
|
123
119
|
url: this.config.url({
|
|
124
120
|
path: "/v1/speech-to-text",
|
|
125
121
|
modelId: this.modelId
|
|
126
122
|
}),
|
|
127
|
-
headers: (
|
|
123
|
+
headers: combineHeaders((_e = (_d = this.config).headers) == null ? void 0 : _e.call(_d), options.headers),
|
|
128
124
|
formData,
|
|
129
125
|
failedResponseHandler: elevenlabsFailedResponseHandler,
|
|
130
|
-
successfulResponseHandler:
|
|
126
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
131
127
|
elevenlabsTranscriptionResponseSchema
|
|
132
128
|
),
|
|
133
129
|
abortSignal: options.abortSignal,
|
|
@@ -135,16 +131,16 @@ var ElevenLabsTranscriptionModel = class {
|
|
|
135
131
|
});
|
|
136
132
|
return {
|
|
137
133
|
text: response.text,
|
|
138
|
-
segments: (
|
|
134
|
+
segments: (_g = (_f = response.words) == null ? void 0 : _f.map((word) => {
|
|
139
135
|
var _a2, _b2;
|
|
140
136
|
return {
|
|
141
137
|
text: word.text,
|
|
142
138
|
startSecond: (_a2 = word.start) != null ? _a2 : 0,
|
|
143
139
|
endSecond: (_b2 = word.end) != null ? _b2 : 0
|
|
144
140
|
};
|
|
145
|
-
})) != null ?
|
|
141
|
+
})) != null ? _g : [],
|
|
146
142
|
language: response.language_code,
|
|
147
|
-
durationInSeconds: (
|
|
143
|
+
durationInSeconds: (_j = (_i = (_h = response.words) == null ? void 0 : _h.at(-1)) == null ? void 0 : _i.end) != null ? _j : void 0,
|
|
148
144
|
warnings,
|
|
149
145
|
response: {
|
|
150
146
|
timestamp: currentDate,
|
|
@@ -155,22 +151,22 @@ var ElevenLabsTranscriptionModel = class {
|
|
|
155
151
|
};
|
|
156
152
|
}
|
|
157
153
|
};
|
|
158
|
-
var elevenlabsTranscriptionResponseSchema =
|
|
159
|
-
language_code:
|
|
160
|
-
language_probability:
|
|
161
|
-
text:
|
|
162
|
-
words:
|
|
163
|
-
|
|
164
|
-
text:
|
|
165
|
-
type:
|
|
166
|
-
start:
|
|
167
|
-
end:
|
|
168
|
-
speaker_id:
|
|
169
|
-
characters:
|
|
170
|
-
|
|
171
|
-
text:
|
|
172
|
-
start:
|
|
173
|
-
end:
|
|
154
|
+
var elevenlabsTranscriptionResponseSchema = z2.object({
|
|
155
|
+
language_code: z2.string(),
|
|
156
|
+
language_probability: z2.number(),
|
|
157
|
+
text: z2.string(),
|
|
158
|
+
words: z2.array(
|
|
159
|
+
z2.object({
|
|
160
|
+
text: z2.string(),
|
|
161
|
+
type: z2.enum(["word", "spacing", "audio_event"]),
|
|
162
|
+
start: z2.number().nullish(),
|
|
163
|
+
end: z2.number().nullish(),
|
|
164
|
+
speaker_id: z2.string().nullish(),
|
|
165
|
+
characters: z2.array(
|
|
166
|
+
z2.object({
|
|
167
|
+
text: z2.string(),
|
|
168
|
+
start: z2.number().nullish(),
|
|
169
|
+
end: z2.number().nullish()
|
|
174
170
|
})
|
|
175
171
|
).nullish()
|
|
176
172
|
})
|
|
@@ -178,40 +174,57 @@ var elevenlabsTranscriptionResponseSchema = import_v42.z.object({
|
|
|
178
174
|
});
|
|
179
175
|
|
|
180
176
|
// src/elevenlabs-speech-model.ts
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
177
|
+
import {
|
|
178
|
+
combineHeaders as combineHeaders2,
|
|
179
|
+
createBinaryResponseHandler,
|
|
180
|
+
parseProviderOptions as parseProviderOptions2,
|
|
181
|
+
postJsonToApi,
|
|
182
|
+
serializeModelOptions as serializeModelOptions2,
|
|
183
|
+
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
|
|
184
|
+
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2
|
|
185
|
+
} from "@ai-sdk/provider-utils";
|
|
186
|
+
import { z as z3 } from "zod/v4";
|
|
187
|
+
var elevenLabsSpeechModelOptionsSchema = z3.object({
|
|
188
|
+
languageCode: z3.string().optional(),
|
|
189
|
+
voiceSettings: z3.object({
|
|
190
|
+
stability: z3.number().min(0).max(1).optional(),
|
|
191
|
+
similarityBoost: z3.number().min(0).max(1).optional(),
|
|
192
|
+
style: z3.number().min(0).max(1).optional(),
|
|
193
|
+
useSpeakerBoost: z3.boolean().optional()
|
|
190
194
|
}).optional(),
|
|
191
|
-
pronunciationDictionaryLocators:
|
|
192
|
-
|
|
193
|
-
pronunciationDictionaryId:
|
|
194
|
-
versionId:
|
|
195
|
+
pronunciationDictionaryLocators: z3.array(
|
|
196
|
+
z3.object({
|
|
197
|
+
pronunciationDictionaryId: z3.string(),
|
|
198
|
+
versionId: z3.string().optional()
|
|
195
199
|
})
|
|
196
200
|
).max(3).optional(),
|
|
197
|
-
seed:
|
|
198
|
-
previousText:
|
|
199
|
-
nextText:
|
|
200
|
-
previousRequestIds:
|
|
201
|
-
nextRequestIds:
|
|
202
|
-
applyTextNormalization:
|
|
203
|
-
applyLanguageTextNormalization:
|
|
204
|
-
enableLogging:
|
|
201
|
+
seed: z3.number().min(0).max(4294967295).optional(),
|
|
202
|
+
previousText: z3.string().optional(),
|
|
203
|
+
nextText: z3.string().optional(),
|
|
204
|
+
previousRequestIds: z3.array(z3.string()).max(3).optional(),
|
|
205
|
+
nextRequestIds: z3.array(z3.string()).max(3).optional(),
|
|
206
|
+
applyTextNormalization: z3.enum(["auto", "on", "off"]).optional(),
|
|
207
|
+
applyLanguageTextNormalization: z3.boolean().optional(),
|
|
208
|
+
enableLogging: z3.boolean().optional()
|
|
205
209
|
});
|
|
206
|
-
var ElevenLabsSpeechModel = class {
|
|
210
|
+
var ElevenLabsSpeechModel = class _ElevenLabsSpeechModel {
|
|
207
211
|
constructor(modelId, config) {
|
|
208
212
|
this.modelId = modelId;
|
|
209
213
|
this.config = config;
|
|
210
|
-
this.specificationVersion = "
|
|
214
|
+
this.specificationVersion = "v4";
|
|
211
215
|
}
|
|
212
216
|
get provider() {
|
|
213
217
|
return this.config.provider;
|
|
214
218
|
}
|
|
219
|
+
static [WORKFLOW_SERIALIZE2](model) {
|
|
220
|
+
return serializeModelOptions2({
|
|
221
|
+
modelId: model.modelId,
|
|
222
|
+
config: model.config
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
static [WORKFLOW_DESERIALIZE2](options) {
|
|
226
|
+
return new _ElevenLabsSpeechModel(options.modelId, options.config);
|
|
227
|
+
}
|
|
215
228
|
async getArgs({
|
|
216
229
|
text,
|
|
217
230
|
voice = "21m00Tcm4TlvDq8ikWAM",
|
|
@@ -222,7 +235,7 @@ var ElevenLabsSpeechModel = class {
|
|
|
222
235
|
providerOptions
|
|
223
236
|
}) {
|
|
224
237
|
const warnings = [];
|
|
225
|
-
const elevenLabsOptions = await (
|
|
238
|
+
const elevenLabsOptions = await parseProviderOptions2({
|
|
226
239
|
provider: "elevenlabs",
|
|
227
240
|
providerOptions,
|
|
228
241
|
schema: elevenLabsSpeechModelOptionsSchema
|
|
@@ -324,14 +337,14 @@ var ElevenLabsSpeechModel = class {
|
|
|
324
337
|
};
|
|
325
338
|
}
|
|
326
339
|
async doGenerate(options) {
|
|
327
|
-
var _a, _b, _c;
|
|
340
|
+
var _a, _b, _c, _d, _e;
|
|
328
341
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
329
342
|
const { requestBody, queryParams, warnings, voiceId } = await this.getArgs(options);
|
|
330
343
|
const {
|
|
331
344
|
value: audio,
|
|
332
345
|
responseHeaders,
|
|
333
346
|
rawValue: rawResponse
|
|
334
|
-
} = await
|
|
347
|
+
} = await postJsonToApi({
|
|
335
348
|
url: (() => {
|
|
336
349
|
const baseUrl = this.config.url({
|
|
337
350
|
path: `/v1/text-to-speech/${voiceId}`,
|
|
@@ -340,10 +353,10 @@ var ElevenLabsSpeechModel = class {
|
|
|
340
353
|
const queryString = new URLSearchParams(queryParams).toString();
|
|
341
354
|
return queryString ? `${baseUrl}?${queryString}` : baseUrl;
|
|
342
355
|
})(),
|
|
343
|
-
headers: (
|
|
356
|
+
headers: combineHeaders2((_e = (_d = this.config).headers) == null ? void 0 : _e.call(_d), options.headers),
|
|
344
357
|
body: requestBody,
|
|
345
358
|
failedResponseHandler: elevenlabsFailedResponseHandler,
|
|
346
|
-
successfulResponseHandler:
|
|
359
|
+
successfulResponseHandler: createBinaryResponseHandler(),
|
|
347
360
|
abortSignal: options.abortSignal,
|
|
348
361
|
fetch: this.config.fetch
|
|
349
362
|
});
|
|
@@ -364,13 +377,13 @@ var ElevenLabsSpeechModel = class {
|
|
|
364
377
|
};
|
|
365
378
|
|
|
366
379
|
// src/version.ts
|
|
367
|
-
var VERSION = true ? "3.0.0-beta.
|
|
380
|
+
var VERSION = true ? "3.0.0-beta.21" : "0.0.0-test";
|
|
368
381
|
|
|
369
382
|
// src/elevenlabs-provider.ts
|
|
370
383
|
function createElevenLabs(options = {}) {
|
|
371
|
-
const getHeaders = () =>
|
|
384
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
372
385
|
{
|
|
373
|
-
"xi-api-key":
|
|
386
|
+
"xi-api-key": loadApiKey({
|
|
374
387
|
apiKey: options.apiKey,
|
|
375
388
|
environmentVariableName: "ELEVENLABS_API_KEY",
|
|
376
389
|
description: "ElevenLabs"
|
|
@@ -396,20 +409,20 @@ function createElevenLabs(options = {}) {
|
|
|
396
409
|
transcription: createTranscriptionModel(modelId)
|
|
397
410
|
};
|
|
398
411
|
};
|
|
399
|
-
provider.specificationVersion = "
|
|
412
|
+
provider.specificationVersion = "v4";
|
|
400
413
|
provider.transcription = createTranscriptionModel;
|
|
401
414
|
provider.transcriptionModel = createTranscriptionModel;
|
|
402
415
|
provider.speech = createSpeechModel;
|
|
403
416
|
provider.speechModel = createSpeechModel;
|
|
404
417
|
provider.languageModel = (modelId) => {
|
|
405
|
-
throw new
|
|
418
|
+
throw new NoSuchModelError({
|
|
406
419
|
modelId,
|
|
407
420
|
modelType: "languageModel",
|
|
408
421
|
message: "ElevenLabs does not provide language models"
|
|
409
422
|
});
|
|
410
423
|
};
|
|
411
424
|
provider.embeddingModel = (modelId) => {
|
|
412
|
-
throw new
|
|
425
|
+
throw new NoSuchModelError({
|
|
413
426
|
modelId,
|
|
414
427
|
modelType: "embeddingModel",
|
|
415
428
|
message: "ElevenLabs does not provide embedding models"
|
|
@@ -417,7 +430,7 @@ function createElevenLabs(options = {}) {
|
|
|
417
430
|
};
|
|
418
431
|
provider.textEmbeddingModel = provider.embeddingModel;
|
|
419
432
|
provider.imageModel = (modelId) => {
|
|
420
|
-
throw new
|
|
433
|
+
throw new NoSuchModelError({
|
|
421
434
|
modelId,
|
|
422
435
|
modelType: "imageModel",
|
|
423
436
|
message: "ElevenLabs does not provide image models"
|
|
@@ -426,10 +439,9 @@ function createElevenLabs(options = {}) {
|
|
|
426
439
|
return provider;
|
|
427
440
|
}
|
|
428
441
|
var elevenlabs = createElevenLabs();
|
|
429
|
-
|
|
430
|
-
0 && (module.exports = {
|
|
442
|
+
export {
|
|
431
443
|
VERSION,
|
|
432
444
|
createElevenLabs,
|
|
433
445
|
elevenlabs
|
|
434
|
-
}
|
|
446
|
+
};
|
|
435
447
|
//# sourceMappingURL=index.js.map
|