@ai-sdk/hume 3.0.71 → 3.0.73
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 +23 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/docs/150-hume.mdx +4 -1
- package/package.json +3 -3
- package/src/hume-config.ts +2 -2
- package/src/hume-provider.ts +17 -12
- package/src/hume-speech-model.ts +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @ai-sdk/hume
|
|
2
2
|
|
|
3
|
+
## 3.0.73
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [51ca5b7]
|
|
8
|
+
- Updated dependencies [dc6f1c3]
|
|
9
|
+
- Updated dependencies [4ae6986]
|
|
10
|
+
- @ai-sdk/provider-utils@5.0.73
|
|
11
|
+
|
|
12
|
+
## 3.0.72
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 7716e18: Support promises and synchronous or asynchronous callbacks in provider API key and token settings. Resolve credentials per authenticated request while preserving existing authentication behavior and synchronous credential serialization.
|
|
17
|
+
|
|
18
|
+
The experimental OpenAI Live `getServerWebSocketConfig()` method can now resolve asynchronously. Await its result before using the connection settings.
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [7716e18]
|
|
21
|
+
- Updated dependencies [5c247e9]
|
|
22
|
+
- Updated dependencies [dcd2f8d]
|
|
23
|
+
- @ai-sdk/provider-utils@5.0.72
|
|
24
|
+
- @ai-sdk/provider@4.0.35
|
|
25
|
+
|
|
3
26
|
## 3.0.71
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProviderV4, SpeechModelV4 } from "@ai-sdk/provider";
|
|
2
|
-
import { FetchFunction, InferSchema, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE } from "@ai-sdk/provider-utils";
|
|
2
|
+
import { FetchFunction, InferSchema, Resolvable, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE } from "@ai-sdk/provider-utils";
|
|
3
3
|
//#region src/hume-config.d.ts
|
|
4
4
|
type HumeConfig = {
|
|
5
5
|
provider: string;
|
|
@@ -7,7 +7,7 @@ type HumeConfig = {
|
|
|
7
7
|
modelId: string;
|
|
8
8
|
path: string;
|
|
9
9
|
}) => string;
|
|
10
|
-
headers?:
|
|
10
|
+
headers?: Resolvable<Record<string, string | undefined>>;
|
|
11
11
|
fetch?: FetchFunction;
|
|
12
12
|
generateId?: () => string;
|
|
13
13
|
};
|
|
@@ -48,9 +48,10 @@ interface HumeProvider extends ProviderV4 {
|
|
|
48
48
|
}
|
|
49
49
|
interface HumeProviderSettings {
|
|
50
50
|
/**
|
|
51
|
-
* API key for authenticating requests.
|
|
51
|
+
* API key for authenticating requests. May be a string, promise, or a
|
|
52
|
+
* synchronous/asynchronous callback called before each request.
|
|
52
53
|
*/
|
|
53
|
-
apiKey?: string
|
|
54
|
+
apiKey?: Resolvable<string>;
|
|
54
55
|
/**
|
|
55
56
|
* Custom headers to include in the requests.
|
|
56
57
|
*/
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/hume-config.ts","../src/hume-speech-model.ts","../src/hume-provider.ts","../src/hume-speech-model-options.ts","../src/version.ts"],"mappings":";;;KAEY;EACV;EACA,MAAM;IAAW;IAAiB;;EAClC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/hume-config.ts","../src/hume-speech-model.ts","../src/hume-provider.ts","../src/hume-speech-model-options.ts","../src/version.ts"],"mappings":";;;KAEY;EACV;EACA,MAAM;IAAW;IAAiB;;EAClC,UAAU,WAAW;EACrB,QAAQ;EACR;;;;UCSQ,8BAA8B;EACtC;IACE,oBAAoB;;;cAIX,2BAA2B;WAsB3B;mBACQ;WAtBV;MAEL;UAII,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B;IACA,QAAQ;MACT;EAKU,YAAA,aACQ,QAAQ;UAGb;EAgGR,WACJ,SAAS,WAAW,kCACnB,QAAQ,QAAQ,WAAW;;;;UCnIf,qBAAqB;GACnC;IACC,QAAQ;;;;;EAMV,UAAU;;UAGK;;;;;EAKf,SAAS;;;;EAKT,UAAU;;;;;EAMV,QAAQ;;;;;wBAMM,WAAW,UAAS,uBAA4B;;;;qBAgEnD,MAAI;;;cCxGJ,+DAA4B;;;;;;;;;;;;;;;;;;;KA2E7B,yBAAyB,mBAC5B;;;qBClFI"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NoSuchModelError } from "@ai-sdk/provider";
|
|
2
|
-
import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, createBinaryResponseHandler, createJsonErrorResponseHandler, lazySchema, loadApiKey, parseProviderOptions, postJsonToApi, serializeModelOptions, withUserAgentSuffix, zodSchema } from "@ai-sdk/provider-utils";
|
|
2
|
+
import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, createBinaryResponseHandler, createJsonErrorResponseHandler, lazySchema, loadApiKey, parseProviderOptions, postJsonToApi, resolve, resolveWith, serializeModelOptions, withUserAgentSuffix, zodSchema } from "@ai-sdk/provider-utils";
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
4
|
//#region src/hume-error.ts
|
|
5
5
|
const humeErrorDataSchema = lazySchema(() => zodSchema(z.object({ error: z.object({
|
|
@@ -153,7 +153,7 @@ var HumeSpeechModel = class HumeSpeechModel {
|
|
|
153
153
|
path: "/v0/tts/file",
|
|
154
154
|
modelId: this.modelId
|
|
155
155
|
}),
|
|
156
|
-
headers: combineHeaders(this.config.headers
|
|
156
|
+
headers: combineHeaders(await resolve(this.config.headers), options.headers),
|
|
157
157
|
body: requestBody,
|
|
158
158
|
failedResponseHandler: humeFailedResponseHandler,
|
|
159
159
|
successfulResponseHandler: createBinaryResponseHandler(),
|
|
@@ -175,21 +175,21 @@ var HumeSpeechModel = class HumeSpeechModel {
|
|
|
175
175
|
};
|
|
176
176
|
//#endregion
|
|
177
177
|
//#region src/version.ts
|
|
178
|
-
const VERSION = "3.0.
|
|
178
|
+
const VERSION = "3.0.73";
|
|
179
179
|
//#endregion
|
|
180
180
|
//#region src/hume-provider.ts
|
|
181
181
|
/**
|
|
182
182
|
* Create an Hume provider instance.
|
|
183
183
|
*/
|
|
184
184
|
function createHume(options = {}) {
|
|
185
|
-
const getHeaders = () => withUserAgentSuffix({
|
|
185
|
+
const getHeaders = () => resolveWith(options.apiKey, (apiKey) => withUserAgentSuffix({
|
|
186
186
|
"X-Hume-Api-Key": loadApiKey({
|
|
187
|
-
apiKey
|
|
187
|
+
apiKey,
|
|
188
188
|
environmentVariableName: "HUME_API_KEY",
|
|
189
189
|
description: "Hume"
|
|
190
190
|
}),
|
|
191
191
|
...options.headers
|
|
192
|
-
}, `ai-sdk-hume/${VERSION}`);
|
|
192
|
+
}, `ai-sdk-hume/${VERSION}`));
|
|
193
193
|
const createSpeechModel = () => new HumeSpeechModel("", {
|
|
194
194
|
provider: `hume.speech`,
|
|
195
195
|
url: ({ path }) => `https://api.hume.ai${path}`,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/hume-error.ts","../src/hume-speech-model-options.ts","../src/hume-speech-model.ts","../src/version.ts","../src/hume-provider.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport {\n lazySchema,\n zodSchema,\n type InferSchema,\n createJsonErrorResponseHandler,\n} from '@ai-sdk/provider-utils';\n\nexport const humeErrorDataSchema = lazySchema(() =>\n zodSchema(\n z.object({\n error: z.object({\n message: z.string(),\n code: z.number(),\n }),\n }),\n ),\n);\n\nexport type HumeErrorData = InferSchema<typeof humeErrorDataSchema>;\n\nexport const humeFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: humeErrorDataSchema,\n errorToMessage: data => data.error.message,\n});\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// https://dev.hume.ai/reference/text-to-speech-tts/synthesize-file\nexport const humeSpeechModelOptionsSchema = lazySchema(() =>\n zodSchema(\n z.object({\n /**\n * Context for the speech synthesis request.\n * Can be either a generationId for retrieving a previous generation,\n * or a list of utterances to synthesize.\n */\n context: z\n .object({\n /**\n * ID of a previously generated speech synthesis to retrieve.\n */\n generationId: z.string(),\n })\n .or(\n z.object({\n /**\n * List of utterances to synthesize into speech.\n */\n utterances: z.array(\n z.object({\n /**\n * The text content to convert to speech.\n */\n text: z.string(),\n /**\n * Optional description or instructions for how the text should be spoken.\n */\n description: z.string().optional(),\n /**\n * Optional speech rate multiplier.\n */\n speed: z.number().optional(),\n /**\n * Optional duration of silence to add after the utterance in seconds.\n */\n trailingSilence: z.number().optional(),\n /**\n * Voice configuration for the utterance.\n * Can be specified by ID or name.\n */\n voice: z\n .object({\n /**\n * ID of the voice to use.\n */\n id: z.string(),\n /**\n * Provider of the voice, either Hume's built-in voices or a custom voice.\n */\n provider: z.enum(['HUME_AI', 'CUSTOM_VOICE']).optional(),\n })\n .or(\n z.object({\n /**\n * Name of the voice to use.\n */\n name: z.string(),\n /**\n * Provider of the voice, either Hume's built-in voices or a custom voice.\n */\n provider: z.enum(['HUME_AI', 'CUSTOM_VOICE']).optional(),\n }),\n )\n .optional(),\n }),\n ),\n }),\n )\n .nullish(),\n }),\n ),\n);\n\nexport type HumeSpeechModelOptions = InferSchema<\n typeof humeSpeechModelOptionsSchema\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 { HumeConfig } from './hume-config';\nimport { humeFailedResponseHandler } from './hume-error';\nimport { humeSpeechModelOptionsSchema } from './hume-speech-model-options';\nimport type { HumeSpeechAPITypes } from './hume-api-types';\n\ninterface HumeSpeechModelConfig extends HumeConfig {\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class HumeSpeechModel implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n\n get provider(): string {\n return this.config.provider;\n }\n\n static [WORKFLOW_SERIALIZE](model: HumeSpeechModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: '';\n config: HumeSpeechModelConfig;\n }) {\n return new HumeSpeechModel(options.modelId as '', options.config);\n }\n\n constructor(\n readonly modelId: '',\n private readonly config: HumeSpeechModelConfig,\n ) {}\n\n private async getArgs({\n text,\n voice = 'd8ab67c6-953d-4bd8-9370-8fa53a0f1453',\n outputFormat = 'mp3',\n speed,\n instructions,\n language,\n providerOptions,\n }: Parameters<SpeechModelV4['doGenerate']>[0]) {\n const warnings: SharedV4Warning[] = [];\n\n // Parse provider options\n const humeOptions = await parseProviderOptions({\n provider: 'hume',\n providerOptions,\n schema: humeSpeechModelOptionsSchema,\n });\n\n // Create request body\n const requestBody: HumeSpeechAPITypes = {\n utterances: [\n {\n text,\n speed,\n description: instructions,\n voice: {\n id: voice,\n provider: 'HUME_AI',\n },\n },\n ],\n format: { type: 'mp3' },\n };\n\n if (outputFormat) {\n if (['mp3', 'pcm', 'wav'].includes(outputFormat)) {\n requestBody.format = { type: outputFormat as 'mp3' | 'pcm' | 'wav' };\n } else {\n warnings.push({\n type: 'unsupported',\n feature: 'outputFormat',\n details: `Unsupported output format: ${outputFormat}. Using mp3 instead.`,\n });\n }\n }\n\n // Add provider-specific options\n if (humeOptions) {\n const speechModelOptions: Omit<\n HumeSpeechAPITypes,\n 'utterances' | 'format'\n > = {};\n\n if (humeOptions.context) {\n if ('generationId' in humeOptions.context) {\n speechModelOptions.context = {\n generation_id: humeOptions.context.generationId,\n };\n } else {\n speechModelOptions.context = {\n utterances: humeOptions.context.utterances.map(utterance => ({\n text: utterance.text,\n description: utterance.description,\n speed: utterance.speed,\n trailing_silence: utterance.trailingSilence,\n voice: utterance.voice,\n })),\n };\n }\n }\n\n for (const key in speechModelOptions) {\n const value =\n speechModelOptions[\n key as keyof Omit<HumeSpeechAPITypes, 'utterances' | 'format'>\n ];\n if (value !== undefined) {\n (requestBody as Record<string, unknown>)[key] = value;\n }\n }\n }\n\n if (language) {\n warnings.push({\n type: 'unsupported',\n feature: 'language',\n details: `Hume speech models do not support language selection. Language parameter \"${language}\" was ignored.`,\n });\n }\n\n return {\n requestBody,\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, warnings } = await this.getArgs(options);\n\n const {\n value: audio,\n responseHeaders,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url: this.config.url({\n path: '/v0/tts/file',\n modelId: this.modelId,\n }),\n headers: combineHeaders(this.config.headers?.(), options.headers),\n body: requestBody,\n failedResponseHandler: humeFailedResponseHandler,\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","// 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","import {\n NoSuchModelError,\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 { HumeSpeechModel } from './hume-speech-model';\nimport { VERSION } from './version';\n\nexport interface HumeProvider extends ProviderV4 {\n (settings?: {}): {\n speech: HumeSpeechModel;\n };\n\n /**\n * Creates a model for speech synthesis.\n */\n speech(): SpeechModelV4;\n}\n\nexport interface HumeProviderSettings {\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 Hume provider instance.\n */\nexport function createHume(options: HumeProviderSettings = {}): HumeProvider {\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n 'X-Hume-Api-Key': loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'HUME_API_KEY',\n description: 'Hume',\n }),\n ...options.headers,\n },\n `ai-sdk-hume/${VERSION}`,\n );\n\n const createSpeechModel = () =>\n new HumeSpeechModel('', {\n provider: `hume.speech`,\n url: ({ path }) => `https://api.hume.ai${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const provider = function () {\n return {\n speech: createSpeechModel(),\n };\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n\n provider.languageModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'languageModel',\n message: 'Hume does not provide language models',\n });\n };\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n message: 'Hume does not provide embedding models',\n });\n };\n\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'imageModel',\n message: 'Hume does not provide image models',\n });\n };\n\n return provider as HumeProvider;\n}\n\n/**\n * Default Hume provider instance.\n */\nexport const h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C,MAAM,IAAI,iBAAiB;GACzB;GACA,WAAW;GACX,SAAS;EACX,CAAC;CACH;CAEA,OAAO;AACT;;;;AAKA,MAAa,OAAO,WAAW"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/hume-error.ts","../src/hume-speech-model-options.ts","../src/hume-speech-model.ts","../src/version.ts","../src/hume-provider.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport {\n lazySchema,\n zodSchema,\n type InferSchema,\n createJsonErrorResponseHandler,\n} from '@ai-sdk/provider-utils';\n\nexport const humeErrorDataSchema = lazySchema(() =>\n zodSchema(\n z.object({\n error: z.object({\n message: z.string(),\n code: z.number(),\n }),\n }),\n ),\n);\n\nexport type HumeErrorData = InferSchema<typeof humeErrorDataSchema>;\n\nexport const humeFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: humeErrorDataSchema,\n errorToMessage: data => data.error.message,\n});\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// https://dev.hume.ai/reference/text-to-speech-tts/synthesize-file\nexport const humeSpeechModelOptionsSchema = lazySchema(() =>\n zodSchema(\n z.object({\n /**\n * Context for the speech synthesis request.\n * Can be either a generationId for retrieving a previous generation,\n * or a list of utterances to synthesize.\n */\n context: z\n .object({\n /**\n * ID of a previously generated speech synthesis to retrieve.\n */\n generationId: z.string(),\n })\n .or(\n z.object({\n /**\n * List of utterances to synthesize into speech.\n */\n utterances: z.array(\n z.object({\n /**\n * The text content to convert to speech.\n */\n text: z.string(),\n /**\n * Optional description or instructions for how the text should be spoken.\n */\n description: z.string().optional(),\n /**\n * Optional speech rate multiplier.\n */\n speed: z.number().optional(),\n /**\n * Optional duration of silence to add after the utterance in seconds.\n */\n trailingSilence: z.number().optional(),\n /**\n * Voice configuration for the utterance.\n * Can be specified by ID or name.\n */\n voice: z\n .object({\n /**\n * ID of the voice to use.\n */\n id: z.string(),\n /**\n * Provider of the voice, either Hume's built-in voices or a custom voice.\n */\n provider: z.enum(['HUME_AI', 'CUSTOM_VOICE']).optional(),\n })\n .or(\n z.object({\n /**\n * Name of the voice to use.\n */\n name: z.string(),\n /**\n * Provider of the voice, either Hume's built-in voices or a custom voice.\n */\n provider: z.enum(['HUME_AI', 'CUSTOM_VOICE']).optional(),\n }),\n )\n .optional(),\n }),\n ),\n }),\n )\n .nullish(),\n }),\n ),\n);\n\nexport type HumeSpeechModelOptions = InferSchema<\n typeof humeSpeechModelOptionsSchema\n>;\n","import type { SpeechModelV4, SharedV4Warning } from '@ai-sdk/provider';\nimport {\n resolve,\n combineHeaders,\n createBinaryResponseHandler,\n parseProviderOptions,\n postJsonToApi,\n serializeModelOptions,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n} from '@ai-sdk/provider-utils';\nimport type { HumeConfig } from './hume-config';\nimport { humeFailedResponseHandler } from './hume-error';\nimport { humeSpeechModelOptionsSchema } from './hume-speech-model-options';\nimport type { HumeSpeechAPITypes } from './hume-api-types';\n\ninterface HumeSpeechModelConfig extends HumeConfig {\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class HumeSpeechModel implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n\n get provider(): string {\n return this.config.provider;\n }\n\n static [WORKFLOW_SERIALIZE](model: HumeSpeechModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: '';\n config: HumeSpeechModelConfig;\n }) {\n return new HumeSpeechModel(options.modelId as '', options.config);\n }\n\n constructor(\n readonly modelId: '',\n private readonly config: HumeSpeechModelConfig,\n ) {}\n\n private async getArgs({\n text,\n voice = 'd8ab67c6-953d-4bd8-9370-8fa53a0f1453',\n outputFormat = 'mp3',\n speed,\n instructions,\n language,\n providerOptions,\n }: Parameters<SpeechModelV4['doGenerate']>[0]) {\n const warnings: SharedV4Warning[] = [];\n\n // Parse provider options\n const humeOptions = await parseProviderOptions({\n provider: 'hume',\n providerOptions,\n schema: humeSpeechModelOptionsSchema,\n });\n\n // Create request body\n const requestBody: HumeSpeechAPITypes = {\n utterances: [\n {\n text,\n speed,\n description: instructions,\n voice: {\n id: voice,\n provider: 'HUME_AI',\n },\n },\n ],\n format: { type: 'mp3' },\n };\n\n if (outputFormat) {\n if (['mp3', 'pcm', 'wav'].includes(outputFormat)) {\n requestBody.format = { type: outputFormat as 'mp3' | 'pcm' | 'wav' };\n } else {\n warnings.push({\n type: 'unsupported',\n feature: 'outputFormat',\n details: `Unsupported output format: ${outputFormat}. Using mp3 instead.`,\n });\n }\n }\n\n // Add provider-specific options\n if (humeOptions) {\n const speechModelOptions: Omit<\n HumeSpeechAPITypes,\n 'utterances' | 'format'\n > = {};\n\n if (humeOptions.context) {\n if ('generationId' in humeOptions.context) {\n speechModelOptions.context = {\n generation_id: humeOptions.context.generationId,\n };\n } else {\n speechModelOptions.context = {\n utterances: humeOptions.context.utterances.map(utterance => ({\n text: utterance.text,\n description: utterance.description,\n speed: utterance.speed,\n trailing_silence: utterance.trailingSilence,\n voice: utterance.voice,\n })),\n };\n }\n }\n\n for (const key in speechModelOptions) {\n const value =\n speechModelOptions[\n key as keyof Omit<HumeSpeechAPITypes, 'utterances' | 'format'>\n ];\n if (value !== undefined) {\n (requestBody as Record<string, unknown>)[key] = value;\n }\n }\n }\n\n if (language) {\n warnings.push({\n type: 'unsupported',\n feature: 'language',\n details: `Hume speech models do not support language selection. Language parameter \"${language}\" was ignored.`,\n });\n }\n\n return {\n requestBody,\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, warnings } = await this.getArgs(options);\n\n const {\n value: audio,\n responseHeaders,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url: this.config.url({\n path: '/v0/tts/file',\n modelId: this.modelId,\n }),\n headers: combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n ),\n body: requestBody,\n failedResponseHandler: humeFailedResponseHandler,\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","// 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","import {\n NoSuchModelError,\n type SpeechModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n resolveWith,\n type Resolvable,\n loadApiKey,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { HumeSpeechModel } from './hume-speech-model';\nimport { VERSION } from './version';\n\nexport interface HumeProvider extends ProviderV4 {\n (settings?: {}): {\n speech: HumeSpeechModel;\n };\n\n /**\n * Creates a model for speech synthesis.\n */\n speech(): SpeechModelV4;\n}\n\nexport interface HumeProviderSettings {\n /**\n * API key for authenticating requests. May be a string, promise, or a\n * synchronous/asynchronous callback called before each request.\n */\n apiKey?: Resolvable<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 Hume provider instance.\n */\nexport function createHume(options: HumeProviderSettings = {}): HumeProvider {\n const getHeaders = () =>\n resolveWith(options.apiKey, apiKey =>\n withUserAgentSuffix(\n {\n 'X-Hume-Api-Key': loadApiKey({\n apiKey,\n environmentVariableName: 'HUME_API_KEY',\n description: 'Hume',\n }),\n ...options.headers,\n },\n `ai-sdk-hume/${VERSION}`,\n ),\n );\n\n const createSpeechModel = () =>\n new HumeSpeechModel('', {\n provider: `hume.speech`,\n url: ({ path }) => `https://api.hume.ai${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const provider = function () {\n return {\n speech: createSpeechModel(),\n };\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n\n provider.languageModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'languageModel',\n message: 'Hume does not provide language models',\n });\n };\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n message: 'Hume does not provide embedding models',\n });\n };\n\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'imageModel',\n message: 'Hume does not provide image models',\n });\n };\n\n return provider as HumeProvider;\n}\n\n/**\n * Default Hume provider instance.\n */\nexport const hume = createHume();\n"],"mappings":";;;;AAQA,MAAa,sBAAsB,iBACjC,UACE,EAAE,OAAO,EACP,OAAO,EAAE,OAAO;CACd,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,OAAO;AACjB,CAAC,EACH,CAAC,CACH,CACF;AAIA,MAAa,4BAA4B,+BAA+B;CACtE,aAAa;CACb,iBAAgB,SAAQ,KAAK,MAAM;AACrC,CAAC;;;AChBD,MAAa,+BAA+B,iBAC1C,UACE,EAAE,OAAO;;;;;;AAMP,SAAS,EACN,OAAO;;;;AAIN,cAAc,EAAE,OAAO,EACzB,CAAC,CAAC,CACD,GACC,EAAE,OAAO;;;;AAIP,YAAY,EAAE,MACZ,EAAE,OAAO;;;;CAIP,MAAM,EAAE,OAAO;;;;CAIf,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;;;;CAIjC,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS;;;;CAI3B,iBAAiB,EAAE,OAAO,CAAC,CAAC,SAAS;;;;;CAKrC,OAAO,EACJ,OAAO;;;;EAIN,IAAI,EAAE,OAAO;;;;EAIb,UAAU,EAAE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WAAW;GAC3B;GACA,yBAAyB;GACzB,aAAa;EACf,CAAC;EACD,GAAG,QAAQ;CACb,GACA,eAAe,SACjB,CACF;CAEF,MAAM,0BACJ,IAAI,gBAAgB,IAAI;EACtB,UAAU;EACV,MAAM,EAAE,WAAW,sBAAsB;EACzC,SAAS;EACT,OAAO,QAAQ;CACjB,CAAC;CAEH,MAAM,WAAW,WAAY;EAC3B,OAAO,EACL,QAAQ,kBAAkB,EAC5B;CACF;CAEA,SAAS,uBAAuB;CAChC,SAAS,SAAS;CAClB,SAAS,cAAc;CAEvB,SAAS,iBAAiB,YAAoB;EAC5C,MAAM,IAAI,iBAAiB;GACzB;GACA,WAAW;GACX,SAAS;EACX,CAAC;CACH;CAEA,SAAS,kBAAkB,YAAoB;EAC7C,MAAM,IAAI,iBAAiB;GACzB;GACA,WAAW;GACX,SAAS;EACX,CAAC;CACH;CAEA,SAAS,cAAc,YAAoB;EACzC,MAAM,IAAI,iBAAiB;GACzB;GACA,WAAW;GACX,SAAS;EACX,CAAC;CACH;CAEA,OAAO;AACT;;;;AAKA,MAAa,OAAO,WAAW"}
|
package/docs/150-hume.mdx
CHANGED
|
@@ -76,7 +76,10 @@ const hume = createHume({
|
|
|
76
76
|
|
|
77
77
|
You can use the following optional settings to customize the Hume provider instance:
|
|
78
78
|
|
|
79
|
-
- **apiKey**
|
|
79
|
+
- **apiKey** _string | PromiseLike<string> | (() => string | PromiseLike<string>)_
|
|
80
|
+
|
|
81
|
+
Pass a synchronous or asynchronous callback to resolve the key before each
|
|
82
|
+
request. The callback is responsible for caching and refreshing credentials.
|
|
80
83
|
|
|
81
84
|
API key that is being sent using the `X-Hume-Api-Key` header.
|
|
82
85
|
It defaults to the `HUME_API_KEY` environment variable.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/hume",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.73",
|
|
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": "4.0.
|
|
33
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
32
|
+
"@ai-sdk/provider": "4.0.35",
|
|
33
|
+
"@ai-sdk/provider-utils": "5.0.73"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@ai-sdk/test-server": "2.0.4",
|
package/src/hume-config.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { FetchFunction } from '@ai-sdk/provider-utils';
|
|
1
|
+
import type { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
2
2
|
|
|
3
3
|
export type HumeConfig = {
|
|
4
4
|
provider: string;
|
|
5
5
|
url: (options: { modelId: string; path: string }) => string;
|
|
6
|
-
headers?:
|
|
6
|
+
headers?: Resolvable<Record<string, string | undefined>>;
|
|
7
7
|
fetch?: FetchFunction;
|
|
8
8
|
generateId?: () => string;
|
|
9
9
|
};
|
package/src/hume-provider.ts
CHANGED
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
type ProviderV4,
|
|
5
5
|
} from '@ai-sdk/provider';
|
|
6
6
|
import {
|
|
7
|
+
resolveWith,
|
|
8
|
+
type Resolvable,
|
|
7
9
|
loadApiKey,
|
|
8
10
|
withUserAgentSuffix,
|
|
9
11
|
type FetchFunction,
|
|
@@ -24,9 +26,10 @@ export interface HumeProvider extends ProviderV4 {
|
|
|
24
26
|
|
|
25
27
|
export interface HumeProviderSettings {
|
|
26
28
|
/**
|
|
27
|
-
* API key for authenticating requests.
|
|
29
|
+
* API key for authenticating requests. May be a string, promise, or a
|
|
30
|
+
* synchronous/asynchronous callback called before each request.
|
|
28
31
|
*/
|
|
29
|
-
apiKey?: string
|
|
32
|
+
apiKey?: Resolvable<string>;
|
|
30
33
|
|
|
31
34
|
/**
|
|
32
35
|
* Custom headers to include in the requests.
|
|
@@ -45,16 +48,18 @@ export interface HumeProviderSettings {
|
|
|
45
48
|
*/
|
|
46
49
|
export function createHume(options: HumeProviderSettings = {}): HumeProvider {
|
|
47
50
|
const getHeaders = () =>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
resolveWith(options.apiKey, apiKey =>
|
|
52
|
+
withUserAgentSuffix(
|
|
53
|
+
{
|
|
54
|
+
'X-Hume-Api-Key': loadApiKey({
|
|
55
|
+
apiKey,
|
|
56
|
+
environmentVariableName: 'HUME_API_KEY',
|
|
57
|
+
description: 'Hume',
|
|
58
|
+
}),
|
|
59
|
+
...options.headers,
|
|
60
|
+
},
|
|
61
|
+
`ai-sdk-hume/${VERSION}`,
|
|
62
|
+
),
|
|
58
63
|
);
|
|
59
64
|
|
|
60
65
|
const createSpeechModel = () =>
|
package/src/hume-speech-model.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SpeechModelV4, SharedV4Warning } from '@ai-sdk/provider';
|
|
2
2
|
import {
|
|
3
|
+
resolve,
|
|
3
4
|
combineHeaders,
|
|
4
5
|
createBinaryResponseHandler,
|
|
5
6
|
parseProviderOptions,
|
|
@@ -156,7 +157,10 @@ export class HumeSpeechModel implements SpeechModelV4 {
|
|
|
156
157
|
path: '/v0/tts/file',
|
|
157
158
|
modelId: this.modelId,
|
|
158
159
|
}),
|
|
159
|
-
headers: combineHeaders(
|
|
160
|
+
headers: combineHeaders(
|
|
161
|
+
await resolve(this.config.headers),
|
|
162
|
+
options.headers,
|
|
163
|
+
),
|
|
160
164
|
body: requestBody,
|
|
161
165
|
failedResponseHandler: humeFailedResponseHandler,
|
|
162
166
|
successfulResponseHandler: createBinaryResponseHandler(),
|