hume 0.9.13 → 0.9.15
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/.mock/definition/expression-measurement/batch/__package__.yml +61 -76
- package/.mock/definition/tts/__package__.yml +113 -15
- package/api/resources/empathicVoice/resources/chatGroups/client/Client.js +4 -4
- package/api/resources/empathicVoice/resources/chats/client/Client.js +3 -3
- package/api/resources/empathicVoice/resources/configs/client/Client.js +9 -9
- package/api/resources/empathicVoice/resources/customVoices/client/Client.js +6 -6
- package/api/resources/empathicVoice/resources/prompts/client/Client.js +9 -9
- package/api/resources/empathicVoice/resources/tools/client/Client.js +9 -9
- package/api/resources/expressionMeasurement/resources/batch/client/Client.js +6 -6
- package/api/resources/index.d.ts +1 -1
- package/api/resources/index.js +2 -2
- package/api/resources/tts/client/Client.d.ts +11 -0
- package/api/resources/tts/client/Client.js +124 -2
- package/api/resources/tts/resources/voices/client/Client.js +1 -1
- package/api/resources/tts/types/PostedTts.d.ts +10 -0
- package/api/resources/tts/types/Snippet.d.ts +0 -2
- package/core/index.d.ts +1 -0
- package/core/index.js +1 -0
- package/core/streaming-fetcher/Stream.d.ts +48 -0
- package/core/streaming-fetcher/Stream.js +170 -0
- package/core/streaming-fetcher/index.d.ts +1 -0
- package/core/streaming-fetcher/index.js +5 -0
- package/dist/api/resources/empathicVoice/resources/chatGroups/client/Client.js +4 -4
- package/dist/api/resources/empathicVoice/resources/chats/client/Client.js +3 -3
- package/dist/api/resources/empathicVoice/resources/configs/client/Client.js +9 -9
- package/dist/api/resources/empathicVoice/resources/customVoices/client/Client.js +6 -6
- package/dist/api/resources/empathicVoice/resources/prompts/client/Client.js +9 -9
- package/dist/api/resources/empathicVoice/resources/tools/client/Client.js +9 -9
- package/dist/api/resources/expressionMeasurement/resources/batch/client/Client.js +6 -6
- package/dist/api/resources/index.d.ts +1 -1
- package/dist/api/resources/index.js +2 -2
- package/dist/api/resources/tts/client/Client.d.ts +11 -0
- package/dist/api/resources/tts/client/Client.js +124 -2
- package/dist/api/resources/tts/resources/voices/client/Client.js +1 -1
- package/dist/api/resources/tts/types/PostedTts.d.ts +10 -0
- package/dist/api/resources/tts/types/Snippet.d.ts +0 -2
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/streaming-fetcher/Stream.d.ts +48 -0
- package/dist/core/streaming-fetcher/Stream.js +170 -0
- package/dist/core/streaming-fetcher/index.d.ts +1 -0
- package/dist/core/streaming-fetcher/index.js +5 -0
- package/dist/serialization/resources/index.d.ts +1 -1
- package/dist/serialization/resources/index.js +2 -2
- package/dist/serialization/resources/tts/types/PostedTts.d.ts +1 -0
- package/dist/serialization/resources/tts/types/PostedTts.js +1 -0
- package/dist/serialization/resources/tts/types/Snippet.d.ts +0 -1
- package/dist/serialization/resources/tts/types/Snippet.js +0 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/reference.md +716 -553
- package/serialization/resources/index.d.ts +1 -1
- package/serialization/resources/index.js +2 -2
- package/serialization/resources/tts/types/PostedTts.d.ts +1 -0
- package/serialization/resources/tts/types/PostedTts.js +1 -0
- package/serialization/resources/tts/types/Snippet.d.ts +0 -1
- package/serialization/resources/tts/types/Snippet.js +0 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -88,7 +88,7 @@ class Batch {
|
|
|
88
88
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
89
89
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.HumeEnvironment.Production, "v0/batch/jobs"),
|
|
90
90
|
method: "GET",
|
|
91
|
-
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.
|
|
91
|
+
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.15", "User-Agent": "hume/0.9.15", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
92
92
|
contentType: "application/json",
|
|
93
93
|
queryParameters: _queryParams,
|
|
94
94
|
requestType: "json",
|
|
@@ -143,7 +143,7 @@ class Batch {
|
|
|
143
143
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
144
144
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.HumeEnvironment.Production, "v0/batch/jobs"),
|
|
145
145
|
method: "POST",
|
|
146
|
-
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.
|
|
146
|
+
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.15", "User-Agent": "hume/0.9.15", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
147
147
|
contentType: "application/json",
|
|
148
148
|
requestType: "json",
|
|
149
149
|
body: serializers.expressionMeasurement.batch.InferenceBaseRequest.jsonOrThrow(request, {
|
|
@@ -197,7 +197,7 @@ class Batch {
|
|
|
197
197
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
198
198
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.HumeEnvironment.Production, `v0/batch/jobs/${encodeURIComponent(id)}`),
|
|
199
199
|
method: "GET",
|
|
200
|
-
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.
|
|
200
|
+
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.15", "User-Agent": "hume/0.9.15", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
201
201
|
contentType: "application/json",
|
|
202
202
|
requestType: "json",
|
|
203
203
|
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
@@ -248,7 +248,7 @@ class Batch {
|
|
|
248
248
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
249
249
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.HumeEnvironment.Production, `v0/batch/jobs/${encodeURIComponent(id)}/predictions`),
|
|
250
250
|
method: "GET",
|
|
251
|
-
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.
|
|
251
|
+
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.15", "User-Agent": "hume/0.9.15", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
252
252
|
contentType: "application/json",
|
|
253
253
|
requestType: "json",
|
|
254
254
|
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
@@ -293,7 +293,7 @@ class Batch {
|
|
|
293
293
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
294
294
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.HumeEnvironment.Production, `v0/batch/jobs/${encodeURIComponent(id)}/artifacts`),
|
|
295
295
|
method: "GET",
|
|
296
|
-
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.
|
|
296
|
+
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.15", "User-Agent": "hume/0.9.15", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
297
297
|
contentType: "application/json",
|
|
298
298
|
requestType: "json",
|
|
299
299
|
responseType: "streaming",
|
|
@@ -349,7 +349,7 @@ class Batch {
|
|
|
349
349
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
350
350
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.HumeEnvironment.Production, "v0/batch/jobs"),
|
|
351
351
|
method: "POST",
|
|
352
|
-
headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.
|
|
352
|
+
headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.15", "User-Agent": "hume/0.9.15", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers),
|
|
353
353
|
requestType: "file",
|
|
354
354
|
duplex: _maybeEncodedRequest.duplex,
|
|
355
355
|
body: _maybeEncodedRequest.body,
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.empathicVoice = exports.expressionMeasurement = exports.tts = void 0;
|
|
27
27
|
exports.tts = __importStar(require("./tts"));
|
|
28
|
-
exports.empathicVoice = __importStar(require("./empathicVoice"));
|
|
29
28
|
exports.expressionMeasurement = __importStar(require("./expressionMeasurement"));
|
|
29
|
+
exports.empathicVoice = __importStar(require("./empathicVoice"));
|
|
@@ -61,6 +61,17 @@ export declare class Tts {
|
|
|
61
61
|
* @throws {@link Hume.tts.UnprocessableEntityError}
|
|
62
62
|
*/
|
|
63
63
|
synthesizeFile(request: Hume.tts.PostedTts, requestOptions?: Tts.RequestOptions): Promise<stream.Readable>;
|
|
64
|
+
/**
|
|
65
|
+
* Streams synthesized speech using the specified voice. If no voice is provided, a novel voice will be generated dynamically. Optionally, additional context can be included to influence the speech's style and prosody.
|
|
66
|
+
* @throws {@link Hume.tts.UnprocessableEntityError}
|
|
67
|
+
*/
|
|
68
|
+
synthesizeFileStreaming(request: Hume.tts.PostedTts, requestOptions?: Tts.RequestOptions): Promise<stream.Readable>;
|
|
69
|
+
/**
|
|
70
|
+
* Streams synthesized speech using the specified voice. If no voice is provided, a novel voice will be generated dynamically. Optionally, additional context can be included to influence the speech's style and prosody.
|
|
71
|
+
*
|
|
72
|
+
* The response is a stream of JSON objects including audio encoded in base64.
|
|
73
|
+
*/
|
|
74
|
+
synthesizeJsonStreaming(request: Hume.tts.PostedTts, requestOptions?: Tts.RequestOptions): Promise<core.Stream<Hume.tts.Snippet>>;
|
|
64
75
|
protected _voices: Voices | undefined;
|
|
65
76
|
get voices(): Voices;
|
|
66
77
|
protected _getCustomAuthorizationHeaders(): Promise<{
|
|
@@ -84,7 +84,7 @@ class Tts {
|
|
|
84
84
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
85
85
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.HumeEnvironment.Production, "v0/tts"),
|
|
86
86
|
method: "POST",
|
|
87
|
-
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.
|
|
87
|
+
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.15", "User-Agent": "hume/0.9.15", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
88
88
|
contentType: "application/json",
|
|
89
89
|
requestType: "json",
|
|
90
90
|
body: serializers.tts.PostedTts.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -143,7 +143,7 @@ class Tts {
|
|
|
143
143
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
144
144
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.HumeEnvironment.Production, "v0/tts/file"),
|
|
145
145
|
method: "POST",
|
|
146
|
-
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.
|
|
146
|
+
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.15", "User-Agent": "hume/0.9.15", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
147
147
|
contentType: "application/json",
|
|
148
148
|
requestType: "json",
|
|
149
149
|
body: serializers.tts.PostedTts.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -186,6 +186,128 @@ class Tts {
|
|
|
186
186
|
}
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Streams synthesized speech using the specified voice. If no voice is provided, a novel voice will be generated dynamically. Optionally, additional context can be included to influence the speech's style and prosody.
|
|
191
|
+
* @throws {@link Hume.tts.UnprocessableEntityError}
|
|
192
|
+
*/
|
|
193
|
+
synthesizeFileStreaming(request, requestOptions) {
|
|
194
|
+
var _a, _b;
|
|
195
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
196
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
197
|
+
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.HumeEnvironment.Production, "v0/tts/stream/file"),
|
|
198
|
+
method: "POST",
|
|
199
|
+
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.15", "User-Agent": "hume/0.9.15", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
200
|
+
contentType: "application/json",
|
|
201
|
+
requestType: "json",
|
|
202
|
+
body: serializers.tts.PostedTts.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
203
|
+
responseType: "streaming",
|
|
204
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
205
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
206
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
207
|
+
});
|
|
208
|
+
if (_response.ok) {
|
|
209
|
+
return _response.body;
|
|
210
|
+
}
|
|
211
|
+
if (_response.error.reason === "status-code") {
|
|
212
|
+
switch (_response.error.statusCode) {
|
|
213
|
+
case 422:
|
|
214
|
+
throw new Hume.tts.UnprocessableEntityError(serializers.tts.HttpValidationError.parseOrThrow(_response.error.body, {
|
|
215
|
+
unrecognizedObjectKeys: "passthrough",
|
|
216
|
+
allowUnrecognizedUnionMembers: true,
|
|
217
|
+
allowUnrecognizedEnumValues: true,
|
|
218
|
+
breadcrumbsPrefix: ["response"],
|
|
219
|
+
}));
|
|
220
|
+
default:
|
|
221
|
+
throw new errors.HumeError({
|
|
222
|
+
statusCode: _response.error.statusCode,
|
|
223
|
+
body: _response.error.body,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
switch (_response.error.reason) {
|
|
228
|
+
case "non-json":
|
|
229
|
+
throw new errors.HumeError({
|
|
230
|
+
statusCode: _response.error.statusCode,
|
|
231
|
+
body: _response.error.rawBody,
|
|
232
|
+
});
|
|
233
|
+
case "timeout":
|
|
234
|
+
throw new errors.HumeTimeoutError();
|
|
235
|
+
case "unknown":
|
|
236
|
+
throw new errors.HumeError({
|
|
237
|
+
message: _response.error.errorMessage,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Streams synthesized speech using the specified voice. If no voice is provided, a novel voice will be generated dynamically. Optionally, additional context can be included to influence the speech's style and prosody.
|
|
244
|
+
*
|
|
245
|
+
* The response is a stream of JSON objects including audio encoded in base64.
|
|
246
|
+
*/
|
|
247
|
+
synthesizeJsonStreaming(request, requestOptions) {
|
|
248
|
+
var _a, _b;
|
|
249
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
250
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
251
|
+
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.HumeEnvironment.Production, "v0/tts/stream/json"),
|
|
252
|
+
method: "POST",
|
|
253
|
+
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.15", "User-Agent": "hume/0.9.15", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
254
|
+
contentType: "application/json",
|
|
255
|
+
requestType: "json",
|
|
256
|
+
body: serializers.tts.PostedTts.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
257
|
+
responseType: "sse",
|
|
258
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
259
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
260
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
261
|
+
});
|
|
262
|
+
if (_response.ok) {
|
|
263
|
+
return new core.Stream({
|
|
264
|
+
stream: _response.body,
|
|
265
|
+
parse: (data) => __awaiter(this, void 0, void 0, function* () {
|
|
266
|
+
return serializers.tts.Snippet.parseOrThrow(data, {
|
|
267
|
+
unrecognizedObjectKeys: "passthrough",
|
|
268
|
+
allowUnrecognizedUnionMembers: true,
|
|
269
|
+
allowUnrecognizedEnumValues: true,
|
|
270
|
+
breadcrumbsPrefix: ["response"],
|
|
271
|
+
});
|
|
272
|
+
}),
|
|
273
|
+
signal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
274
|
+
eventShape: {
|
|
275
|
+
type: "json",
|
|
276
|
+
messageTerminator: "\n",
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
if (_response.error.reason === "status-code") {
|
|
281
|
+
switch (_response.error.statusCode) {
|
|
282
|
+
case 422:
|
|
283
|
+
throw new Hume.tts.UnprocessableEntityError(serializers.tts.HttpValidationError.parseOrThrow(_response.error.body, {
|
|
284
|
+
unrecognizedObjectKeys: "passthrough",
|
|
285
|
+
allowUnrecognizedUnionMembers: true,
|
|
286
|
+
allowUnrecognizedEnumValues: true,
|
|
287
|
+
breadcrumbsPrefix: ["response"],
|
|
288
|
+
}));
|
|
289
|
+
default:
|
|
290
|
+
throw new errors.HumeError({
|
|
291
|
+
statusCode: _response.error.statusCode,
|
|
292
|
+
body: _response.error.body,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
switch (_response.error.reason) {
|
|
297
|
+
case "non-json":
|
|
298
|
+
throw new errors.HumeError({
|
|
299
|
+
statusCode: _response.error.statusCode,
|
|
300
|
+
body: _response.error.rawBody,
|
|
301
|
+
});
|
|
302
|
+
case "timeout":
|
|
303
|
+
throw new errors.HumeTimeoutError();
|
|
304
|
+
case "unknown":
|
|
305
|
+
throw new errors.HumeError({
|
|
306
|
+
message: _response.error.errorMessage,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
189
311
|
get voices() {
|
|
190
312
|
var _a;
|
|
191
313
|
return ((_a = this._voices) !== null && _a !== void 0 ? _a : (this._voices = new Client_1.Voices(this._options)));
|
|
@@ -69,7 +69,7 @@ class Voices {
|
|
|
69
69
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
70
70
|
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.HumeEnvironment.Production, "v0/tts/voices"),
|
|
71
71
|
method: "POST",
|
|
72
|
-
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.
|
|
72
|
+
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.9.15", "User-Agent": "hume/0.9.15", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
73
73
|
contentType: "application/json",
|
|
74
74
|
requestType: "json",
|
|
75
75
|
body: serializers.tts.PostedVoice.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -9,6 +9,16 @@ export interface PostedTts {
|
|
|
9
9
|
format?: Hume.tts.Format;
|
|
10
10
|
/** Number of generations of the audio to produce. */
|
|
11
11
|
numGenerations?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Controls how audio output is segmented in the response.
|
|
14
|
+
*
|
|
15
|
+
* - When **enabled** (`true`), input utterances are automatically split into natural-sounding speech segments.
|
|
16
|
+
*
|
|
17
|
+
* - When **disabled** (`false`), the response maintains a strict one-to-one mapping between input utterances and output snippets.
|
|
18
|
+
*
|
|
19
|
+
* This setting affects how the `snippets` array is structured in the response, which may be important for applications that need to track the relationship between input text and generated audio segments. When setting to `false`, avoid including utterances with long `text`, as this can result in distorted output.
|
|
20
|
+
*/
|
|
21
|
+
splitUtterances?: boolean;
|
|
12
22
|
/** Utterances to be converted to speech output. */
|
|
13
23
|
utterances: Hume.tts.PostedUtterance[];
|
|
14
24
|
}
|
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
export interface Snippet {
|
|
5
5
|
/** The segmented audio output in the requested format, encoded as a base64 string. */
|
|
6
6
|
audio: string;
|
|
7
|
-
/** The generated audio output format. */
|
|
8
|
-
audioFormat: string;
|
|
9
7
|
/** The generation ID this snippet corresponds to. */
|
|
10
8
|
generationId: string;
|
|
11
9
|
/** A unique ID associated with this **Snippet**. */
|
package/dist/core/index.d.ts
CHANGED
package/dist/core/index.js
CHANGED
|
@@ -28,6 +28,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.serialization = void 0;
|
|
30
30
|
/** THIS FILE IS MANUALLY MAINAINED: see .fernignore */
|
|
31
|
+
__exportStar(require("./streaming-fetcher"), exports);
|
|
31
32
|
__exportStar(require("./fetcher"), exports);
|
|
32
33
|
__exportStar(require("./runtime"), exports);
|
|
33
34
|
__exportStar(require("./form-data-utils"), exports);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Readable } from "stream";
|
|
3
|
+
export declare namespace Stream {
|
|
4
|
+
interface Args {
|
|
5
|
+
/**
|
|
6
|
+
* The HTTP response stream to read from.
|
|
7
|
+
*/
|
|
8
|
+
stream: Readable | ReadableStream;
|
|
9
|
+
/**
|
|
10
|
+
* The event shape to use for parsing the stream data.
|
|
11
|
+
*/
|
|
12
|
+
eventShape: JsonEvent | SseEvent;
|
|
13
|
+
/**
|
|
14
|
+
* An abort signal to stop the stream.
|
|
15
|
+
*/
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
}
|
|
18
|
+
interface JsonEvent {
|
|
19
|
+
type: "json";
|
|
20
|
+
messageTerminator: string;
|
|
21
|
+
}
|
|
22
|
+
interface SseEvent {
|
|
23
|
+
type: "sse";
|
|
24
|
+
streamTerminator?: string;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export declare class Stream<T> implements AsyncIterable<T> {
|
|
28
|
+
private stream;
|
|
29
|
+
private parse;
|
|
30
|
+
/**
|
|
31
|
+
* The prefix to use for each message. For example,
|
|
32
|
+
* for SSE, the prefix is "data: ".
|
|
33
|
+
*/
|
|
34
|
+
private prefix;
|
|
35
|
+
private messageTerminator;
|
|
36
|
+
private streamTerminator;
|
|
37
|
+
private controller;
|
|
38
|
+
constructor({ stream, parse, eventShape, signal }: Stream.Args & {
|
|
39
|
+
parse: (val: unknown) => Promise<T>;
|
|
40
|
+
});
|
|
41
|
+
private iterMessages;
|
|
42
|
+
[Symbol.asyncIterator](): AsyncIterator<T, void, unknown>;
|
|
43
|
+
private decodeChunk;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Browser polyfill for ReadableStream
|
|
47
|
+
*/
|
|
48
|
+
export declare function readableStreamAsyncIterable<T>(stream: any): AsyncIterableIterator<T>;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
+
var m = o[Symbol.asyncIterator], i;
|
|
14
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
+
};
|
|
18
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
19
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
20
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
21
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
22
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
23
|
+
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
24
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
25
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
26
|
+
function fulfill(value) { resume("next", value); }
|
|
27
|
+
function reject(value) { resume("throw", value); }
|
|
28
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.readableStreamAsyncIterable = exports.Stream = void 0;
|
|
32
|
+
const runtime_1 = require("../runtime");
|
|
33
|
+
const DATA_PREFIX = "data:";
|
|
34
|
+
class Stream {
|
|
35
|
+
constructor({ stream, parse, eventShape, signal }) {
|
|
36
|
+
this.controller = new AbortController();
|
|
37
|
+
this.stream = stream;
|
|
38
|
+
this.parse = parse;
|
|
39
|
+
if (eventShape.type === "sse") {
|
|
40
|
+
this.prefix = DATA_PREFIX;
|
|
41
|
+
this.messageTerminator = "\n";
|
|
42
|
+
this.streamTerminator = eventShape.streamTerminator;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
this.messageTerminator = eventShape.messageTerminator;
|
|
46
|
+
}
|
|
47
|
+
signal === null || signal === void 0 ? void 0 : signal.addEventListener("abort", () => this.controller.abort());
|
|
48
|
+
}
|
|
49
|
+
iterMessages() {
|
|
50
|
+
return __asyncGenerator(this, arguments, function* iterMessages_1() {
|
|
51
|
+
var e_1, _a;
|
|
52
|
+
this.controller.signal;
|
|
53
|
+
const stream = readableStreamAsyncIterable(this.stream);
|
|
54
|
+
let buf = "";
|
|
55
|
+
let prefixSeen = false;
|
|
56
|
+
try {
|
|
57
|
+
for (var stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield __await(stream_1.next()), !stream_1_1.done;) {
|
|
58
|
+
const chunk = stream_1_1.value;
|
|
59
|
+
buf += this.decodeChunk(chunk);
|
|
60
|
+
let terminatorIndex;
|
|
61
|
+
// Parse the chunk into as many messages as possible
|
|
62
|
+
while ((terminatorIndex = buf.indexOf(this.messageTerminator)) >= 0) {
|
|
63
|
+
// Extract the line from the buffer
|
|
64
|
+
let line = buf.slice(0, terminatorIndex + 1);
|
|
65
|
+
buf = buf.slice(terminatorIndex + 1);
|
|
66
|
+
// Skip empty lines
|
|
67
|
+
if (line.length === 0) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
// Skip the chunk until the prefix is found
|
|
71
|
+
if (!prefixSeen && this.prefix != null) {
|
|
72
|
+
const prefixIndex = line.indexOf(this.prefix);
|
|
73
|
+
if (prefixIndex === -1) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
prefixSeen = true;
|
|
77
|
+
line = line.slice(prefixIndex + this.prefix.length);
|
|
78
|
+
}
|
|
79
|
+
// If the stream terminator is present, return
|
|
80
|
+
if (this.streamTerminator != null && line.includes(this.streamTerminator)) {
|
|
81
|
+
return yield __await(void 0);
|
|
82
|
+
}
|
|
83
|
+
// Otherwise, yield message from the prefix to the terminator
|
|
84
|
+
const message = yield __await(this.parse(JSON.parse(line)));
|
|
85
|
+
yield yield __await(message);
|
|
86
|
+
prefixSeen = false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
91
|
+
finally {
|
|
92
|
+
try {
|
|
93
|
+
if (stream_1_1 && !stream_1_1.done && (_a = stream_1.return)) yield __await(_a.call(stream_1));
|
|
94
|
+
}
|
|
95
|
+
finally { if (e_1) throw e_1.error; }
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
[Symbol.asyncIterator]() {
|
|
100
|
+
return __asyncGenerator(this, arguments, function* _a() {
|
|
101
|
+
var e_2, _b;
|
|
102
|
+
try {
|
|
103
|
+
for (var _c = __asyncValues(this.iterMessages()), _d; _d = yield __await(_c.next()), !_d.done;) {
|
|
104
|
+
const message = _d.value;
|
|
105
|
+
yield yield __await(message);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
109
|
+
finally {
|
|
110
|
+
try {
|
|
111
|
+
if (_d && !_d.done && (_b = _c.return)) yield __await(_b.call(_c));
|
|
112
|
+
}
|
|
113
|
+
finally { if (e_2) throw e_2.error; }
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
decodeChunk(chunk) {
|
|
118
|
+
let decoded = "";
|
|
119
|
+
// If TextDecoder is present, use it
|
|
120
|
+
if (typeof TextDecoder !== "undefined") {
|
|
121
|
+
const decoder = new TextDecoder("utf8");
|
|
122
|
+
decoded += decoder.decode(chunk);
|
|
123
|
+
}
|
|
124
|
+
// Buffer is present in Node.js environment
|
|
125
|
+
else if (runtime_1.RUNTIME.type === "node" && typeof chunk != "undefined") {
|
|
126
|
+
decoded += Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
127
|
+
}
|
|
128
|
+
return decoded;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.Stream = Stream;
|
|
132
|
+
/**
|
|
133
|
+
* Browser polyfill for ReadableStream
|
|
134
|
+
*/
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
136
|
+
function readableStreamAsyncIterable(stream) {
|
|
137
|
+
if (stream[Symbol.asyncIterator]) {
|
|
138
|
+
return stream;
|
|
139
|
+
}
|
|
140
|
+
const reader = stream.getReader();
|
|
141
|
+
return {
|
|
142
|
+
next() {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
try {
|
|
145
|
+
const result = yield reader.read();
|
|
146
|
+
if (result === null || result === void 0 ? void 0 : result.done) {
|
|
147
|
+
reader.releaseLock();
|
|
148
|
+
} // release lock when stream becomes closed
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
catch (e) {
|
|
152
|
+
reader.releaseLock(); // release lock when stream becomes errored
|
|
153
|
+
throw e;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
return() {
|
|
158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
const cancelPromise = reader.cancel();
|
|
160
|
+
reader.releaseLock();
|
|
161
|
+
yield cancelPromise;
|
|
162
|
+
return { done: true, value: undefined };
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
[Symbol.asyncIterator]() {
|
|
166
|
+
return this;
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
exports.readableStreamAsyncIterable = readableStreamAsyncIterable;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Stream } from "./Stream";
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.empathicVoice = exports.expressionMeasurement = exports.tts = void 0;
|
|
27
27
|
exports.tts = __importStar(require("./tts"));
|
|
28
|
-
exports.empathicVoice = __importStar(require("./empathicVoice"));
|
|
29
28
|
exports.expressionMeasurement = __importStar(require("./expressionMeasurement"));
|
|
29
|
+
exports.empathicVoice = __importStar(require("./empathicVoice"));
|
|
@@ -35,5 +35,6 @@ exports.PostedTts = core.serialization.object({
|
|
|
35
35
|
context: PostedContext_1.PostedContext.optional(),
|
|
36
36
|
format: Format_1.Format.optional(),
|
|
37
37
|
numGenerations: core.serialization.property("num_generations", core.serialization.number().optional()),
|
|
38
|
+
splitUtterances: core.serialization.property("split_utterances", core.serialization.boolean().optional()),
|
|
38
39
|
utterances: core.serialization.list(PostedUtterance_1.PostedUtterance),
|
|
39
40
|
});
|
|
@@ -30,7 +30,6 @@ exports.Snippet = void 0;
|
|
|
30
30
|
const core = __importStar(require("../../../../core"));
|
|
31
31
|
exports.Snippet = core.serialization.object({
|
|
32
32
|
audio: core.serialization.string(),
|
|
33
|
-
audioFormat: core.serialization.property("audio_format", core.serialization.string()),
|
|
34
33
|
generationId: core.serialization.property("generation_id", core.serialization.string()),
|
|
35
34
|
id: core.serialization.string(),
|
|
36
35
|
text: core.serialization.string(),
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.9.
|
|
1
|
+
export declare const SDK_VERSION = "0.9.15";
|
package/dist/version.js
CHANGED