@ai-sdk/deepgram 3.0.29 → 3.1.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/CHANGELOG.md +39 -0
- package/README.md +2 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +72 -31
- package/dist/index.js.map +1 -1
- package/docs/110-deepgram.mdx +61 -21
- package/package.json +3 -3
- package/src/deepgram-error.ts +6 -5
- package/src/deepgram-provider.ts +1 -1
- package/src/deepgram-speech-model.ts +74 -12
- package/src/deepgram-speech-options.ts +6 -10
- package/src/deepgram-transcription-model.ts +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @ai-sdk/deepgram
|
|
2
2
|
|
|
3
|
+
## 3.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 00fe856: feat(deepgram): transcription option fixes + speech voice/language composition, usage metadata, speed passthrough, and error parsing
|
|
8
|
+
|
|
9
|
+
Transcription:
|
|
10
|
+
|
|
11
|
+
- `keyterm`, `paragraphs`, `intents`, `sentiment`, and `replace` were
|
|
12
|
+
accepted in `providerOptions.deepgram` but silently dropped from the
|
|
13
|
+
`/v1/listen` request. They are now sent as query parameters. Also widens
|
|
14
|
+
the provider callable signature from `'nova-3'` to any transcription
|
|
15
|
+
model ID.
|
|
16
|
+
- **Behavior change:** `diarize` no longer defaults to `true`. Speaker
|
|
17
|
+
diarization is a paid Deepgram add-on, and the provider previously sent
|
|
18
|
+
`diarize=true` on every pre-recorded request unless explicitly opted
|
|
19
|
+
out. It is now only sent when explicitly set in
|
|
20
|
+
`providerOptions.deepgram`. Users who relied on the old default must
|
|
21
|
+
pass `providerOptions: { deepgram: { diarize: true } }`.
|
|
22
|
+
|
|
23
|
+
Speech:
|
|
24
|
+
|
|
25
|
+
- Bare voice family IDs (`aura-2`, `aura`) compose the upstream model ID
|
|
26
|
+
from the `generateSpeech` `voice` and `language` options
|
|
27
|
+
(`<family>-<voice>-<language>`, language defaults to `en`) and require
|
|
28
|
+
`voice`; full voice IDs (e.g. `aura-2-helena-en`) keep passing through
|
|
29
|
+
unchanged. The `DeepgramSpeechModelId` union is trimmed to the family
|
|
30
|
+
IDs plus the string escape hatch.
|
|
31
|
+
- `providerMetadata.deepgram` carries `modelName`, `modelUuid`,
|
|
32
|
+
`additionalModelUuids`, `charCount` (the billed character count),
|
|
33
|
+
`breaksApplied`, `pronunciationsApplied`, `pronunciationWarnings` (when
|
|
34
|
+
present), and `requestId` from the `/v1/speak` response headers.
|
|
35
|
+
- The `speed` option is passed through to Deepgram's `speed` parameter
|
|
36
|
+
(accepted range 0.7–1.5) instead of being ignored with a warning.
|
|
37
|
+
- API errors now parse Deepgram's `{ "err_code", "err_msg", "request_id" }`
|
|
38
|
+
error shape, so `APICallError.message` carries the real cause instead of
|
|
39
|
+
the HTTP reason phrase. The legacy `{ "error": { "message", "code" } }`
|
|
40
|
+
schema was dropped: no endpoint returns it.
|
|
41
|
+
|
|
3
42
|
## 3.0.29
|
|
4
43
|
|
|
5
44
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -71,7 +71,8 @@ import { deepgram } from '@ai-sdk/deepgram';
|
|
|
71
71
|
import { generateSpeech } from 'ai';
|
|
72
72
|
|
|
73
73
|
const { audio } = await generateSpeech({
|
|
74
|
-
model: deepgram.speech('aura-2
|
|
74
|
+
model: deepgram.speech('aura-2'),
|
|
75
|
+
voice: 'helena',
|
|
75
76
|
text: 'Hello, welcome to Deepgram!',
|
|
76
77
|
});
|
|
77
78
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -39,10 +39,10 @@ declare class DeepgramTranscriptionModel implements TranscriptionModelV4 {
|
|
|
39
39
|
doGenerate(options: Parameters<TranscriptionModelV4['doGenerate']>[0]): Promise<Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>>;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
type DeepgramSpeechModelId = 'aura
|
|
42
|
+
type DeepgramSpeechModelId = 'aura' | 'aura-2' | (string & {});
|
|
43
43
|
|
|
44
44
|
interface DeepgramProvider extends ProviderV4 {
|
|
45
|
-
(modelId:
|
|
45
|
+
(modelId: DeepgramTranscriptionModelId, settings?: {}): {
|
|
46
46
|
transcription: DeepgramTranscriptionModel;
|
|
47
47
|
};
|
|
48
48
|
/**
|
package/dist/index.js
CHANGED
|
@@ -23,14 +23,13 @@ import { z as z3 } from "zod/v4";
|
|
|
23
23
|
import { z } from "zod/v4";
|
|
24
24
|
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
25
25
|
var deepgramErrorDataSchema = z.object({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
})
|
|
26
|
+
err_code: z.string(),
|
|
27
|
+
err_msg: z.string(),
|
|
28
|
+
request_id: z.string().optional()
|
|
30
29
|
});
|
|
31
30
|
var deepgramFailedResponseHandler = createJsonErrorResponseHandler({
|
|
32
31
|
errorSchema: deepgramErrorDataSchema,
|
|
33
|
-
errorToMessage: (data) => data.
|
|
32
|
+
errorToMessage: (data) => data.err_msg
|
|
34
33
|
});
|
|
35
34
|
|
|
36
35
|
// src/deepgram-transcription-model-options.ts
|
|
@@ -96,7 +95,7 @@ var DeepgramTranscriptionModel = class _DeepgramTranscriptionModel {
|
|
|
96
95
|
async getArgs({
|
|
97
96
|
providerOptions
|
|
98
97
|
}) {
|
|
99
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
98
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
100
99
|
const warnings = [];
|
|
101
100
|
const deepgramOptions = await parseProviderOptions({
|
|
102
101
|
provider: "deepgram",
|
|
@@ -104,25 +103,27 @@ var DeepgramTranscriptionModel = class _DeepgramTranscriptionModel {
|
|
|
104
103
|
schema: deepgramTranscriptionModelOptionsSchema
|
|
105
104
|
});
|
|
106
105
|
const body = {
|
|
107
|
-
model: this.modelId
|
|
108
|
-
diarize: true
|
|
106
|
+
model: this.modelId
|
|
109
107
|
};
|
|
110
108
|
if (deepgramOptions) {
|
|
111
109
|
body.detect_entities = (_a = deepgramOptions.detectEntities) != null ? _a : void 0;
|
|
112
110
|
body.detect_language = (_b = deepgramOptions.detectLanguage) != null ? _b : void 0;
|
|
113
|
-
body.
|
|
114
|
-
body.
|
|
115
|
-
body.
|
|
116
|
-
body.
|
|
117
|
-
body.
|
|
118
|
-
body.
|
|
119
|
-
body.
|
|
120
|
-
body.
|
|
121
|
-
body.
|
|
122
|
-
body.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
111
|
+
body.diarize = (_c = deepgramOptions.diarize) != null ? _c : void 0;
|
|
112
|
+
body.filler_words = (_d = deepgramOptions.fillerWords) != null ? _d : void 0;
|
|
113
|
+
body.intents = (_e = deepgramOptions.intents) != null ? _e : void 0;
|
|
114
|
+
body.keyterm = (_f = deepgramOptions.keyterm) != null ? _f : void 0;
|
|
115
|
+
body.language = (_g = deepgramOptions.language) != null ? _g : void 0;
|
|
116
|
+
body.paragraphs = (_h = deepgramOptions.paragraphs) != null ? _h : void 0;
|
|
117
|
+
body.punctuate = (_i = deepgramOptions.punctuate) != null ? _i : void 0;
|
|
118
|
+
body.redact = (_j = deepgramOptions.redact) != null ? _j : void 0;
|
|
119
|
+
body.replace = (_k = deepgramOptions.replace) != null ? _k : void 0;
|
|
120
|
+
body.search = (_l = deepgramOptions.search) != null ? _l : void 0;
|
|
121
|
+
body.sentiment = (_m = deepgramOptions.sentiment) != null ? _m : void 0;
|
|
122
|
+
body.smart_format = (_n = deepgramOptions.smartFormat) != null ? _n : void 0;
|
|
123
|
+
body.summarize = (_o = deepgramOptions.summarize) != null ? _o : void 0;
|
|
124
|
+
body.topics = (_p = deepgramOptions.topics) != null ? _p : void 0;
|
|
125
|
+
body.utterances = (_q = deepgramOptions.utterances) != null ? _q : void 0;
|
|
126
|
+
body.utt_split = (_r = deepgramOptions.uttSplit) != null ? _r : void 0;
|
|
126
127
|
}
|
|
127
128
|
const queryParams = new URLSearchParams();
|
|
128
129
|
for (const [key, value] of Object.entries(body)) {
|
|
@@ -240,6 +241,7 @@ var deepgramSpeechModelOptionsSchema = z4.object({
|
|
|
240
241
|
});
|
|
241
242
|
|
|
242
243
|
// src/deepgram-speech-model.ts
|
|
244
|
+
var VOICE_FAMILY_IDS = /* @__PURE__ */ new Set(["aura", "aura-2"]);
|
|
243
245
|
var DeepgramSpeechModel = class _DeepgramSpeechModel {
|
|
244
246
|
constructor(modelId, config) {
|
|
245
247
|
this.modelId = modelId;
|
|
@@ -274,11 +276,28 @@ var DeepgramSpeechModel = class _DeepgramSpeechModel {
|
|
|
274
276
|
providerOptions,
|
|
275
277
|
schema: deepgramSpeechModelOptionsSchema
|
|
276
278
|
});
|
|
279
|
+
let upstreamModelId = this.modelId;
|
|
280
|
+
if (VOICE_FAMILY_IDS.has(this.modelId)) {
|
|
281
|
+
const trimmedVoice = voice == null ? void 0 : voice.trim();
|
|
282
|
+
if (!trimmedVoice) {
|
|
283
|
+
throw new Error(
|
|
284
|
+
`Deepgram speech model "${this.modelId}" requires a \`voice\` to be set (e.g. voice: 'thalia').`
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
if (language === "auto") {
|
|
288
|
+
warnings.push({
|
|
289
|
+
type: "compatibility",
|
|
290
|
+
feature: "language",
|
|
291
|
+
details: `Deepgram TTS models do not support automatic language detection. Language "en" was used instead.`
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
upstreamModelId = `${this.modelId}-${trimmedVoice}-${language && language !== "auto" ? language : "en"}`;
|
|
295
|
+
}
|
|
277
296
|
const requestBody = {
|
|
278
297
|
text
|
|
279
298
|
};
|
|
280
299
|
const queryParams = {
|
|
281
|
-
model:
|
|
300
|
+
model: upstreamModelId
|
|
282
301
|
};
|
|
283
302
|
if (outputFormat) {
|
|
284
303
|
const formatLower = outputFormat.toLowerCase();
|
|
@@ -535,7 +554,7 @@ var DeepgramSpeechModel = class _DeepgramSpeechModel {
|
|
|
535
554
|
}
|
|
536
555
|
}
|
|
537
556
|
}
|
|
538
|
-
if (voice && voice !== this.modelId) {
|
|
557
|
+
if (upstreamModelId === this.modelId && voice && voice !== this.modelId) {
|
|
539
558
|
warnings.push({
|
|
540
559
|
type: "unsupported",
|
|
541
560
|
feature: "voice",
|
|
@@ -543,13 +562,9 @@ var DeepgramSpeechModel = class _DeepgramSpeechModel {
|
|
|
543
562
|
});
|
|
544
563
|
}
|
|
545
564
|
if (speed != null) {
|
|
546
|
-
|
|
547
|
-
type: "unsupported",
|
|
548
|
-
feature: "speed",
|
|
549
|
-
details: `Deepgram TTS REST API does not support speed adjustment. Speed parameter was ignored.`
|
|
550
|
-
});
|
|
565
|
+
queryParams.speed = String(speed);
|
|
551
566
|
}
|
|
552
|
-
if (language) {
|
|
567
|
+
if (upstreamModelId === this.modelId && language) {
|
|
553
568
|
warnings.push({
|
|
554
569
|
type: "unsupported",
|
|
555
570
|
feature: "language",
|
|
@@ -570,7 +585,7 @@ var DeepgramSpeechModel = class _DeepgramSpeechModel {
|
|
|
570
585
|
};
|
|
571
586
|
}
|
|
572
587
|
async doGenerate(options) {
|
|
573
|
-
var _a, _b, _c, _d, _e;
|
|
588
|
+
var _a, _b, _c, _d, _e, _f;
|
|
574
589
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
575
590
|
const { requestBody, queryParams, warnings } = await this.getArgs(options);
|
|
576
591
|
const {
|
|
@@ -593,6 +608,18 @@ var DeepgramSpeechModel = class _DeepgramSpeechModel {
|
|
|
593
608
|
abortSignal: options.abortSignal,
|
|
594
609
|
fetch: this.config.fetch
|
|
595
610
|
});
|
|
611
|
+
const headerNumber = (name) => {
|
|
612
|
+
const value = responseHeaders == null ? void 0 : responseHeaders[name];
|
|
613
|
+
if (value == null) {
|
|
614
|
+
return void 0;
|
|
615
|
+
}
|
|
616
|
+
const parsed = Number(value);
|
|
617
|
+
return Number.isNaN(parsed) ? void 0 : parsed;
|
|
618
|
+
};
|
|
619
|
+
const charCount = headerNumber("dg-char-count");
|
|
620
|
+
const breaksApplied = headerNumber("dg-breaks-applied");
|
|
621
|
+
const pronunciationsApplied = headerNumber("dg-pronunciations-applied");
|
|
622
|
+
const additionalModelUuids = (_f = responseHeaders == null ? void 0 : responseHeaders["dg-additional-model-uuids"]) == null ? void 0 : _f.split(",");
|
|
596
623
|
return {
|
|
597
624
|
audio,
|
|
598
625
|
warnings,
|
|
@@ -604,13 +631,27 @@ var DeepgramSpeechModel = class _DeepgramSpeechModel {
|
|
|
604
631
|
modelId: this.modelId,
|
|
605
632
|
headers: responseHeaders,
|
|
606
633
|
body: rawResponse
|
|
634
|
+
},
|
|
635
|
+
providerMetadata: {
|
|
636
|
+
deepgram: {
|
|
637
|
+
...(responseHeaders == null ? void 0 : responseHeaders["dg-model-name"]) ? { modelName: responseHeaders["dg-model-name"] } : {},
|
|
638
|
+
...(responseHeaders == null ? void 0 : responseHeaders["dg-model-uuid"]) ? { modelUuid: responseHeaders["dg-model-uuid"] } : {},
|
|
639
|
+
...additionalModelUuids ? { additionalModelUuids } : {},
|
|
640
|
+
...charCount != null ? { charCount } : {},
|
|
641
|
+
...breaksApplied != null ? { breaksApplied } : {},
|
|
642
|
+
...pronunciationsApplied != null ? { pronunciationsApplied } : {},
|
|
643
|
+
...(responseHeaders == null ? void 0 : responseHeaders["dg-pronunciation-warnings"]) ? {
|
|
644
|
+
pronunciationWarnings: responseHeaders["dg-pronunciation-warnings"]
|
|
645
|
+
} : {},
|
|
646
|
+
...(responseHeaders == null ? void 0 : responseHeaders["dg-request-id"]) ? { requestId: responseHeaders["dg-request-id"] } : {}
|
|
647
|
+
}
|
|
607
648
|
}
|
|
608
649
|
};
|
|
609
650
|
}
|
|
610
651
|
};
|
|
611
652
|
|
|
612
653
|
// src/version.ts
|
|
613
|
-
var VERSION = true ? "3.0
|
|
654
|
+
var VERSION = true ? "3.1.0" : "0.0.0-test";
|
|
614
655
|
|
|
615
656
|
// src/deepgram-provider.ts
|
|
616
657
|
function createDeepgram(options = {}) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/deepgram-provider.ts","../src/deepgram-transcription-model.ts","../src/deepgram-error.ts","../src/deepgram-transcription-model-options.ts","../src/deepgram-speech-model.ts","../src/deepgram-speech-model-options.ts","../src/version.ts"],"sourcesContent":["import {\n NoSuchModelError,\n type TranscriptionModelV4,\n type SpeechModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n loadApiKey,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { DeepgramTranscriptionModel } from './deepgram-transcription-model';\nimport type { DeepgramTranscriptionModelId } from './deepgram-transcription-options';\nimport { DeepgramSpeechModel } from './deepgram-speech-model';\nimport type { DeepgramSpeechModelId } from './deepgram-speech-options';\nimport { VERSION } from './version';\n\nexport interface DeepgramProvider extends ProviderV4 {\n (\n modelId: 'nova-3',\n settings?: {},\n ): {\n transcription: DeepgramTranscriptionModel;\n };\n\n /**\n * Creates a model for transcription.\n */\n transcription(modelId: DeepgramTranscriptionModelId): TranscriptionModelV4;\n\n /**\n * Creates a model for speech generation.\n */\n speech(modelId: DeepgramSpeechModelId): SpeechModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport interface DeepgramProviderSettings {\n /**\n * API key for authenticating requests.\n */\n apiKey?: string;\n\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\n/**\n * Create an Deepgram provider instance.\n */\nexport function createDeepgram(\n options: DeepgramProviderSettings = {},\n): DeepgramProvider {\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n authorization: `Token ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'DEEPGRAM_API_KEY',\n description: 'Deepgram',\n })}`,\n ...options.headers,\n },\n `ai-sdk/deepgram/${VERSION}`,\n );\n\n const createTranscriptionModel = (modelId: DeepgramTranscriptionModelId) =>\n new DeepgramTranscriptionModel(modelId, {\n provider: `deepgram.transcription`,\n url: ({ path }) => `https://api.deepgram.com${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createSpeechModel = (modelId: DeepgramSpeechModelId) =>\n new DeepgramSpeechModel(modelId, {\n provider: `deepgram.speech`,\n url: ({ path }) => `https://api.deepgram.com${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const provider = function (modelId: DeepgramTranscriptionModelId) {\n return {\n transcription: createTranscriptionModel(modelId),\n };\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.transcription = createTranscriptionModel;\n provider.transcriptionModel = createTranscriptionModel;\n provider.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n\n // Required ProviderV4 methods that are not supported\n provider.languageModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'languageModel',\n message: 'Deepgram does not provide language models',\n });\n };\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n message: 'Deepgram does not provide text embedding models',\n });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'imageModel',\n message: 'Deepgram does not provide image models',\n });\n };\n\n return provider as DeepgramProvider;\n}\n\n/**\n * Default Deepgram provider instance.\n */\nexport const deepgram = createDeepgram();\n","import type { SharedV4Warning, TranscriptionModelV4 } from '@ai-sdk/provider';\nimport {\n combineHeaders,\n createJsonResponseHandler,\n parseProviderOptions,\n postToApi,\n serializeModelOptions,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { DeepgramTranscriptionAPITypes } from './deepgram-api-types';\nimport type { DeepgramConfig } from './deepgram-config';\nimport { deepgramFailedResponseHandler } from './deepgram-error';\nimport { deepgramTranscriptionModelOptionsSchema } from './deepgram-transcription-model-options';\nimport type { DeepgramTranscriptionModelId } from './deepgram-transcription-options';\n\ninterface DeepgramTranscriptionModelConfig extends DeepgramConfig {\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class DeepgramTranscriptionModel implements TranscriptionModelV4 {\n readonly specificationVersion = 'v4';\n\n get provider(): string {\n return this.config.provider;\n }\n\n static [WORKFLOW_SERIALIZE](model: DeepgramTranscriptionModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: DeepgramTranscriptionModelId;\n config: DeepgramTranscriptionModelConfig;\n }) {\n return new DeepgramTranscriptionModel(options.modelId, options.config);\n }\n\n constructor(\n readonly modelId: DeepgramTranscriptionModelId,\n private readonly config: DeepgramTranscriptionModelConfig,\n ) {}\n\n private async getArgs({\n providerOptions,\n }: Parameters<TranscriptionModelV4['doGenerate']>[0]) {\n const warnings: SharedV4Warning[] = [];\n\n // Parse provider options\n const deepgramOptions = await parseProviderOptions({\n provider: 'deepgram',\n providerOptions,\n schema: deepgramTranscriptionModelOptionsSchema,\n });\n\n const body: DeepgramTranscriptionAPITypes = {\n model: this.modelId,\n diarize: true,\n };\n\n // Add provider-specific options\n if (deepgramOptions) {\n body.detect_entities = deepgramOptions.detectEntities ?? undefined;\n body.detect_language = deepgramOptions.detectLanguage ?? undefined;\n body.filler_words = deepgramOptions.fillerWords ?? undefined;\n body.language = deepgramOptions.language ?? undefined;\n body.punctuate = deepgramOptions.punctuate ?? undefined;\n body.redact = deepgramOptions.redact ?? undefined;\n body.search = deepgramOptions.search ?? undefined;\n body.smart_format = deepgramOptions.smartFormat ?? undefined;\n body.summarize = deepgramOptions.summarize ?? undefined;\n body.topics = deepgramOptions.topics ?? undefined;\n body.utterances = deepgramOptions.utterances ?? undefined;\n body.utt_split = deepgramOptions.uttSplit ?? undefined;\n\n if (typeof deepgramOptions.diarize === 'boolean') {\n body.diarize = deepgramOptions.diarize;\n }\n }\n\n // Convert body to URL query parameters\n const queryParams = new URLSearchParams();\n for (const [key, value] of Object.entries(body)) {\n if (value !== undefined) {\n queryParams.append(key, String(value));\n }\n }\n\n return {\n queryParams,\n warnings,\n };\n }\n\n async doGenerate(\n options: Parameters<TranscriptionModelV4['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { queryParams, warnings } = await this.getArgs(options);\n\n const {\n value: response,\n responseHeaders,\n rawValue: rawResponse,\n } = await postToApi({\n url:\n this.config.url({\n path: '/v1/listen',\n modelId: this.modelId,\n }) +\n '?' +\n queryParams.toString(),\n headers: {\n ...combineHeaders(this.config.headers?.(), options.headers),\n 'Content-Type': options.mediaType,\n },\n body: {\n content: options.audio,\n values: options.audio,\n },\n failedResponseHandler: deepgramFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n deepgramTranscriptionResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n text:\n response.results?.channels.at(0)?.alternatives.at(0)?.transcript ?? '',\n segments:\n response.results?.channels[0].alternatives[0].words?.map(word => ({\n text: word.word,\n startSecond: word.start,\n endSecond: word.end,\n })) ?? [],\n language:\n response.results?.channels.at(0)?.detected_language ?? undefined,\n durationInSeconds: response.metadata?.duration ?? undefined,\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n body: rawResponse,\n },\n };\n }\n}\n\nconst deepgramTranscriptionResponseSchema = z.object({\n metadata: z\n .object({\n duration: z.number(),\n })\n .nullish(),\n results: z\n .object({\n channels: z.array(\n z.object({\n detected_language: z.string().nullish(),\n alternatives: z.array(\n z.object({\n transcript: z.string(),\n words: z.array(\n z.object({\n word: z.string(),\n start: z.number(),\n end: z.number(),\n }),\n ),\n }),\n ),\n }),\n ),\n })\n .nullish(),\n});\n","import { z } from 'zod/v4';\nimport { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';\n\nexport const deepgramErrorDataSchema = z.object({\n error: z.object({\n message: z.string(),\n code: z.number(),\n }),\n});\n\nexport type DeepgramErrorData = z.infer<typeof deepgramErrorDataSchema>;\n\nexport const deepgramFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: deepgramErrorDataSchema,\n errorToMessage: data => data.error.message,\n});\n","import { z } from 'zod/v4';\n\n// https://developers.deepgram.com/docs/pre-recorded-audio#results\nexport const deepgramTranscriptionModelOptionsSchema = z.object({\n /** Language to use for transcription. If not specified, Deepgram defaults to English. Use `detectLanguage: true` to enable automatic language detection. */\n language: z.string().nullish(),\n /** Whether to enable automatic language detection. When true, Deepgram will detect the language of the audio. */\n detectLanguage: z.boolean().nullish(),\n /** Whether to use smart formatting, which formats written-out numbers, dates, times, etc. */\n smartFormat: z.boolean().nullish(),\n /** Whether to add punctuation to the transcript. */\n punctuate: z.boolean().nullish(),\n /** Whether to format the transcript into paragraphs. */\n paragraphs: z.boolean().nullish(),\n /** Whether to generate a summary of the transcript. Use 'v2' for the latest version or false to disable. */\n summarize: z.union([z.literal('v2'), z.literal(false)]).nullish(),\n /** Whether to identify topics in the transcript. */\n topics: z.boolean().nullish(),\n /** Whether to identify intents in the transcript. */\n intents: z.boolean().nullish(),\n /** Whether to analyze sentiment in the transcript. */\n sentiment: z.boolean().nullish(),\n /** Whether to detect and tag named entities in the transcript. */\n detectEntities: z.boolean().nullish(),\n /** Specify terms or patterns to redact from the transcript. Can be a string or array of strings. */\n redact: z.union([z.string(), z.array(z.string())]).nullish(),\n /** String to replace redacted content with. */\n replace: z.string().nullish(),\n /** Term or phrase to search for in the transcript. */\n search: z.string().nullish(),\n /** Key term to identify in the transcript. */\n keyterm: z.string().nullish(),\n /** Whether to identify different speakers in the audio. */\n diarize: z.boolean().nullish(),\n /** Whether to segment the transcript into utterances. */\n utterances: z.boolean().nullish(),\n /** Minimum duration of silence (in seconds) to trigger a new utterance. */\n uttSplit: z.number().nullish(),\n /** Whether to include filler words (um, uh, etc.) in the transcript. */\n fillerWords: z.boolean().nullish(),\n});\n\nexport type DeepgramTranscriptionModelOptions = z.infer<\n typeof deepgramTranscriptionModelOptionsSchema\n>;\n","import type { SpeechModelV4, SharedV4Warning } from '@ai-sdk/provider';\nimport {\n combineHeaders,\n createBinaryResponseHandler,\n parseProviderOptions,\n postJsonToApi,\n serializeModelOptions,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n} from '@ai-sdk/provider-utils';\nimport type { DeepgramConfig } from './deepgram-config';\nimport { deepgramFailedResponseHandler } from './deepgram-error';\nimport { deepgramSpeechModelOptionsSchema } from './deepgram-speech-model-options';\nimport type { DeepgramSpeechModelId } from './deepgram-speech-options';\n\ninterface DeepgramSpeechModelConfig extends DeepgramConfig {\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class DeepgramSpeechModel implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n\n get provider(): string {\n return this.config.provider;\n }\n\n static [WORKFLOW_SERIALIZE](model: DeepgramSpeechModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: DeepgramSpeechModelId;\n config: DeepgramSpeechModelConfig;\n }) {\n return new DeepgramSpeechModel(options.modelId, options.config);\n }\n\n constructor(\n readonly modelId: DeepgramSpeechModelId,\n private readonly config: DeepgramSpeechModelConfig,\n ) {}\n\n private async getArgs({\n text,\n voice,\n outputFormat = 'mp3',\n speed,\n language,\n instructions,\n providerOptions,\n }: Parameters<SpeechModelV4['doGenerate']>[0]) {\n const warnings: SharedV4Warning[] = [];\n\n // Parse provider options\n const deepgramOptions = await parseProviderOptions({\n provider: 'deepgram',\n providerOptions,\n schema: deepgramSpeechModelOptionsSchema,\n });\n\n // Create request body\n const requestBody = {\n text,\n };\n\n // Prepare query parameters\n const queryParams: Record<string, string> = {\n model: this.modelId,\n };\n\n // Map outputFormat to encoding/container/sample_rate\n // https://developers.deepgram.com/docs/tts-media-output-settings#audio-format-combinations\n if (outputFormat) {\n const formatLower = outputFormat.toLowerCase();\n\n // Common format mappings based on Deepgram's valid combinations\n const formatMap: Record<\n string,\n {\n encoding?: string;\n container?: string;\n sampleRate?: number;\n bitRate?: number;\n }\n > = {\n // MP3: no container, fixed 22050 sample rate, bitrate 32000/48000\n mp3: { encoding: 'mp3' }, // Don't set container or sample_rate for mp3\n // Linear16: wav/none container, configurable sample rate\n wav: { container: 'wav', encoding: 'linear16' },\n linear16: { encoding: 'linear16', container: 'wav' },\n // MuLaw: wav/none container, 8000/16000 sample rate\n mulaw: { encoding: 'mulaw', container: 'wav' },\n // ALaw: wav/none container, 8000/16000 sample rate\n alaw: { encoding: 'alaw', container: 'wav' },\n // Opus: ogg container, fixed 48000 sample rate\n opus: { encoding: 'opus', container: 'ogg' },\n ogg: { encoding: 'opus', container: 'ogg' },\n // FLAC: no container, configurable sample rate\n flac: { encoding: 'flac' },\n // AAC: no container, fixed 22050 sample rate\n aac: { encoding: 'aac' },\n // Raw audio (no container)\n pcm: { encoding: 'linear16', container: 'none' },\n };\n\n const mappedFormat = formatMap[formatLower];\n if (mappedFormat) {\n if (mappedFormat.encoding) {\n queryParams.encoding = mappedFormat.encoding;\n }\n // Only set container if specified and valid for the encoding\n if (mappedFormat.container) {\n queryParams.container = mappedFormat.container;\n }\n // Only set sample_rate if specified and valid for the encoding\n if (mappedFormat.sampleRate) {\n queryParams.sample_rate = String(mappedFormat.sampleRate);\n }\n // Set bitrate for formats that support it\n if (mappedFormat.bitRate) {\n queryParams.bit_rate = String(mappedFormat.bitRate);\n }\n } else {\n // Try to parse format like \"wav_44100\" or \"linear16_24000\"\n const parts = formatLower.split('_');\n if (parts.length >= 2) {\n const firstPart = parts[0];\n const secondPart = parts[1];\n const sampleRate = parseInt(secondPart, 10);\n\n // Check if first part is an encoding\n if (\n [\n 'linear16',\n 'mulaw',\n 'alaw',\n 'mp3',\n 'opus',\n 'flac',\n 'aac',\n ].includes(firstPart)\n ) {\n queryParams.encoding = firstPart;\n\n // Set container based on encoding\n if (['linear16', 'mulaw', 'alaw'].includes(firstPart)) {\n // These can use wav or none, default to wav\n queryParams.container = 'wav';\n } else if (firstPart === 'opus') {\n queryParams.container = 'ogg';\n }\n // mp3, flac, aac don't use container\n\n // Set sample rate if valid for encoding\n if (!isNaN(sampleRate)) {\n if (\n firstPart === 'linear16' &&\n [8000, 16000, 24000, 32000, 48000].includes(sampleRate)\n ) {\n queryParams.sample_rate = String(sampleRate);\n } else if (\n firstPart === 'mulaw' &&\n [8000, 16000].includes(sampleRate)\n ) {\n queryParams.sample_rate = String(sampleRate);\n } else if (\n firstPart === 'alaw' &&\n [8000, 16000].includes(sampleRate)\n ) {\n queryParams.sample_rate = String(sampleRate);\n } else if (\n firstPart === 'flac' &&\n [8000, 16000, 22050, 32000, 48000].includes(sampleRate)\n ) {\n queryParams.sample_rate = String(sampleRate);\n }\n // mp3, opus, aac have fixed sample rates, don't set\n }\n } else if (['wav', 'ogg'].includes(firstPart)) {\n // First part is container\n if (firstPart === 'wav') {\n queryParams.container = 'wav';\n queryParams.encoding = 'linear16'; // Default encoding for wav\n } else if (firstPart === 'ogg') {\n queryParams.container = 'ogg';\n queryParams.encoding = 'opus'; // Default encoding for ogg\n }\n if (!isNaN(sampleRate)) {\n queryParams.sample_rate = String(sampleRate);\n }\n }\n }\n }\n }\n\n // Add provider-specific options - map camelCase to snake_case\n // Validate combinations according to Deepgram's spec\n if (deepgramOptions) {\n if (deepgramOptions.encoding) {\n const newEncoding = deepgramOptions.encoding.toLowerCase();\n\n // If encoding changes, we may need to clear incompatible parameters\n queryParams.encoding = newEncoding;\n\n // Validate container based on encoding\n if (deepgramOptions.container) {\n // Validate container is valid for this encoding\n if (['linear16', 'mulaw', 'alaw'].includes(newEncoding)) {\n if (\n !['wav', 'none'].includes(deepgramOptions.container.toLowerCase())\n ) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"${newEncoding}\" only supports containers \"wav\" or \"none\". Container \"${deepgramOptions.container}\" was ignored.`,\n });\n } else {\n queryParams.container = deepgramOptions.container.toLowerCase();\n }\n } else if (newEncoding === 'opus') {\n // opus requires ogg container, override any previous container setting\n queryParams.container = 'ogg';\n } else if (['mp3', 'flac', 'aac'].includes(newEncoding)) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"${newEncoding}\" does not support container parameter. Container \"${deepgramOptions.container}\" was ignored.`,\n });\n // Remove container if it was set by outputFormat\n delete queryParams.container;\n }\n } else {\n // No container specified in providerOptions\n // If encoding changed to one that doesn't support container, remove it\n if (['mp3', 'flac', 'aac'].includes(newEncoding)) {\n delete queryParams.container;\n } else if (['linear16', 'mulaw', 'alaw'].includes(newEncoding)) {\n // Set default container if not already set\n if (!queryParams.container) {\n queryParams.container = 'wav'; // Default for these encodings\n }\n } else if (newEncoding === 'opus') {\n // opus requires ogg container, override any previous container setting\n queryParams.container = 'ogg';\n }\n }\n\n // Clean up sample_rate and bit_rate if they're incompatible with the new encoding\n // Fixed sample rate encodings (mp3, opus, aac) don't support sample_rate parameter\n if (['mp3', 'opus', 'aac'].includes(newEncoding)) {\n delete queryParams.sample_rate;\n }\n // Lossless encodings without bitrate support (linear16, mulaw, alaw, flac) don't support bit_rate\n if (['linear16', 'mulaw', 'alaw', 'flac'].includes(newEncoding)) {\n delete queryParams.bit_rate;\n }\n } else if (deepgramOptions.container) {\n // Container specified without encoding - set default encoding\n const container = deepgramOptions.container.toLowerCase();\n const oldEncoding = queryParams.encoding?.toLowerCase();\n let newEncoding: string | undefined;\n\n if (container === 'wav') {\n queryParams.container = 'wav';\n newEncoding = 'linear16'; // Default encoding for wav\n } else if (container === 'ogg') {\n queryParams.container = 'ogg';\n newEncoding = 'opus'; // Default encoding for ogg\n } else if (container === 'none') {\n queryParams.container = 'none';\n newEncoding = 'linear16'; // Default encoding for raw audio\n }\n\n // If encoding changed, clean up incompatible parameters\n if (newEncoding && newEncoding !== oldEncoding) {\n queryParams.encoding = newEncoding;\n // Clean up sample_rate and bit_rate if they're incompatible with the new encoding\n if (['mp3', 'opus', 'aac'].includes(newEncoding)) {\n delete queryParams.sample_rate;\n }\n if (['linear16', 'mulaw', 'alaw', 'flac'].includes(newEncoding)) {\n delete queryParams.bit_rate;\n }\n }\n }\n\n if (deepgramOptions.sampleRate != null) {\n const encoding = queryParams.encoding?.toLowerCase() || '';\n const sampleRate = deepgramOptions.sampleRate;\n\n // Validate sample rate based on encoding\n if (encoding === 'linear16') {\n if (![8000, 16000, 24000, 32000, 48000].includes(sampleRate)) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"linear16\" only supports sample rates: 8000, 16000, 24000, 32000, 48000. Sample rate ${sampleRate} was ignored.`,\n });\n } else {\n queryParams.sample_rate = String(sampleRate);\n }\n } else if (encoding === 'mulaw' || encoding === 'alaw') {\n if (![8000, 16000].includes(sampleRate)) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"${encoding}\" only supports sample rates: 8000, 16000. Sample rate ${sampleRate} was ignored.`,\n });\n } else {\n queryParams.sample_rate = String(sampleRate);\n }\n } else if (encoding === 'flac') {\n if (![8000, 16000, 22050, 32000, 48000].includes(sampleRate)) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"flac\" only supports sample rates: 8000, 16000, 22050, 32000, 48000. Sample rate ${sampleRate} was ignored.`,\n });\n } else {\n queryParams.sample_rate = String(sampleRate);\n }\n } else if (['mp3', 'opus', 'aac'].includes(encoding)) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"${encoding}\" has a fixed sample rate and does not support sample_rate parameter. Sample rate ${sampleRate} was ignored.`,\n });\n } else {\n // No encoding set yet, allow it (will be validated when encoding is set)\n queryParams.sample_rate = String(sampleRate);\n }\n }\n\n if (deepgramOptions.bitRate != null) {\n const encoding = queryParams.encoding?.toLowerCase() || '';\n const bitRate = deepgramOptions.bitRate;\n\n // Validate bitrate based on encoding\n if (encoding === 'mp3') {\n if (![32000, 48000].includes(Number(bitRate))) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"mp3\" only supports bit rates: 32000, 48000. Bit rate ${bitRate} was ignored.`,\n });\n } else {\n queryParams.bit_rate = String(bitRate);\n }\n } else if (encoding === 'opus') {\n const bitRateNum = Number(bitRate);\n if (bitRateNum < 4000 || bitRateNum > 650000) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"opus\" supports bit rates between 4000 and 650000. Bit rate ${bitRate} was ignored.`,\n });\n } else {\n queryParams.bit_rate = String(bitRate);\n }\n } else if (encoding === 'aac') {\n const bitRateNum = Number(bitRate);\n if (bitRateNum < 4000 || bitRateNum > 192000) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"aac\" supports bit rates between 4000 and 192000. Bit rate ${bitRate} was ignored.`,\n });\n } else {\n queryParams.bit_rate = String(bitRate);\n }\n } else if (['linear16', 'mulaw', 'alaw', 'flac'].includes(encoding)) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"${encoding}\" does not support bit_rate parameter. Bit rate ${bitRate} was ignored.`,\n });\n } else {\n // No encoding set yet, allow it\n queryParams.bit_rate = String(bitRate);\n }\n }\n\n if (deepgramOptions.callback) {\n queryParams.callback = deepgramOptions.callback;\n }\n if (deepgramOptions.callbackMethod) {\n queryParams.callback_method = deepgramOptions.callbackMethod;\n }\n if (deepgramOptions.mipOptOut != null) {\n queryParams.mip_opt_out = String(deepgramOptions.mipOptOut);\n }\n if (deepgramOptions.tag) {\n if (Array.isArray(deepgramOptions.tag)) {\n queryParams.tag = deepgramOptions.tag.join(',');\n } else {\n queryParams.tag = deepgramOptions.tag;\n }\n }\n }\n\n // Handle voice parameter - Deepgram embeds voice in model ID\n // If voice is provided and different from model, warn user\n if (voice && voice !== this.modelId) {\n warnings.push({\n type: 'unsupported',\n feature: 'voice',\n details: `Deepgram TTS models embed the voice in the model ID. The voice parameter \"${voice}\" was ignored. Use the model ID to select a voice (e.g., \"aura-2-helena-en\").`,\n });\n }\n\n // Handle speed - not supported in Deepgram REST API\n if (speed != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'speed',\n details: `Deepgram TTS REST API does not support speed adjustment. Speed parameter was ignored.`,\n });\n }\n\n // Handle language - Deepgram models are language-specific via model ID\n if (language) {\n warnings.push({\n type: 'unsupported',\n feature: 'language',\n details: `Deepgram TTS models are language-specific via the model ID. Language parameter \"${language}\" was ignored. Select a model with the appropriate language suffix (e.g., \"-en\" for English).`,\n });\n }\n\n // Handle instructions - not supported in Deepgram REST API\n if (instructions) {\n warnings.push({\n type: 'unsupported',\n feature: 'instructions',\n details: `Deepgram TTS REST API does not support instructions. Instructions parameter was ignored.`,\n });\n }\n\n return {\n requestBody,\n queryParams,\n warnings,\n };\n }\n\n async doGenerate(\n options: Parameters<SpeechModelV4['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<SpeechModelV4['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { requestBody, queryParams, warnings } = await this.getArgs(options);\n\n const {\n value: audio,\n responseHeaders,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url: (() => {\n const baseUrl = this.config.url({\n path: '/v1/speak',\n modelId: this.modelId,\n });\n const queryString = new URLSearchParams(queryParams).toString();\n return queryString ? `${baseUrl}?${queryString}` : baseUrl;\n })(),\n headers: combineHeaders(this.config.headers?.(), options.headers),\n body: requestBody,\n failedResponseHandler: deepgramFailedResponseHandler,\n successfulResponseHandler: createBinaryResponseHandler(),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n audio,\n warnings,\n request: {\n body: JSON.stringify(requestBody),\n },\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n body: rawResponse,\n },\n };\n }\n}\n","import { z } from 'zod/v4';\n\n// https://developers.deepgram.com/reference/text-to-speech/speak-request\nexport const deepgramSpeechModelOptionsSchema = z.object({\n /** Bitrate of the audio in bits per second. Can be a number or predefined enum value. */\n bitRate: z.union([z.number(), z.string()]).nullish(),\n /** Container format for the output audio (mp3, wav, etc.). */\n container: z.string().nullish(),\n /** Encoding type for the audio output (linear16, mulaw, alaw, etc.). */\n encoding: z.string().nullish(),\n /** Sample rate for the output audio in Hz (8000, 16000, 24000, 44100, 48000). */\n sampleRate: z.number().nullish(),\n /** URL to which we'll make the callback request. */\n callback: z.string().url().nullish(),\n /** HTTP method by which the callback request will be made (POST or PUT). */\n callbackMethod: z.enum(['POST', 'PUT']).nullish(),\n /** Opts out requests from the Deepgram Model Improvement Program. */\n mipOptOut: z.boolean().nullish(),\n /** Label your requests for the purpose of identification during usage reporting. */\n tag: z.union([z.string(), z.array(z.string())]).nullish(),\n});\n\nexport type DeepgramSpeechModelOptions = z.infer<\n typeof deepgramSpeechModelOptionsSchema\n>;\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAIK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAEK;;;ACTP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,KAAAA,UAAS;;;ACVlB,SAAS,SAAS;AAClB,SAAS,sCAAsC;AAExC,IAAM,0BAA0B,EAAE,OAAO;AAAA,EAC9C,OAAO,EAAE,OAAO;AAAA,IACd,S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["z","z","z","combineHeaders","parseProviderOptions","serializeModelOptions","WORKFLOW_SERIALIZE","WORKFLOW_DESERIALIZE","z","WORKFLOW_SERIALIZE","serializeModelOptions","WORKFLOW_DESERIALIZE","parseProviderOptions","combineHeaders"]}
|
|
1
|
+
{"version":3,"sources":["../src/deepgram-provider.ts","../src/deepgram-transcription-model.ts","../src/deepgram-error.ts","../src/deepgram-transcription-model-options.ts","../src/deepgram-speech-model.ts","../src/deepgram-speech-model-options.ts","../src/version.ts"],"sourcesContent":["import {\n NoSuchModelError,\n type TranscriptionModelV4,\n type SpeechModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n loadApiKey,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { DeepgramTranscriptionModel } from './deepgram-transcription-model';\nimport type { DeepgramTranscriptionModelId } from './deepgram-transcription-options';\nimport { DeepgramSpeechModel } from './deepgram-speech-model';\nimport type { DeepgramSpeechModelId } from './deepgram-speech-options';\nimport { VERSION } from './version';\n\nexport interface DeepgramProvider extends ProviderV4 {\n (\n modelId: DeepgramTranscriptionModelId,\n settings?: {},\n ): {\n transcription: DeepgramTranscriptionModel;\n };\n\n /**\n * Creates a model for transcription.\n */\n transcription(modelId: DeepgramTranscriptionModelId): TranscriptionModelV4;\n\n /**\n * Creates a model for speech generation.\n */\n speech(modelId: DeepgramSpeechModelId): SpeechModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport interface DeepgramProviderSettings {\n /**\n * API key for authenticating requests.\n */\n apiKey?: string;\n\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\n/**\n * Create an Deepgram provider instance.\n */\nexport function createDeepgram(\n options: DeepgramProviderSettings = {},\n): DeepgramProvider {\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n authorization: `Token ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'DEEPGRAM_API_KEY',\n description: 'Deepgram',\n })}`,\n ...options.headers,\n },\n `ai-sdk/deepgram/${VERSION}`,\n );\n\n const createTranscriptionModel = (modelId: DeepgramTranscriptionModelId) =>\n new DeepgramTranscriptionModel(modelId, {\n provider: `deepgram.transcription`,\n url: ({ path }) => `https://api.deepgram.com${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createSpeechModel = (modelId: DeepgramSpeechModelId) =>\n new DeepgramSpeechModel(modelId, {\n provider: `deepgram.speech`,\n url: ({ path }) => `https://api.deepgram.com${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const provider = function (modelId: DeepgramTranscriptionModelId) {\n return {\n transcription: createTranscriptionModel(modelId),\n };\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.transcription = createTranscriptionModel;\n provider.transcriptionModel = createTranscriptionModel;\n provider.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n\n // Required ProviderV4 methods that are not supported\n provider.languageModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'languageModel',\n message: 'Deepgram does not provide language models',\n });\n };\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n message: 'Deepgram does not provide text embedding models',\n });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'imageModel',\n message: 'Deepgram does not provide image models',\n });\n };\n\n return provider as DeepgramProvider;\n}\n\n/**\n * Default Deepgram provider instance.\n */\nexport const deepgram = createDeepgram();\n","import type { SharedV4Warning, TranscriptionModelV4 } from '@ai-sdk/provider';\nimport {\n combineHeaders,\n createJsonResponseHandler,\n parseProviderOptions,\n postToApi,\n serializeModelOptions,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { DeepgramTranscriptionAPITypes } from './deepgram-api-types';\nimport type { DeepgramConfig } from './deepgram-config';\nimport { deepgramFailedResponseHandler } from './deepgram-error';\nimport { deepgramTranscriptionModelOptionsSchema } from './deepgram-transcription-model-options';\nimport type { DeepgramTranscriptionModelId } from './deepgram-transcription-options';\n\ninterface DeepgramTranscriptionModelConfig extends DeepgramConfig {\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class DeepgramTranscriptionModel implements TranscriptionModelV4 {\n readonly specificationVersion = 'v4';\n\n get provider(): string {\n return this.config.provider;\n }\n\n static [WORKFLOW_SERIALIZE](model: DeepgramTranscriptionModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: DeepgramTranscriptionModelId;\n config: DeepgramTranscriptionModelConfig;\n }) {\n return new DeepgramTranscriptionModel(options.modelId, options.config);\n }\n\n constructor(\n readonly modelId: DeepgramTranscriptionModelId,\n private readonly config: DeepgramTranscriptionModelConfig,\n ) {}\n\n private async getArgs({\n providerOptions,\n }: Parameters<TranscriptionModelV4['doGenerate']>[0]) {\n const warnings: SharedV4Warning[] = [];\n\n // Parse provider options\n const deepgramOptions = await parseProviderOptions({\n provider: 'deepgram',\n providerOptions,\n schema: deepgramTranscriptionModelOptionsSchema,\n });\n\n const body: DeepgramTranscriptionAPITypes = {\n model: this.modelId,\n };\n\n // Add provider-specific options\n if (deepgramOptions) {\n body.detect_entities = deepgramOptions.detectEntities ?? undefined;\n body.detect_language = deepgramOptions.detectLanguage ?? undefined;\n body.diarize = deepgramOptions.diarize ?? undefined;\n body.filler_words = deepgramOptions.fillerWords ?? undefined;\n body.intents = deepgramOptions.intents ?? undefined;\n body.keyterm = deepgramOptions.keyterm ?? undefined;\n body.language = deepgramOptions.language ?? undefined;\n body.paragraphs = deepgramOptions.paragraphs ?? undefined;\n body.punctuate = deepgramOptions.punctuate ?? undefined;\n body.redact = deepgramOptions.redact ?? undefined;\n body.replace = deepgramOptions.replace ?? undefined;\n body.search = deepgramOptions.search ?? undefined;\n body.sentiment = deepgramOptions.sentiment ?? undefined;\n body.smart_format = deepgramOptions.smartFormat ?? undefined;\n body.summarize = deepgramOptions.summarize ?? undefined;\n body.topics = deepgramOptions.topics ?? undefined;\n body.utterances = deepgramOptions.utterances ?? undefined;\n body.utt_split = deepgramOptions.uttSplit ?? undefined;\n }\n\n // Convert body to URL query parameters\n const queryParams = new URLSearchParams();\n for (const [key, value] of Object.entries(body)) {\n if (value !== undefined) {\n queryParams.append(key, String(value));\n }\n }\n\n return {\n queryParams,\n warnings,\n };\n }\n\n async doGenerate(\n options: Parameters<TranscriptionModelV4['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { queryParams, warnings } = await this.getArgs(options);\n\n const {\n value: response,\n responseHeaders,\n rawValue: rawResponse,\n } = await postToApi({\n url:\n this.config.url({\n path: '/v1/listen',\n modelId: this.modelId,\n }) +\n '?' +\n queryParams.toString(),\n headers: {\n ...combineHeaders(this.config.headers?.(), options.headers),\n 'Content-Type': options.mediaType,\n },\n body: {\n content: options.audio,\n values: options.audio,\n },\n failedResponseHandler: deepgramFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n deepgramTranscriptionResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n text:\n response.results?.channels.at(0)?.alternatives.at(0)?.transcript ?? '',\n segments:\n response.results?.channels[0].alternatives[0].words?.map(word => ({\n text: word.word,\n startSecond: word.start,\n endSecond: word.end,\n })) ?? [],\n language:\n response.results?.channels.at(0)?.detected_language ?? undefined,\n durationInSeconds: response.metadata?.duration ?? undefined,\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n body: rawResponse,\n },\n };\n }\n}\n\nconst deepgramTranscriptionResponseSchema = z.object({\n metadata: z\n .object({\n duration: z.number(),\n })\n .nullish(),\n results: z\n .object({\n channels: z.array(\n z.object({\n detected_language: z.string().nullish(),\n alternatives: z.array(\n z.object({\n transcript: z.string(),\n words: z.array(\n z.object({\n word: z.string(),\n start: z.number(),\n end: z.number(),\n }),\n ),\n }),\n ),\n }),\n ),\n })\n .nullish(),\n});\n","import { z } from 'zod/v4';\nimport { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';\n\n// Error shape returned by the Deepgram APIs, e.g.\n// {\"err_code\":\"INVALID_QUERY_PARAMETER\",\"err_msg\":\"Invalid 'model' value of ...\",\"request_id\":\"...\"}\nexport const deepgramErrorDataSchema = z.object({\n err_code: z.string(),\n err_msg: z.string(),\n request_id: z.string().optional(),\n});\n\nexport type DeepgramErrorData = z.infer<typeof deepgramErrorDataSchema>;\n\nexport const deepgramFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: deepgramErrorDataSchema,\n errorToMessage: data => data.err_msg,\n});\n","import { z } from 'zod/v4';\n\n// https://developers.deepgram.com/docs/pre-recorded-audio#results\nexport const deepgramTranscriptionModelOptionsSchema = z.object({\n /** Language to use for transcription. If not specified, Deepgram defaults to English. Use `detectLanguage: true` to enable automatic language detection. */\n language: z.string().nullish(),\n /** Whether to enable automatic language detection. When true, Deepgram will detect the language of the audio. */\n detectLanguage: z.boolean().nullish(),\n /** Whether to use smart formatting, which formats written-out numbers, dates, times, etc. */\n smartFormat: z.boolean().nullish(),\n /** Whether to add punctuation to the transcript. */\n punctuate: z.boolean().nullish(),\n /** Whether to format the transcript into paragraphs. */\n paragraphs: z.boolean().nullish(),\n /** Whether to generate a summary of the transcript. Use 'v2' for the latest version or false to disable. */\n summarize: z.union([z.literal('v2'), z.literal(false)]).nullish(),\n /** Whether to identify topics in the transcript. */\n topics: z.boolean().nullish(),\n /** Whether to identify intents in the transcript. */\n intents: z.boolean().nullish(),\n /** Whether to analyze sentiment in the transcript. */\n sentiment: z.boolean().nullish(),\n /** Whether to detect and tag named entities in the transcript. */\n detectEntities: z.boolean().nullish(),\n /** Specify terms or patterns to redact from the transcript. Can be a string or array of strings. */\n redact: z.union([z.string(), z.array(z.string())]).nullish(),\n /** String to replace redacted content with. */\n replace: z.string().nullish(),\n /** Term or phrase to search for in the transcript. */\n search: z.string().nullish(),\n /** Key term to identify in the transcript. */\n keyterm: z.string().nullish(),\n /** Whether to identify different speakers in the audio. */\n diarize: z.boolean().nullish(),\n /** Whether to segment the transcript into utterances. */\n utterances: z.boolean().nullish(),\n /** Minimum duration of silence (in seconds) to trigger a new utterance. */\n uttSplit: z.number().nullish(),\n /** Whether to include filler words (um, uh, etc.) in the transcript. */\n fillerWords: z.boolean().nullish(),\n});\n\nexport type DeepgramTranscriptionModelOptions = z.infer<\n typeof deepgramTranscriptionModelOptionsSchema\n>;\n","import type { SpeechModelV4, SharedV4Warning } from '@ai-sdk/provider';\nimport {\n combineHeaders,\n createBinaryResponseHandler,\n parseProviderOptions,\n postJsonToApi,\n serializeModelOptions,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n} from '@ai-sdk/provider-utils';\nimport type { DeepgramConfig } from './deepgram-config';\nimport { deepgramFailedResponseHandler } from './deepgram-error';\nimport { deepgramSpeechModelOptionsSchema } from './deepgram-speech-model-options';\nimport type { DeepgramSpeechModelId } from './deepgram-speech-options';\n\ninterface DeepgramSpeechModelConfig extends DeepgramConfig {\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\n// Deepgram embeds voice and language in the model ID\n// (`<family>-<voice>-<language>`, e.g. `aura-2-thalia-en`). Bare family IDs\n// compose the upstream model ID from the voice and language call options.\nconst VOICE_FAMILY_IDS = new Set<string>(['aura', 'aura-2']);\n\nexport class DeepgramSpeechModel implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n\n get provider(): string {\n return this.config.provider;\n }\n\n static [WORKFLOW_SERIALIZE](model: DeepgramSpeechModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: DeepgramSpeechModelId;\n config: DeepgramSpeechModelConfig;\n }) {\n return new DeepgramSpeechModel(options.modelId, options.config);\n }\n\n constructor(\n readonly modelId: DeepgramSpeechModelId,\n private readonly config: DeepgramSpeechModelConfig,\n ) {}\n\n private async getArgs({\n text,\n voice,\n outputFormat = 'mp3',\n speed,\n language,\n instructions,\n providerOptions,\n }: Parameters<SpeechModelV4['doGenerate']>[0]) {\n const warnings: SharedV4Warning[] = [];\n\n // Parse provider options\n const deepgramOptions = await parseProviderOptions({\n provider: 'deepgram',\n providerOptions,\n schema: deepgramSpeechModelOptionsSchema,\n });\n\n // Compose the upstream model ID from voice/language when a bare voice\n // family ID is used; full voice IDs (e.g. `aura-2-thalia-en`) pass through.\n let upstreamModelId: string = this.modelId;\n if (VOICE_FAMILY_IDS.has(this.modelId)) {\n const trimmedVoice = voice?.trim();\n if (!trimmedVoice) {\n throw new Error(\n `Deepgram speech model \"${this.modelId}\" requires a \\`voice\\` to be set (e.g. voice: 'thalia').`,\n );\n }\n if (language === 'auto') {\n warnings.push({\n type: 'compatibility',\n feature: 'language',\n details: `Deepgram TTS models do not support automatic language detection. Language \"en\" was used instead.`,\n });\n }\n upstreamModelId = `${this.modelId}-${trimmedVoice}-${language && language !== 'auto' ? language : 'en'}`;\n }\n\n // Create request body\n const requestBody = {\n text,\n };\n\n // Prepare query parameters\n const queryParams: Record<string, string> = {\n model: upstreamModelId,\n };\n\n // Map outputFormat to encoding/container/sample_rate\n // https://developers.deepgram.com/docs/tts-media-output-settings#audio-format-combinations\n if (outputFormat) {\n const formatLower = outputFormat.toLowerCase();\n\n // Common format mappings based on Deepgram's valid combinations\n const formatMap: Record<\n string,\n {\n encoding?: string;\n container?: string;\n sampleRate?: number;\n bitRate?: number;\n }\n > = {\n // MP3: no container, fixed 22050 sample rate, bitrate 32000/48000\n mp3: { encoding: 'mp3' }, // Don't set container or sample_rate for mp3\n // Linear16: wav/none container, configurable sample rate\n wav: { container: 'wav', encoding: 'linear16' },\n linear16: { encoding: 'linear16', container: 'wav' },\n // MuLaw: wav/none container, 8000/16000 sample rate\n mulaw: { encoding: 'mulaw', container: 'wav' },\n // ALaw: wav/none container, 8000/16000 sample rate\n alaw: { encoding: 'alaw', container: 'wav' },\n // Opus: ogg container, fixed 48000 sample rate\n opus: { encoding: 'opus', container: 'ogg' },\n ogg: { encoding: 'opus', container: 'ogg' },\n // FLAC: no container, configurable sample rate\n flac: { encoding: 'flac' },\n // AAC: no container, fixed 22050 sample rate\n aac: { encoding: 'aac' },\n // Raw audio (no container)\n pcm: { encoding: 'linear16', container: 'none' },\n };\n\n const mappedFormat = formatMap[formatLower];\n if (mappedFormat) {\n if (mappedFormat.encoding) {\n queryParams.encoding = mappedFormat.encoding;\n }\n // Only set container if specified and valid for the encoding\n if (mappedFormat.container) {\n queryParams.container = mappedFormat.container;\n }\n // Only set sample_rate if specified and valid for the encoding\n if (mappedFormat.sampleRate) {\n queryParams.sample_rate = String(mappedFormat.sampleRate);\n }\n // Set bitrate for formats that support it\n if (mappedFormat.bitRate) {\n queryParams.bit_rate = String(mappedFormat.bitRate);\n }\n } else {\n // Try to parse format like \"wav_44100\" or \"linear16_24000\"\n const parts = formatLower.split('_');\n if (parts.length >= 2) {\n const firstPart = parts[0];\n const secondPart = parts[1];\n const sampleRate = parseInt(secondPart, 10);\n\n // Check if first part is an encoding\n if (\n [\n 'linear16',\n 'mulaw',\n 'alaw',\n 'mp3',\n 'opus',\n 'flac',\n 'aac',\n ].includes(firstPart)\n ) {\n queryParams.encoding = firstPart;\n\n // Set container based on encoding\n if (['linear16', 'mulaw', 'alaw'].includes(firstPart)) {\n // These can use wav or none, default to wav\n queryParams.container = 'wav';\n } else if (firstPart === 'opus') {\n queryParams.container = 'ogg';\n }\n // mp3, flac, aac don't use container\n\n // Set sample rate if valid for encoding\n if (!isNaN(sampleRate)) {\n if (\n firstPart === 'linear16' &&\n [8000, 16000, 24000, 32000, 48000].includes(sampleRate)\n ) {\n queryParams.sample_rate = String(sampleRate);\n } else if (\n firstPart === 'mulaw' &&\n [8000, 16000].includes(sampleRate)\n ) {\n queryParams.sample_rate = String(sampleRate);\n } else if (\n firstPart === 'alaw' &&\n [8000, 16000].includes(sampleRate)\n ) {\n queryParams.sample_rate = String(sampleRate);\n } else if (\n firstPart === 'flac' &&\n [8000, 16000, 22050, 32000, 48000].includes(sampleRate)\n ) {\n queryParams.sample_rate = String(sampleRate);\n }\n // mp3, opus, aac have fixed sample rates, don't set\n }\n } else if (['wav', 'ogg'].includes(firstPart)) {\n // First part is container\n if (firstPart === 'wav') {\n queryParams.container = 'wav';\n queryParams.encoding = 'linear16'; // Default encoding for wav\n } else if (firstPart === 'ogg') {\n queryParams.container = 'ogg';\n queryParams.encoding = 'opus'; // Default encoding for ogg\n }\n if (!isNaN(sampleRate)) {\n queryParams.sample_rate = String(sampleRate);\n }\n }\n }\n }\n }\n\n // Add provider-specific options - map camelCase to snake_case\n // Validate combinations according to Deepgram's spec\n if (deepgramOptions) {\n if (deepgramOptions.encoding) {\n const newEncoding = deepgramOptions.encoding.toLowerCase();\n\n // If encoding changes, we may need to clear incompatible parameters\n queryParams.encoding = newEncoding;\n\n // Validate container based on encoding\n if (deepgramOptions.container) {\n // Validate container is valid for this encoding\n if (['linear16', 'mulaw', 'alaw'].includes(newEncoding)) {\n if (\n !['wav', 'none'].includes(deepgramOptions.container.toLowerCase())\n ) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"${newEncoding}\" only supports containers \"wav\" or \"none\". Container \"${deepgramOptions.container}\" was ignored.`,\n });\n } else {\n queryParams.container = deepgramOptions.container.toLowerCase();\n }\n } else if (newEncoding === 'opus') {\n // opus requires ogg container, override any previous container setting\n queryParams.container = 'ogg';\n } else if (['mp3', 'flac', 'aac'].includes(newEncoding)) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"${newEncoding}\" does not support container parameter. Container \"${deepgramOptions.container}\" was ignored.`,\n });\n // Remove container if it was set by outputFormat\n delete queryParams.container;\n }\n } else {\n // No container specified in providerOptions\n // If encoding changed to one that doesn't support container, remove it\n if (['mp3', 'flac', 'aac'].includes(newEncoding)) {\n delete queryParams.container;\n } else if (['linear16', 'mulaw', 'alaw'].includes(newEncoding)) {\n // Set default container if not already set\n if (!queryParams.container) {\n queryParams.container = 'wav'; // Default for these encodings\n }\n } else if (newEncoding === 'opus') {\n // opus requires ogg container, override any previous container setting\n queryParams.container = 'ogg';\n }\n }\n\n // Clean up sample_rate and bit_rate if they're incompatible with the new encoding\n // Fixed sample rate encodings (mp3, opus, aac) don't support sample_rate parameter\n if (['mp3', 'opus', 'aac'].includes(newEncoding)) {\n delete queryParams.sample_rate;\n }\n // Lossless encodings without bitrate support (linear16, mulaw, alaw, flac) don't support bit_rate\n if (['linear16', 'mulaw', 'alaw', 'flac'].includes(newEncoding)) {\n delete queryParams.bit_rate;\n }\n } else if (deepgramOptions.container) {\n // Container specified without encoding - set default encoding\n const container = deepgramOptions.container.toLowerCase();\n const oldEncoding = queryParams.encoding?.toLowerCase();\n let newEncoding: string | undefined;\n\n if (container === 'wav') {\n queryParams.container = 'wav';\n newEncoding = 'linear16'; // Default encoding for wav\n } else if (container === 'ogg') {\n queryParams.container = 'ogg';\n newEncoding = 'opus'; // Default encoding for ogg\n } else if (container === 'none') {\n queryParams.container = 'none';\n newEncoding = 'linear16'; // Default encoding for raw audio\n }\n\n // If encoding changed, clean up incompatible parameters\n if (newEncoding && newEncoding !== oldEncoding) {\n queryParams.encoding = newEncoding;\n // Clean up sample_rate and bit_rate if they're incompatible with the new encoding\n if (['mp3', 'opus', 'aac'].includes(newEncoding)) {\n delete queryParams.sample_rate;\n }\n if (['linear16', 'mulaw', 'alaw', 'flac'].includes(newEncoding)) {\n delete queryParams.bit_rate;\n }\n }\n }\n\n if (deepgramOptions.sampleRate != null) {\n const encoding = queryParams.encoding?.toLowerCase() || '';\n const sampleRate = deepgramOptions.sampleRate;\n\n // Validate sample rate based on encoding\n if (encoding === 'linear16') {\n if (![8000, 16000, 24000, 32000, 48000].includes(sampleRate)) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"linear16\" only supports sample rates: 8000, 16000, 24000, 32000, 48000. Sample rate ${sampleRate} was ignored.`,\n });\n } else {\n queryParams.sample_rate = String(sampleRate);\n }\n } else if (encoding === 'mulaw' || encoding === 'alaw') {\n if (![8000, 16000].includes(sampleRate)) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"${encoding}\" only supports sample rates: 8000, 16000. Sample rate ${sampleRate} was ignored.`,\n });\n } else {\n queryParams.sample_rate = String(sampleRate);\n }\n } else if (encoding === 'flac') {\n if (![8000, 16000, 22050, 32000, 48000].includes(sampleRate)) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"flac\" only supports sample rates: 8000, 16000, 22050, 32000, 48000. Sample rate ${sampleRate} was ignored.`,\n });\n } else {\n queryParams.sample_rate = String(sampleRate);\n }\n } else if (['mp3', 'opus', 'aac'].includes(encoding)) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"${encoding}\" has a fixed sample rate and does not support sample_rate parameter. Sample rate ${sampleRate} was ignored.`,\n });\n } else {\n // No encoding set yet, allow it (will be validated when encoding is set)\n queryParams.sample_rate = String(sampleRate);\n }\n }\n\n if (deepgramOptions.bitRate != null) {\n const encoding = queryParams.encoding?.toLowerCase() || '';\n const bitRate = deepgramOptions.bitRate;\n\n // Validate bitrate based on encoding\n if (encoding === 'mp3') {\n if (![32000, 48000].includes(Number(bitRate))) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"mp3\" only supports bit rates: 32000, 48000. Bit rate ${bitRate} was ignored.`,\n });\n } else {\n queryParams.bit_rate = String(bitRate);\n }\n } else if (encoding === 'opus') {\n const bitRateNum = Number(bitRate);\n if (bitRateNum < 4000 || bitRateNum > 650000) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"opus\" supports bit rates between 4000 and 650000. Bit rate ${bitRate} was ignored.`,\n });\n } else {\n queryParams.bit_rate = String(bitRate);\n }\n } else if (encoding === 'aac') {\n const bitRateNum = Number(bitRate);\n if (bitRateNum < 4000 || bitRateNum > 192000) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"aac\" supports bit rates between 4000 and 192000. Bit rate ${bitRate} was ignored.`,\n });\n } else {\n queryParams.bit_rate = String(bitRate);\n }\n } else if (['linear16', 'mulaw', 'alaw', 'flac'].includes(encoding)) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions',\n details: `Encoding \"${encoding}\" does not support bit_rate parameter. Bit rate ${bitRate} was ignored.`,\n });\n } else {\n // No encoding set yet, allow it\n queryParams.bit_rate = String(bitRate);\n }\n }\n\n if (deepgramOptions.callback) {\n queryParams.callback = deepgramOptions.callback;\n }\n if (deepgramOptions.callbackMethod) {\n queryParams.callback_method = deepgramOptions.callbackMethod;\n }\n if (deepgramOptions.mipOptOut != null) {\n queryParams.mip_opt_out = String(deepgramOptions.mipOptOut);\n }\n if (deepgramOptions.tag) {\n if (Array.isArray(deepgramOptions.tag)) {\n queryParams.tag = deepgramOptions.tag.join(',');\n } else {\n queryParams.tag = deepgramOptions.tag;\n }\n }\n }\n\n // Handle voice parameter - only relevant for full voice model IDs, where\n // the voice is embedded in the model ID and a voice param cannot compose.\n if (upstreamModelId === this.modelId && voice && voice !== this.modelId) {\n warnings.push({\n type: 'unsupported',\n feature: 'voice',\n details: `Deepgram TTS models embed the voice in the model ID. The voice parameter \"${voice}\" was ignored. Use the model ID to select a voice (e.g., \"aura-2-helena-en\").`,\n });\n }\n\n // Map speed to Deepgram's speed query parameter. Deepgram does not\n // support it for all languages and validates the value upstream.\n if (speed != null) {\n queryParams.speed = String(speed);\n }\n\n // Handle language - full voice model IDs are already language-specific;\n // language was already consumed when composing from a voice family ID.\n if (upstreamModelId === this.modelId && language) {\n warnings.push({\n type: 'unsupported',\n feature: 'language',\n details: `Deepgram TTS models are language-specific via the model ID. Language parameter \"${language}\" was ignored. Select a model with the appropriate language suffix (e.g., \"-en\" for English).`,\n });\n }\n\n // Handle instructions - not supported in Deepgram REST API\n if (instructions) {\n warnings.push({\n type: 'unsupported',\n feature: 'instructions',\n details: `Deepgram TTS REST API does not support instructions. Instructions parameter was ignored.`,\n });\n }\n\n return {\n requestBody,\n queryParams,\n warnings,\n };\n }\n\n async doGenerate(\n options: Parameters<SpeechModelV4['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<SpeechModelV4['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { requestBody, queryParams, warnings } = await this.getArgs(options);\n\n const {\n value: audio,\n responseHeaders,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url: (() => {\n const baseUrl = this.config.url({\n path: '/v1/speak',\n modelId: this.modelId,\n });\n const queryString = new URLSearchParams(queryParams).toString();\n return queryString ? `${baseUrl}?${queryString}` : baseUrl;\n })(),\n headers: combineHeaders(this.config.headers?.(), options.headers),\n body: requestBody,\n failedResponseHandler: deepgramFailedResponseHandler,\n successfulResponseHandler: createBinaryResponseHandler(),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n // Deepgram returns usage and model details in response headers\n // (dg-project-id deliberately excluded: account identifier).\n const headerNumber = (name: string): number | undefined => {\n const value = responseHeaders?.[name];\n if (value == null) {\n return undefined;\n }\n const parsed = Number(value);\n return Number.isNaN(parsed) ? undefined : parsed;\n };\n const charCount = headerNumber('dg-char-count');\n const breaksApplied = headerNumber('dg-breaks-applied');\n const pronunciationsApplied = headerNumber('dg-pronunciations-applied');\n const additionalModelUuids =\n responseHeaders?.['dg-additional-model-uuids']?.split(',');\n\n return {\n audio,\n warnings,\n request: {\n body: JSON.stringify(requestBody),\n },\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n body: rawResponse,\n },\n providerMetadata: {\n deepgram: {\n ...(responseHeaders?.['dg-model-name']\n ? { modelName: responseHeaders['dg-model-name'] }\n : {}),\n ...(responseHeaders?.['dg-model-uuid']\n ? { modelUuid: responseHeaders['dg-model-uuid'] }\n : {}),\n ...(additionalModelUuids ? { additionalModelUuids } : {}),\n ...(charCount != null ? { charCount } : {}),\n ...(breaksApplied != null ? { breaksApplied } : {}),\n ...(pronunciationsApplied != null ? { pronunciationsApplied } : {}),\n ...(responseHeaders?.['dg-pronunciation-warnings']\n ? {\n pronunciationWarnings:\n responseHeaders['dg-pronunciation-warnings'],\n }\n : {}),\n ...(responseHeaders?.['dg-request-id']\n ? { requestId: responseHeaders['dg-request-id'] }\n : {}),\n },\n },\n };\n }\n}\n","import { z } from 'zod/v4';\n\n// https://developers.deepgram.com/reference/text-to-speech/speak-request\nexport const deepgramSpeechModelOptionsSchema = z.object({\n /** Bitrate of the audio in bits per second. Can be a number or predefined enum value. */\n bitRate: z.union([z.number(), z.string()]).nullish(),\n /** Container format for the output audio (mp3, wav, etc.). */\n container: z.string().nullish(),\n /** Encoding type for the audio output (linear16, mulaw, alaw, etc.). */\n encoding: z.string().nullish(),\n /** Sample rate for the output audio in Hz (8000, 16000, 24000, 44100, 48000). */\n sampleRate: z.number().nullish(),\n /** URL to which we'll make the callback request. */\n callback: z.string().url().nullish(),\n /** HTTP method by which the callback request will be made (POST or PUT). */\n callbackMethod: z.enum(['POST', 'PUT']).nullish(),\n /** Opts out requests from the Deepgram Model Improvement Program. */\n mipOptOut: z.boolean().nullish(),\n /** Label your requests for the purpose of identification during usage reporting. */\n tag: z.union([z.string(), z.array(z.string())]).nullish(),\n});\n\nexport type DeepgramSpeechModelOptions = z.infer<\n typeof deepgramSpeechModelOptionsSchema\n>;\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACK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AM,WAAW,SAAU,SAAuC;AAChE,WAAO;AAAA,MACL,eAAe,yBAAyB,OAAO;AAAA,IACjD;AAAA,EACF;AAEA,WAAS,uBAAuB;AAChC,WAAS,gBAAgB;AACzB,WAAS,qBAAqB;AAC9B,WAAS,SAAS;AAClB,WAAS,cAAc;AAGvB,WAAS,gBAAgB,CAAC,YAAoB;AAC5C,UAAM,IAAI,iBAAiB;AAAA,MACzB;AAAA,MACA,WAAW;AAAA,MACX,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,WAAS,iBAAiB,CAAC,YAAoB;AAC7C,UAAM,IAAI,iBAAiB;AAAA,MACzB;AAAA,MACA,WAAW;AAAA,MACX,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACA,WAAS,qBAAqB,SAAS;AAEvC,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iBAAiB;AAAA,MACzB;AAAA,MACA,WAAW;AAAA,MACX,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAKO,IAAM,WAAW,eAAe;","names":["z","z","z","combineHeaders","parseProviderOptions","serializeModelOptions","WORKFLOW_SERIALIZE","WORKFLOW_DESERIALIZE","z","WORKFLOW_SERIALIZE","serializeModelOptions","WORKFLOW_DESERIALIZE","parseProviderOptions","combineHeaders"]}
|
package/docs/110-deepgram.mdx
CHANGED
|
@@ -55,24 +55,30 @@ You can use the following optional settings to customize the Deepgram provider i
|
|
|
55
55
|
You can create models that call the [Deepgram text-to-speech API](https://developers.deepgram.com/docs/text-to-speech)
|
|
56
56
|
using the `.speech()` factory method.
|
|
57
57
|
|
|
58
|
-
The first argument is the
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
You can use the model with the `generateSpeech` function:
|
|
58
|
+
The first argument is the voice family ID: `aura-2` (current generation) or
|
|
59
|
+
`aura` (Aura-1). The voice and language are selected with the
|
|
60
|
+
`generateSpeech` `voice` and `language` options — the provider composes the
|
|
61
|
+
upstream Deepgram model ID as `<family>-<voice>-<language>` (language
|
|
62
|
+
defaults to `en`):
|
|
65
63
|
|
|
66
64
|
```ts
|
|
67
65
|
import { generateSpeech } from 'ai';
|
|
68
66
|
import { deepgram } from '@ai-sdk/deepgram';
|
|
69
67
|
|
|
70
68
|
const result = await generateSpeech({
|
|
71
|
-
model: deepgram.speech('aura-2
|
|
69
|
+
model: deepgram.speech('aura-2'),
|
|
70
|
+
voice: 'thalia',
|
|
71
|
+
language: 'en',
|
|
72
72
|
text: 'Hello, world!',
|
|
73
73
|
});
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
+
<Note>
|
|
77
|
+
Full voice model IDs (e.g. `deepgram.speech('aura-2-helena-en')`) still pass
|
|
78
|
+
through, but the family ID + `voice`/`language` form above is the recommended
|
|
79
|
+
path — it matches voice selection in the other speech providers.
|
|
80
|
+
</Note>
|
|
81
|
+
|
|
76
82
|
You can also pass additional provider-specific options using the `providerOptions` argument:
|
|
77
83
|
|
|
78
84
|
```ts highlight="7-11"
|
|
@@ -80,7 +86,8 @@ import { generateSpeech } from 'ai';
|
|
|
80
86
|
import { deepgram, type DeepgramSpeechModelOptions } from '@ai-sdk/deepgram';
|
|
81
87
|
|
|
82
88
|
const result = await generateSpeech({
|
|
83
|
-
model: deepgram.speech('aura-2
|
|
89
|
+
model: deepgram.speech('aura-2'),
|
|
90
|
+
voice: 'helena',
|
|
84
91
|
text: 'Hello, world!',
|
|
85
92
|
providerOptions: {
|
|
86
93
|
deepgram: {
|
|
@@ -140,19 +147,26 @@ The following provider options are available:
|
|
|
140
147
|
Label your requests for identification during usage reporting.
|
|
141
148
|
Optional.
|
|
142
149
|
|
|
150
|
+
Speech results include Deepgram response details in
|
|
151
|
+
`providerMetadata.deepgram`: `modelName` (the resolved upstream model),
|
|
152
|
+
`modelUuid`, `additionalModelUuids`, `charCount` (the billed character
|
|
153
|
+
count), `breaksApplied`, `pronunciationsApplied`,
|
|
154
|
+
`pronunciationWarnings` (when present), and `requestId`.
|
|
155
|
+
|
|
156
|
+
The `generateSpeech` `speed` option is passed through to Deepgram's `speed`
|
|
157
|
+
parameter. Deepgram accepts speeds in the 0.7–1.5 range and rejects
|
|
158
|
+
out-of-range values with a 400 error; speed is not supported for all
|
|
159
|
+
languages. `instructions` is not supported and is ignored with a warning.
|
|
160
|
+
|
|
143
161
|
### Model Capabilities
|
|
144
162
|
|
|
145
|
-
|
|
|
146
|
-
|
|
|
147
|
-
| `aura-2
|
|
148
|
-
| `aura
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
| `aura-asteria-en` |
|
|
153
|
-
| `aura-luna-en` |
|
|
154
|
-
| `aura-stella-en` |
|
|
155
|
-
| [+ more voices](https://developers.deepgram.com/docs/tts-models) |
|
|
163
|
+
| Family | Voices (selected via the `voice` option) |
|
|
164
|
+
| -------- | --------------------------------------------------------------------------- |
|
|
165
|
+
| `aura-2` | 41 English, 17 Spanish, 9 Dutch, 7 German, 10 Italian, 5 Japanese, 2 French |
|
|
166
|
+
| `aura` | 12 English (Aura-1) |
|
|
167
|
+
|
|
168
|
+
See the [full voice list](https://developers.deepgram.com/docs/tts-models)
|
|
169
|
+
for all voice names and accents.
|
|
156
170
|
|
|
157
171
|
## Transcription Models
|
|
158
172
|
|
|
@@ -239,7 +253,8 @@ The following provider options are available:
|
|
|
239
253
|
- **diarize** _boolean_
|
|
240
254
|
|
|
241
255
|
Whether to identify different speakers in the transcription.
|
|
242
|
-
Defaults to `
|
|
256
|
+
Defaults to `false`. Note that Deepgram bills speaker diarization as a
|
|
257
|
+
per-minute add-on.
|
|
243
258
|
Optional.
|
|
244
259
|
|
|
245
260
|
- **utterances** _boolean_
|
|
@@ -257,6 +272,31 @@ The following provider options are available:
|
|
|
257
272
|
Whether to include filler words (um, uh, etc.) in the transcription.
|
|
258
273
|
Optional.
|
|
259
274
|
|
|
275
|
+
- **paragraphs** _boolean_
|
|
276
|
+
|
|
277
|
+
Whether to format the transcription into paragraphs.
|
|
278
|
+
Optional.
|
|
279
|
+
|
|
280
|
+
- **intents** _boolean_
|
|
281
|
+
|
|
282
|
+
Whether to detect intents in the transcription.
|
|
283
|
+
Optional.
|
|
284
|
+
|
|
285
|
+
- **sentiment** _boolean_
|
|
286
|
+
|
|
287
|
+
Whether to analyze sentiment in the transcription.
|
|
288
|
+
Optional.
|
|
289
|
+
|
|
290
|
+
- **keyterm** _string_
|
|
291
|
+
|
|
292
|
+
Key term to improve recognition accuracy for.
|
|
293
|
+
Optional.
|
|
294
|
+
|
|
295
|
+
- **replace** _string_
|
|
296
|
+
|
|
297
|
+
String to replace redacted content with.
|
|
298
|
+
Optional.
|
|
299
|
+
|
|
260
300
|
### Model Capabilities
|
|
261
301
|
|
|
262
302
|
| Model | Transcription | Duration | Segments | Language |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/deepgram",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ai-sdk/provider": "
|
|
33
|
-
"@ai-sdk/provider
|
|
32
|
+
"@ai-sdk/provider-utils": "5.0.29",
|
|
33
|
+
"@ai-sdk/provider": "4.0.7"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "22.19.19",
|
package/src/deepgram-error.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { z } from 'zod/v4';
|
|
2
2
|
import { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';
|
|
3
3
|
|
|
4
|
+
// Error shape returned by the Deepgram APIs, e.g.
|
|
5
|
+
// {"err_code":"INVALID_QUERY_PARAMETER","err_msg":"Invalid 'model' value of ...","request_id":"..."}
|
|
4
6
|
export const deepgramErrorDataSchema = z.object({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}),
|
|
7
|
+
err_code: z.string(),
|
|
8
|
+
err_msg: z.string(),
|
|
9
|
+
request_id: z.string().optional(),
|
|
9
10
|
});
|
|
10
11
|
|
|
11
12
|
export type DeepgramErrorData = z.infer<typeof deepgramErrorDataSchema>;
|
|
12
13
|
|
|
13
14
|
export const deepgramFailedResponseHandler = createJsonErrorResponseHandler({
|
|
14
15
|
errorSchema: deepgramErrorDataSchema,
|
|
15
|
-
errorToMessage: data => data.
|
|
16
|
+
errorToMessage: data => data.err_msg,
|
|
16
17
|
});
|
package/src/deepgram-provider.ts
CHANGED
|
@@ -19,6 +19,11 @@ interface DeepgramSpeechModelConfig extends DeepgramConfig {
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
// Deepgram embeds voice and language in the model ID
|
|
23
|
+
// (`<family>-<voice>-<language>`, e.g. `aura-2-thalia-en`). Bare family IDs
|
|
24
|
+
// compose the upstream model ID from the voice and language call options.
|
|
25
|
+
const VOICE_FAMILY_IDS = new Set<string>(['aura', 'aura-2']);
|
|
26
|
+
|
|
22
27
|
export class DeepgramSpeechModel implements SpeechModelV4 {
|
|
23
28
|
readonly specificationVersion = 'v4';
|
|
24
29
|
|
|
@@ -63,6 +68,26 @@ export class DeepgramSpeechModel implements SpeechModelV4 {
|
|
|
63
68
|
schema: deepgramSpeechModelOptionsSchema,
|
|
64
69
|
});
|
|
65
70
|
|
|
71
|
+
// Compose the upstream model ID from voice/language when a bare voice
|
|
72
|
+
// family ID is used; full voice IDs (e.g. `aura-2-thalia-en`) pass through.
|
|
73
|
+
let upstreamModelId: string = this.modelId;
|
|
74
|
+
if (VOICE_FAMILY_IDS.has(this.modelId)) {
|
|
75
|
+
const trimmedVoice = voice?.trim();
|
|
76
|
+
if (!trimmedVoice) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
`Deepgram speech model "${this.modelId}" requires a \`voice\` to be set (e.g. voice: 'thalia').`,
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
if (language === 'auto') {
|
|
82
|
+
warnings.push({
|
|
83
|
+
type: 'compatibility',
|
|
84
|
+
feature: 'language',
|
|
85
|
+
details: `Deepgram TTS models do not support automatic language detection. Language "en" was used instead.`,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
upstreamModelId = `${this.modelId}-${trimmedVoice}-${language && language !== 'auto' ? language : 'en'}`;
|
|
89
|
+
}
|
|
90
|
+
|
|
66
91
|
// Create request body
|
|
67
92
|
const requestBody = {
|
|
68
93
|
text,
|
|
@@ -70,7 +95,7 @@ export class DeepgramSpeechModel implements SpeechModelV4 {
|
|
|
70
95
|
|
|
71
96
|
// Prepare query parameters
|
|
72
97
|
const queryParams: Record<string, string> = {
|
|
73
|
-
model:
|
|
98
|
+
model: upstreamModelId,
|
|
74
99
|
};
|
|
75
100
|
|
|
76
101
|
// Map outputFormat to encoding/container/sample_rate
|
|
@@ -403,9 +428,9 @@ export class DeepgramSpeechModel implements SpeechModelV4 {
|
|
|
403
428
|
}
|
|
404
429
|
}
|
|
405
430
|
|
|
406
|
-
// Handle voice parameter -
|
|
407
|
-
//
|
|
408
|
-
if (voice && voice !== this.modelId) {
|
|
431
|
+
// Handle voice parameter - only relevant for full voice model IDs, where
|
|
432
|
+
// the voice is embedded in the model ID and a voice param cannot compose.
|
|
433
|
+
if (upstreamModelId === this.modelId && voice && voice !== this.modelId) {
|
|
409
434
|
warnings.push({
|
|
410
435
|
type: 'unsupported',
|
|
411
436
|
feature: 'voice',
|
|
@@ -413,17 +438,15 @@ export class DeepgramSpeechModel implements SpeechModelV4 {
|
|
|
413
438
|
});
|
|
414
439
|
}
|
|
415
440
|
|
|
416
|
-
//
|
|
441
|
+
// Map speed to Deepgram's speed query parameter. Deepgram does not
|
|
442
|
+
// support it for all languages and validates the value upstream.
|
|
417
443
|
if (speed != null) {
|
|
418
|
-
|
|
419
|
-
type: 'unsupported',
|
|
420
|
-
feature: 'speed',
|
|
421
|
-
details: `Deepgram TTS REST API does not support speed adjustment. Speed parameter was ignored.`,
|
|
422
|
-
});
|
|
444
|
+
queryParams.speed = String(speed);
|
|
423
445
|
}
|
|
424
446
|
|
|
425
|
-
// Handle language -
|
|
426
|
-
|
|
447
|
+
// Handle language - full voice model IDs are already language-specific;
|
|
448
|
+
// language was already consumed when composing from a voice family ID.
|
|
449
|
+
if (upstreamModelId === this.modelId && language) {
|
|
427
450
|
warnings.push({
|
|
428
451
|
type: 'unsupported',
|
|
429
452
|
feature: 'language',
|
|
@@ -474,6 +497,22 @@ export class DeepgramSpeechModel implements SpeechModelV4 {
|
|
|
474
497
|
fetch: this.config.fetch,
|
|
475
498
|
});
|
|
476
499
|
|
|
500
|
+
// Deepgram returns usage and model details in response headers
|
|
501
|
+
// (dg-project-id deliberately excluded: account identifier).
|
|
502
|
+
const headerNumber = (name: string): number | undefined => {
|
|
503
|
+
const value = responseHeaders?.[name];
|
|
504
|
+
if (value == null) {
|
|
505
|
+
return undefined;
|
|
506
|
+
}
|
|
507
|
+
const parsed = Number(value);
|
|
508
|
+
return Number.isNaN(parsed) ? undefined : parsed;
|
|
509
|
+
};
|
|
510
|
+
const charCount = headerNumber('dg-char-count');
|
|
511
|
+
const breaksApplied = headerNumber('dg-breaks-applied');
|
|
512
|
+
const pronunciationsApplied = headerNumber('dg-pronunciations-applied');
|
|
513
|
+
const additionalModelUuids =
|
|
514
|
+
responseHeaders?.['dg-additional-model-uuids']?.split(',');
|
|
515
|
+
|
|
477
516
|
return {
|
|
478
517
|
audio,
|
|
479
518
|
warnings,
|
|
@@ -486,6 +525,29 @@ export class DeepgramSpeechModel implements SpeechModelV4 {
|
|
|
486
525
|
headers: responseHeaders,
|
|
487
526
|
body: rawResponse,
|
|
488
527
|
},
|
|
528
|
+
providerMetadata: {
|
|
529
|
+
deepgram: {
|
|
530
|
+
...(responseHeaders?.['dg-model-name']
|
|
531
|
+
? { modelName: responseHeaders['dg-model-name'] }
|
|
532
|
+
: {}),
|
|
533
|
+
...(responseHeaders?.['dg-model-uuid']
|
|
534
|
+
? { modelUuid: responseHeaders['dg-model-uuid'] }
|
|
535
|
+
: {}),
|
|
536
|
+
...(additionalModelUuids ? { additionalModelUuids } : {}),
|
|
537
|
+
...(charCount != null ? { charCount } : {}),
|
|
538
|
+
...(breaksApplied != null ? { breaksApplied } : {}),
|
|
539
|
+
...(pronunciationsApplied != null ? { pronunciationsApplied } : {}),
|
|
540
|
+
...(responseHeaders?.['dg-pronunciation-warnings']
|
|
541
|
+
? {
|
|
542
|
+
pronunciationWarnings:
|
|
543
|
+
responseHeaders['dg-pronunciation-warnings'],
|
|
544
|
+
}
|
|
545
|
+
: {}),
|
|
546
|
+
...(responseHeaders?.['dg-request-id']
|
|
547
|
+
? { requestId: responseHeaders['dg-request-id'] }
|
|
548
|
+
: {}),
|
|
549
|
+
},
|
|
550
|
+
},
|
|
489
551
|
};
|
|
490
552
|
}
|
|
491
553
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
| 'aura-2-zeus-en'
|
|
8
|
-
| 'aura-luna-en'
|
|
9
|
-
| 'aura-stella-en'
|
|
10
|
-
| (string & {});
|
|
1
|
+
// Deepgram TTS voices are addressed by voice family; the upstream model ID
|
|
2
|
+
// is composed from the family, the `voice` option, and the `language`
|
|
3
|
+
// option (`<family>-<voice>-<language>`, e.g. 'aura-2' + 'thalia' + 'en' →
|
|
4
|
+
// 'aura-2-thalia-en'). Full voice list:
|
|
5
|
+
// https://developers.deepgram.com/docs/tts-models
|
|
6
|
+
export type DeepgramSpeechModelId = 'aura' | 'aura-2' | (string & {});
|
|
@@ -61,27 +61,28 @@ export class DeepgramTranscriptionModel implements TranscriptionModelV4 {
|
|
|
61
61
|
|
|
62
62
|
const body: DeepgramTranscriptionAPITypes = {
|
|
63
63
|
model: this.modelId,
|
|
64
|
-
diarize: true,
|
|
65
64
|
};
|
|
66
65
|
|
|
67
66
|
// Add provider-specific options
|
|
68
67
|
if (deepgramOptions) {
|
|
69
68
|
body.detect_entities = deepgramOptions.detectEntities ?? undefined;
|
|
70
69
|
body.detect_language = deepgramOptions.detectLanguage ?? undefined;
|
|
70
|
+
body.diarize = deepgramOptions.diarize ?? undefined;
|
|
71
71
|
body.filler_words = deepgramOptions.fillerWords ?? undefined;
|
|
72
|
+
body.intents = deepgramOptions.intents ?? undefined;
|
|
73
|
+
body.keyterm = deepgramOptions.keyterm ?? undefined;
|
|
72
74
|
body.language = deepgramOptions.language ?? undefined;
|
|
75
|
+
body.paragraphs = deepgramOptions.paragraphs ?? undefined;
|
|
73
76
|
body.punctuate = deepgramOptions.punctuate ?? undefined;
|
|
74
77
|
body.redact = deepgramOptions.redact ?? undefined;
|
|
78
|
+
body.replace = deepgramOptions.replace ?? undefined;
|
|
75
79
|
body.search = deepgramOptions.search ?? undefined;
|
|
80
|
+
body.sentiment = deepgramOptions.sentiment ?? undefined;
|
|
76
81
|
body.smart_format = deepgramOptions.smartFormat ?? undefined;
|
|
77
82
|
body.summarize = deepgramOptions.summarize ?? undefined;
|
|
78
83
|
body.topics = deepgramOptions.topics ?? undefined;
|
|
79
84
|
body.utterances = deepgramOptions.utterances ?? undefined;
|
|
80
85
|
body.utt_split = deepgramOptions.uttSplit ?? undefined;
|
|
81
|
-
|
|
82
|
-
if (typeof deepgramOptions.diarize === 'boolean') {
|
|
83
|
-
body.diarize = deepgramOptions.diarize;
|
|
84
|
-
}
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
// Convert body to URL query parameters
|