hume 0.11.1 → 0.11.3
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/empathic-voice/__package__.yml +24 -0
- package/.mock/definition/empathic-voice/configs.yml +2 -0
- package/.mock/definition/tts/__package__.yml +28 -0
- package/.mock/fern.config.json +1 -1
- package/Client.d.ts +11 -7
- package/Client.js +54 -6
- package/api/resources/empathicVoice/errors/BadRequestError.d.ts +2 -1
- package/api/resources/empathicVoice/errors/BadRequestError.js +2 -1
- package/api/resources/empathicVoice/resources/chatGroups/client/Client.d.ts +7 -3
- package/api/resources/empathicVoice/resources/chatGroups/client/Client.js +79 -52
- package/api/resources/empathicVoice/resources/chats/client/Client.d.ts +5 -2
- package/api/resources/empathicVoice/resources/chats/client/Client.js +59 -39
- package/api/resources/empathicVoice/resources/configs/client/Client.d.ts +17 -8
- package/api/resources/empathicVoice/resources/configs/client/Client.js +144 -83
- package/api/resources/empathicVoice/resources/configs/client/requests/PostedConfig.d.ts +1 -0
- package/api/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.d.ts +1 -0
- package/api/resources/empathicVoice/resources/customVoices/client/Client.d.ts +13 -6
- package/api/resources/empathicVoice/resources/customVoices/client/Client.js +95 -53
- package/api/resources/empathicVoice/resources/prompts/client/Client.d.ts +19 -9
- package/api/resources/empathicVoice/resources/prompts/client/Client.js +143 -81
- package/api/resources/empathicVoice/resources/tools/client/Client.d.ts +17 -8
- package/api/resources/empathicVoice/resources/tools/client/Client.js +144 -83
- package/api/resources/empathicVoice/types/PostedNudgeSpec.d.ts +12 -0
- package/api/resources/empathicVoice/types/PostedNudgeSpec.js +5 -0
- package/api/resources/empathicVoice/types/ReturnConfig.d.ts +1 -0
- package/api/resources/empathicVoice/types/ReturnNudgeSpec.d.ts +12 -0
- package/api/resources/empathicVoice/types/ReturnNudgeSpec.js +5 -0
- package/api/resources/empathicVoice/types/WebhookEventChatStatus.d.ts +2 -1
- package/api/resources/empathicVoice/types/WebhookEventChatStatus.js +1 -0
- package/api/resources/empathicVoice/types/index.d.ts +2 -0
- package/api/resources/empathicVoice/types/index.js +2 -0
- package/api/resources/expressionMeasurement/client/Client.d.ts +2 -0
- package/api/resources/expressionMeasurement/resources/batch/client/Client.d.ts +15 -7
- package/api/resources/expressionMeasurement/resources/batch/client/Client.js +96 -52
- package/api/resources/tts/client/Client.d.ts +27 -19
- package/api/resources/tts/client/Client.js +89 -50
- package/api/resources/tts/client/index.d.ts +1 -1
- package/api/resources/tts/client/index.js +15 -0
- package/api/resources/tts/client/requests/SynthesizeJsonRequest.d.ts +36 -0
- package/api/resources/tts/client/requests/SynthesizeJsonRequest.js +5 -0
- package/api/resources/tts/client/requests/index.d.ts +1 -0
- package/api/resources/tts/client/requests/index.js +2 -0
- package/api/resources/tts/errors/BadRequestError.d.ts +2 -1
- package/api/resources/tts/errors/BadRequestError.js +2 -1
- package/api/resources/tts/errors/UnprocessableEntityError.d.ts +2 -1
- package/api/resources/tts/errors/UnprocessableEntityError.js +2 -1
- package/api/resources/tts/resources/voices/client/Client.d.ts +7 -3
- package/api/resources/tts/resources/voices/client/Client.js +49 -29
- package/api/resources/tts/types/Snippet.d.ts +2 -0
- package/api/resources/tts/types/SnippetAudioChunk.d.ts +2 -0
- package/core/fetcher/APIResponse.d.ts +10 -0
- package/core/fetcher/Fetcher.d.ts +2 -1
- package/core/fetcher/Fetcher.js +29 -9
- package/core/fetcher/Headers.d.ts +2 -0
- package/core/fetcher/Headers.js +84 -0
- package/core/fetcher/HttpResponsePromise.d.ts +58 -0
- package/core/fetcher/HttpResponsePromise.js +103 -0
- package/core/fetcher/RawResponse.d.ts +29 -0
- package/core/fetcher/RawResponse.js +44 -0
- package/core/fetcher/index.d.ts +3 -0
- package/core/fetcher/index.js +7 -1
- package/core/form-data-utils/FormDataWrapper.d.ts +3 -0
- package/core/form-data-utils/FormDataWrapper.js +53 -13
- package/core/form-data-utils/toReadableStream.d.ts +1 -0
- package/core/form-data-utils/toReadableStream.js +50 -0
- package/core/headers.d.ts +3 -0
- package/core/headers.js +29 -0
- package/core/index.d.ts +4 -4
- package/core/index.js +5 -4
- package/core/pagination/Page.d.ts +5 -2
- package/core/pagination/Page.js +5 -2
- package/core/pagination/Pageable.d.ts +2 -0
- package/core/runtime/runtime.js +0 -1
- package/dist/Client.d.ts +11 -7
- package/dist/Client.js +54 -6
- package/dist/api/resources/empathicVoice/errors/BadRequestError.d.ts +2 -1
- package/dist/api/resources/empathicVoice/errors/BadRequestError.js +2 -1
- package/dist/api/resources/empathicVoice/resources/chatGroups/client/Client.d.ts +7 -3
- package/dist/api/resources/empathicVoice/resources/chatGroups/client/Client.js +79 -52
- package/dist/api/resources/empathicVoice/resources/chats/client/Client.d.ts +5 -2
- package/dist/api/resources/empathicVoice/resources/chats/client/Client.js +59 -39
- package/dist/api/resources/empathicVoice/resources/configs/client/Client.d.ts +17 -8
- package/dist/api/resources/empathicVoice/resources/configs/client/Client.js +144 -83
- package/dist/api/resources/empathicVoice/resources/configs/client/requests/PostedConfig.d.ts +1 -0
- package/dist/api/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.d.ts +1 -0
- package/dist/api/resources/empathicVoice/resources/customVoices/client/Client.d.ts +13 -6
- package/dist/api/resources/empathicVoice/resources/customVoices/client/Client.js +95 -53
- package/dist/api/resources/empathicVoice/resources/prompts/client/Client.d.ts +19 -9
- package/dist/api/resources/empathicVoice/resources/prompts/client/Client.js +143 -81
- package/dist/api/resources/empathicVoice/resources/tools/client/Client.d.ts +17 -8
- package/dist/api/resources/empathicVoice/resources/tools/client/Client.js +144 -83
- package/dist/api/resources/empathicVoice/types/PostedNudgeSpec.d.ts +12 -0
- package/dist/api/resources/empathicVoice/types/PostedNudgeSpec.js +5 -0
- package/dist/api/resources/empathicVoice/types/ReturnConfig.d.ts +1 -0
- package/dist/api/resources/empathicVoice/types/ReturnNudgeSpec.d.ts +12 -0
- package/dist/api/resources/empathicVoice/types/ReturnNudgeSpec.js +5 -0
- package/dist/api/resources/empathicVoice/types/WebhookEventChatStatus.d.ts +2 -1
- package/dist/api/resources/empathicVoice/types/WebhookEventChatStatus.js +1 -0
- package/dist/api/resources/empathicVoice/types/index.d.ts +2 -0
- package/dist/api/resources/empathicVoice/types/index.js +2 -0
- package/dist/api/resources/expressionMeasurement/client/Client.d.ts +2 -0
- package/dist/api/resources/expressionMeasurement/resources/batch/client/Client.d.ts +15 -7
- package/dist/api/resources/expressionMeasurement/resources/batch/client/Client.js +96 -52
- package/dist/api/resources/tts/client/Client.d.ts +27 -19
- package/dist/api/resources/tts/client/Client.js +89 -50
- package/dist/api/resources/tts/client/index.d.ts +1 -1
- package/dist/api/resources/tts/client/index.js +15 -0
- package/dist/api/resources/tts/client/requests/SynthesizeJsonRequest.d.ts +36 -0
- package/dist/api/resources/tts/client/requests/SynthesizeJsonRequest.js +5 -0
- package/dist/api/resources/tts/client/requests/index.d.ts +1 -0
- package/dist/api/resources/tts/client/requests/index.js +2 -0
- package/dist/api/resources/tts/errors/BadRequestError.d.ts +2 -1
- package/dist/api/resources/tts/errors/BadRequestError.js +2 -1
- package/dist/api/resources/tts/errors/UnprocessableEntityError.d.ts +2 -1
- package/dist/api/resources/tts/errors/UnprocessableEntityError.js +2 -1
- package/dist/api/resources/tts/resources/voices/client/Client.d.ts +7 -3
- package/dist/api/resources/tts/resources/voices/client/Client.js +49 -29
- package/dist/api/resources/tts/types/Snippet.d.ts +2 -0
- package/dist/api/resources/tts/types/SnippetAudioChunk.d.ts +2 -0
- package/dist/core/fetcher/APIResponse.d.ts +10 -0
- package/dist/core/fetcher/Fetcher.d.ts +2 -1
- package/dist/core/fetcher/Fetcher.js +29 -9
- package/dist/core/fetcher/Headers.d.ts +2 -0
- package/dist/core/fetcher/Headers.js +84 -0
- package/dist/core/fetcher/HttpResponsePromise.d.ts +58 -0
- package/dist/core/fetcher/HttpResponsePromise.js +103 -0
- package/dist/core/fetcher/RawResponse.d.ts +29 -0
- package/dist/core/fetcher/RawResponse.js +44 -0
- package/dist/core/fetcher/index.d.ts +3 -0
- package/dist/core/fetcher/index.js +7 -1
- package/dist/core/form-data-utils/FormDataWrapper.d.ts +3 -0
- package/dist/core/form-data-utils/FormDataWrapper.js +53 -13
- package/dist/core/form-data-utils/toReadableStream.d.ts +1 -0
- package/dist/core/form-data-utils/toReadableStream.js +50 -0
- package/dist/core/headers.d.ts +3 -0
- package/dist/core/headers.js +29 -0
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +5 -4
- package/dist/core/pagination/Page.d.ts +5 -2
- package/dist/core/pagination/Page.js +5 -2
- package/dist/core/pagination/Pageable.d.ts +2 -0
- package/dist/core/runtime/runtime.js +0 -1
- package/dist/errors/HumeError.d.ts +7 -2
- package/dist/errors/HumeError.js +10 -10
- package/dist/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfig.d.ts +2 -0
- package/dist/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfig.js +2 -0
- package/dist/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.d.ts +2 -0
- package/dist/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.js +2 -0
- package/dist/serialization/resources/empathicVoice/types/PostedNudgeSpec.d.ts +13 -0
- package/dist/serialization/resources/empathicVoice/types/PostedNudgeSpec.js +44 -0
- package/dist/serialization/resources/empathicVoice/types/ReturnConfig.d.ts +2 -0
- package/dist/serialization/resources/empathicVoice/types/ReturnConfig.js +2 -0
- package/dist/serialization/resources/empathicVoice/types/ReturnNudgeSpec.d.ts +13 -0
- package/dist/serialization/resources/empathicVoice/types/ReturnNudgeSpec.js +44 -0
- package/dist/serialization/resources/empathicVoice/types/WebhookEventChatStatus.d.ts +1 -1
- package/dist/serialization/resources/empathicVoice/types/WebhookEventChatStatus.js +1 -0
- package/dist/serialization/resources/empathicVoice/types/index.d.ts +2 -0
- package/dist/serialization/resources/empathicVoice/types/index.js +2 -0
- package/dist/serialization/resources/tts/types/Snippet.d.ts +1 -0
- package/dist/serialization/resources/tts/types/Snippet.js +1 -0
- package/dist/serialization/resources/tts/types/SnippetAudioChunk.d.ts +1 -0
- package/dist/serialization/resources/tts/types/SnippetAudioChunk.js +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/wrapper/expressionMeasurement/ExpressionMeasurementClient.js +2 -0
- package/dist/wrapper/expressionMeasurement/batch/BatchClient.d.ts +2 -1
- package/dist/wrapper/expressionMeasurement/batch/BatchClient.js +43 -17
- package/errors/HumeError.d.ts +7 -2
- package/errors/HumeError.js +10 -10
- package/package.json +9 -4
- package/reference.md +17 -15
- package/scripts/rename-to-esm-files.js +10 -2
- package/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfig.d.ts +2 -0
- package/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfig.js +2 -0
- package/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.d.ts +2 -0
- package/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.js +2 -0
- package/serialization/resources/empathicVoice/types/PostedNudgeSpec.d.ts +13 -0
- package/serialization/resources/empathicVoice/types/PostedNudgeSpec.js +44 -0
- package/serialization/resources/empathicVoice/types/ReturnConfig.d.ts +2 -0
- package/serialization/resources/empathicVoice/types/ReturnConfig.js +2 -0
- package/serialization/resources/empathicVoice/types/ReturnNudgeSpec.d.ts +13 -0
- package/serialization/resources/empathicVoice/types/ReturnNudgeSpec.js +44 -0
- package/serialization/resources/empathicVoice/types/WebhookEventChatStatus.d.ts +1 -1
- package/serialization/resources/empathicVoice/types/WebhookEventChatStatus.js +1 -0
- package/serialization/resources/empathicVoice/types/index.d.ts +2 -0
- package/serialization/resources/empathicVoice/types/index.js +2 -0
- package/serialization/resources/tts/types/Snippet.d.ts +1 -0
- package/serialization/resources/tts/types/Snippet.js +1 -0
- package/serialization/resources/tts/types/SnippetAudioChunk.d.ts +1 -0
- package/serialization/resources/tts/types/SnippetAudioChunk.js +1 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/wrapper/expressionMeasurement/ExpressionMeasurementClient.js +2 -0
- package/wrapper/expressionMeasurement/batch/BatchClient.d.ts +2 -1
- package/wrapper/expressionMeasurement/batch/BatchClient.js +43 -17
- /package/core/{streaming-fetcher → stream}/Stream.d.ts +0 -0
- /package/core/{streaming-fetcher → stream}/Stream.js +0 -0
- /package/core/{streaming-fetcher → stream}/index.d.ts +0 -0
- /package/core/{streaming-fetcher → stream}/index.js +0 -0
- /package/dist/core/{streaming-fetcher → stream}/Stream.d.ts +0 -0
- /package/dist/core/{streaming-fetcher → stream}/Stream.js +0 -0
- /package/dist/core/{streaming-fetcher → stream}/index.d.ts +0 -0
- /package/dist/core/{streaming-fetcher → stream}/index.js +0 -0
|
@@ -52,6 +52,7 @@ exports.Tts = void 0;
|
|
|
52
52
|
const environments = __importStar(require("../../../../environments"));
|
|
53
53
|
const core = __importStar(require("../../../../core"));
|
|
54
54
|
const Hume = __importStar(require("../../../index"));
|
|
55
|
+
const headers_js_1 = require("../../../../core/headers.js");
|
|
55
56
|
const serializers = __importStar(require("../../../../serialization/index"));
|
|
56
57
|
const url_join_1 = __importDefault(require("url-join"));
|
|
57
58
|
const errors = __importStar(require("../../../../errors/index"));
|
|
@@ -69,50 +70,64 @@ class Tts {
|
|
|
69
70
|
*
|
|
70
71
|
* The response includes the base64-encoded audio and metadata in JSON format.
|
|
71
72
|
*
|
|
72
|
-
* @param {Hume.tts.
|
|
73
|
+
* @param {Hume.tts.SynthesizeJsonRequest} request
|
|
73
74
|
* @param {Tts.RequestOptions} requestOptions - Request-specific configuration.
|
|
74
75
|
*
|
|
75
76
|
* @throws {@link Hume.tts.UnprocessableEntityError}
|
|
76
77
|
*
|
|
77
78
|
* @example
|
|
78
79
|
* await client.tts.synthesizeJson({
|
|
79
|
-
*
|
|
80
|
-
* text: "Beauty is no quality in things themselves: It exists merely in the mind which contemplates them.",
|
|
81
|
-
* description: "Middle-aged masculine voice with a clear, rhythmic Scots lilt, rounded vowels, and a warm, steady tone with an articulate, academic quality."
|
|
82
|
-
* }],
|
|
83
|
-
* context: {
|
|
80
|
+
* body: {
|
|
84
81
|
* utterances: [{
|
|
85
|
-
* text: "
|
|
86
|
-
* description: "
|
|
87
|
-
* }]
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
82
|
+
* text: "Beauty is no quality in things themselves: It exists merely in the mind which contemplates them.",
|
|
83
|
+
* description: "Middle-aged masculine voice with a clear, rhythmic Scots lilt, rounded vowels, and a warm, steady tone with an articulate, academic quality."
|
|
84
|
+
* }],
|
|
85
|
+
* context: {
|
|
86
|
+
* utterances: [{
|
|
87
|
+
* text: "How can people see beauty so differently?",
|
|
88
|
+
* description: "A curious student with a clear and respectful tone, seeking clarification on Hume's ideas with a straightforward question."
|
|
89
|
+
* }]
|
|
90
|
+
* },
|
|
91
|
+
* format: {
|
|
92
|
+
* type: "mp3"
|
|
93
|
+
* },
|
|
94
|
+
* numGenerations: 1
|
|
95
|
+
* }
|
|
93
96
|
* })
|
|
94
97
|
*/
|
|
95
98
|
synthesizeJson(request, requestOptions) {
|
|
99
|
+
return core.HttpResponsePromise.fromPromise(this.__synthesizeJson(request, requestOptions));
|
|
100
|
+
}
|
|
101
|
+
__synthesizeJson(request, requestOptions) {
|
|
96
102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
-
var _a, _b, _c;
|
|
103
|
+
var _a, _b, _c, _d;
|
|
104
|
+
const { accessToken, body: _body } = request;
|
|
105
|
+
const _queryParams = {};
|
|
106
|
+
if (accessToken != null) {
|
|
107
|
+
_queryParams["access_token"] = accessToken;
|
|
108
|
+
}
|
|
98
109
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
99
110
|
url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.HumeEnvironment.Production, "v0/tts"),
|
|
100
111
|
method: "POST",
|
|
101
|
-
headers:
|
|
112
|
+
headers: (0, headers_js_1.mergeHeaders)((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
102
113
|
contentType: "application/json",
|
|
114
|
+
queryParameters: _queryParams,
|
|
103
115
|
requestType: "json",
|
|
104
|
-
body: serializers.tts.PostedTts.jsonOrThrow(
|
|
116
|
+
body: serializers.tts.PostedTts.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }),
|
|
105
117
|
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
106
118
|
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
107
119
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
108
120
|
});
|
|
109
121
|
if (_response.ok) {
|
|
110
|
-
return
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
return {
|
|
123
|
+
data: serializers.tts.ReturnTts.parseOrThrow(_response.body, {
|
|
124
|
+
unrecognizedObjectKeys: "passthrough",
|
|
125
|
+
allowUnrecognizedUnionMembers: true,
|
|
126
|
+
allowUnrecognizedEnumValues: true,
|
|
127
|
+
breadcrumbsPrefix: ["response"],
|
|
128
|
+
}),
|
|
129
|
+
rawResponse: _response.rawResponse,
|
|
130
|
+
};
|
|
116
131
|
}
|
|
117
132
|
if (_response.error.reason === "status-code") {
|
|
118
133
|
switch (_response.error.statusCode) {
|
|
@@ -122,11 +137,12 @@ class Tts {
|
|
|
122
137
|
allowUnrecognizedUnionMembers: true,
|
|
123
138
|
allowUnrecognizedEnumValues: true,
|
|
124
139
|
breadcrumbsPrefix: ["response"],
|
|
125
|
-
}));
|
|
140
|
+
}), _response.rawResponse);
|
|
126
141
|
default:
|
|
127
142
|
throw new errors.HumeError({
|
|
128
143
|
statusCode: _response.error.statusCode,
|
|
129
144
|
body: _response.error.body,
|
|
145
|
+
rawResponse: _response.rawResponse,
|
|
130
146
|
});
|
|
131
147
|
}
|
|
132
148
|
}
|
|
@@ -135,12 +151,14 @@ class Tts {
|
|
|
135
151
|
throw new errors.HumeError({
|
|
136
152
|
statusCode: _response.error.statusCode,
|
|
137
153
|
body: _response.error.rawBody,
|
|
154
|
+
rawResponse: _response.rawResponse,
|
|
138
155
|
});
|
|
139
156
|
case "timeout":
|
|
140
157
|
throw new errors.HumeTimeoutError("Timeout exceeded when calling POST /v0/tts.");
|
|
141
158
|
case "unknown":
|
|
142
159
|
throw new errors.HumeError({
|
|
143
160
|
message: _response.error.errorMessage,
|
|
161
|
+
rawResponse: _response.rawResponse,
|
|
144
162
|
});
|
|
145
163
|
}
|
|
146
164
|
});
|
|
@@ -152,12 +170,15 @@ class Tts {
|
|
|
152
170
|
* @throws {@link Hume.tts.UnprocessableEntityError}
|
|
153
171
|
*/
|
|
154
172
|
synthesizeFile(request, requestOptions) {
|
|
173
|
+
return core.HttpResponsePromise.fromPromise(this.__synthesizeFile(request, requestOptions));
|
|
174
|
+
}
|
|
175
|
+
__synthesizeFile(request, requestOptions) {
|
|
155
176
|
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
-
var _a, _b, _c;
|
|
177
|
+
var _a, _b, _c, _d;
|
|
157
178
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
158
179
|
url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.HumeEnvironment.Production, "v0/tts/file"),
|
|
159
180
|
method: "POST",
|
|
160
|
-
headers:
|
|
181
|
+
headers: (0, headers_js_1.mergeHeaders)((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
161
182
|
contentType: "application/json",
|
|
162
183
|
requestType: "json",
|
|
163
184
|
body: serializers.tts.PostedTts.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -167,7 +188,7 @@ class Tts {
|
|
|
167
188
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
168
189
|
});
|
|
169
190
|
if (_response.ok) {
|
|
170
|
-
return _response.body;
|
|
191
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
171
192
|
}
|
|
172
193
|
if (_response.error.reason === "status-code") {
|
|
173
194
|
switch (_response.error.statusCode) {
|
|
@@ -177,11 +198,12 @@ class Tts {
|
|
|
177
198
|
allowUnrecognizedUnionMembers: true,
|
|
178
199
|
allowUnrecognizedEnumValues: true,
|
|
179
200
|
breadcrumbsPrefix: ["response"],
|
|
180
|
-
}));
|
|
201
|
+
}), _response.rawResponse);
|
|
181
202
|
default:
|
|
182
203
|
throw new errors.HumeError({
|
|
183
204
|
statusCode: _response.error.statusCode,
|
|
184
205
|
body: _response.error.body,
|
|
206
|
+
rawResponse: _response.rawResponse,
|
|
185
207
|
});
|
|
186
208
|
}
|
|
187
209
|
}
|
|
@@ -190,12 +212,14 @@ class Tts {
|
|
|
190
212
|
throw new errors.HumeError({
|
|
191
213
|
statusCode: _response.error.statusCode,
|
|
192
214
|
body: _response.error.rawBody,
|
|
215
|
+
rawResponse: _response.rawResponse,
|
|
193
216
|
});
|
|
194
217
|
case "timeout":
|
|
195
218
|
throw new errors.HumeTimeoutError("Timeout exceeded when calling POST /v0/tts/file.");
|
|
196
219
|
case "unknown":
|
|
197
220
|
throw new errors.HumeError({
|
|
198
221
|
message: _response.error.errorMessage,
|
|
222
|
+
rawResponse: _response.rawResponse,
|
|
199
223
|
});
|
|
200
224
|
}
|
|
201
225
|
});
|
|
@@ -205,12 +229,15 @@ class Tts {
|
|
|
205
229
|
* @throws {@link Hume.tts.UnprocessableEntityError}
|
|
206
230
|
*/
|
|
207
231
|
synthesizeFileStreaming(request, requestOptions) {
|
|
232
|
+
return core.HttpResponsePromise.fromPromise(this.__synthesizeFileStreaming(request, requestOptions));
|
|
233
|
+
}
|
|
234
|
+
__synthesizeFileStreaming(request, requestOptions) {
|
|
208
235
|
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
-
var _a, _b, _c;
|
|
236
|
+
var _a, _b, _c, _d;
|
|
210
237
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
211
238
|
url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.HumeEnvironment.Production, "v0/tts/stream/file"),
|
|
212
239
|
method: "POST",
|
|
213
|
-
headers:
|
|
240
|
+
headers: (0, headers_js_1.mergeHeaders)((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
214
241
|
contentType: "application/json",
|
|
215
242
|
requestType: "json",
|
|
216
243
|
body: serializers.tts.PostedTts.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -220,7 +247,7 @@ class Tts {
|
|
|
220
247
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
221
248
|
});
|
|
222
249
|
if (_response.ok) {
|
|
223
|
-
return _response.body;
|
|
250
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
224
251
|
}
|
|
225
252
|
if (_response.error.reason === "status-code") {
|
|
226
253
|
switch (_response.error.statusCode) {
|
|
@@ -230,11 +257,12 @@ class Tts {
|
|
|
230
257
|
allowUnrecognizedUnionMembers: true,
|
|
231
258
|
allowUnrecognizedEnumValues: true,
|
|
232
259
|
breadcrumbsPrefix: ["response"],
|
|
233
|
-
}));
|
|
260
|
+
}), _response.rawResponse);
|
|
234
261
|
default:
|
|
235
262
|
throw new errors.HumeError({
|
|
236
263
|
statusCode: _response.error.statusCode,
|
|
237
264
|
body: _response.error.body,
|
|
265
|
+
rawResponse: _response.rawResponse,
|
|
238
266
|
});
|
|
239
267
|
}
|
|
240
268
|
}
|
|
@@ -243,12 +271,14 @@ class Tts {
|
|
|
243
271
|
throw new errors.HumeError({
|
|
244
272
|
statusCode: _response.error.statusCode,
|
|
245
273
|
body: _response.error.rawBody,
|
|
274
|
+
rawResponse: _response.rawResponse,
|
|
246
275
|
});
|
|
247
276
|
case "timeout":
|
|
248
277
|
throw new errors.HumeTimeoutError("Timeout exceeded when calling POST /v0/tts/stream/file.");
|
|
249
278
|
case "unknown":
|
|
250
279
|
throw new errors.HumeError({
|
|
251
280
|
message: _response.error.errorMessage,
|
|
281
|
+
rawResponse: _response.rawResponse,
|
|
252
282
|
});
|
|
253
283
|
}
|
|
254
284
|
});
|
|
@@ -259,12 +289,15 @@ class Tts {
|
|
|
259
289
|
* The response is a stream of JSON objects including audio encoded in base64.
|
|
260
290
|
*/
|
|
261
291
|
synthesizeJsonStreaming(request, requestOptions) {
|
|
292
|
+
return core.HttpResponsePromise.fromPromise(this.__synthesizeJsonStreaming(request, requestOptions));
|
|
293
|
+
}
|
|
294
|
+
__synthesizeJsonStreaming(request, requestOptions) {
|
|
262
295
|
return __awaiter(this, void 0, void 0, function* () {
|
|
263
|
-
var _a, _b, _c;
|
|
296
|
+
var _a, _b, _c, _d;
|
|
264
297
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
265
298
|
url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.HumeEnvironment.Production, "v0/tts/stream/json"),
|
|
266
299
|
method: "POST",
|
|
267
|
-
headers:
|
|
300
|
+
headers: (0, headers_js_1.mergeHeaders)((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
268
301
|
contentType: "application/json",
|
|
269
302
|
requestType: "json",
|
|
270
303
|
body: serializers.tts.PostedTts.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
@@ -274,22 +307,25 @@ class Tts {
|
|
|
274
307
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
275
308
|
});
|
|
276
309
|
if (_response.ok) {
|
|
277
|
-
return
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
310
|
+
return {
|
|
311
|
+
data: new core.Stream({
|
|
312
|
+
stream: _response.body,
|
|
313
|
+
parse: (data) => __awaiter(this, void 0, void 0, function* () {
|
|
314
|
+
return serializers.tts.SnippetAudioChunk.parseOrThrow(data, {
|
|
315
|
+
unrecognizedObjectKeys: "passthrough",
|
|
316
|
+
allowUnrecognizedUnionMembers: true,
|
|
317
|
+
allowUnrecognizedEnumValues: true,
|
|
318
|
+
breadcrumbsPrefix: ["response"],
|
|
319
|
+
});
|
|
320
|
+
}),
|
|
321
|
+
signal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
322
|
+
eventShape: {
|
|
323
|
+
type: "json",
|
|
324
|
+
messageTerminator: "\n",
|
|
325
|
+
},
|
|
286
326
|
}),
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
type: "json",
|
|
290
|
-
messageTerminator: "\n",
|
|
291
|
-
},
|
|
292
|
-
});
|
|
327
|
+
rawResponse: _response.rawResponse,
|
|
328
|
+
};
|
|
293
329
|
}
|
|
294
330
|
if (_response.error.reason === "status-code") {
|
|
295
331
|
switch (_response.error.statusCode) {
|
|
@@ -299,11 +335,12 @@ class Tts {
|
|
|
299
335
|
allowUnrecognizedUnionMembers: true,
|
|
300
336
|
allowUnrecognizedEnumValues: true,
|
|
301
337
|
breadcrumbsPrefix: ["response"],
|
|
302
|
-
}));
|
|
338
|
+
}), _response.rawResponse);
|
|
303
339
|
default:
|
|
304
340
|
throw new errors.HumeError({
|
|
305
341
|
statusCode: _response.error.statusCode,
|
|
306
342
|
body: _response.error.body,
|
|
343
|
+
rawResponse: _response.rawResponse,
|
|
307
344
|
});
|
|
308
345
|
}
|
|
309
346
|
}
|
|
@@ -312,12 +349,14 @@ class Tts {
|
|
|
312
349
|
throw new errors.HumeError({
|
|
313
350
|
statusCode: _response.error.statusCode,
|
|
314
351
|
body: _response.error.rawBody,
|
|
352
|
+
rawResponse: _response.rawResponse,
|
|
315
353
|
});
|
|
316
354
|
case "timeout":
|
|
317
355
|
throw new errors.HumeTimeoutError("Timeout exceeded when calling POST /v0/tts/stream/json.");
|
|
318
356
|
case "unknown":
|
|
319
357
|
throw new errors.HumeError({
|
|
320
358
|
message: _response.error.errorMessage,
|
|
359
|
+
rawResponse: _response.rawResponse,
|
|
321
360
|
});
|
|
322
361
|
}
|
|
323
362
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./requests";
|
|
@@ -1,2 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./requests"), exports);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as Hume from "../../../../index";
|
|
5
|
+
/**
|
|
6
|
+
* @example
|
|
7
|
+
* {
|
|
8
|
+
* body: {
|
|
9
|
+
* utterances: [{
|
|
10
|
+
* text: "Beauty is no quality in things themselves: It exists merely in the mind which contemplates them.",
|
|
11
|
+
* description: "Middle-aged masculine voice with a clear, rhythmic Scots lilt, rounded vowels, and a warm, steady tone with an articulate, academic quality."
|
|
12
|
+
* }],
|
|
13
|
+
* context: {
|
|
14
|
+
* utterances: [{
|
|
15
|
+
* text: "How can people see beauty so differently?",
|
|
16
|
+
* description: "A curious student with a clear and respectful tone, seeking clarification on Hume's ideas with a straightforward question."
|
|
17
|
+
* }]
|
|
18
|
+
* },
|
|
19
|
+
* format: {
|
|
20
|
+
* type: "mp3"
|
|
21
|
+
* },
|
|
22
|
+
* numGenerations: 1
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
export interface SynthesizeJsonRequest {
|
|
27
|
+
/**
|
|
28
|
+
* Access token used for authenticating the client. If not provided, an `api_key` must be provided to authenticate.
|
|
29
|
+
*
|
|
30
|
+
* The access token is generated using both an API key and a Secret key, which provides an additional layer of security compared to using just an API key.
|
|
31
|
+
*
|
|
32
|
+
* For more details, refer to the [Authentication Strategies Guide](/docs/introduction/api-key#authentication-strategies).
|
|
33
|
+
*/
|
|
34
|
+
accessToken?: string;
|
|
35
|
+
body: Hume.tts.PostedTts;
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type SynthesizeJsonRequest } from "./SynthesizeJsonRequest";
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as errors from "../../../../errors/index";
|
|
5
5
|
import * as Hume from "../../../index";
|
|
6
|
+
import * as core from "../../../../core";
|
|
6
7
|
export declare class BadRequestError extends errors.HumeError {
|
|
7
|
-
constructor(body: Hume.tts.ErrorResponse);
|
|
8
|
+
constructor(body: Hume.tts.ErrorResponse, rawResponse?: core.RawResponse);
|
|
8
9
|
}
|
|
@@ -39,11 +39,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.BadRequestError = void 0;
|
|
40
40
|
const errors = __importStar(require("../../../../errors/index"));
|
|
41
41
|
class BadRequestError extends errors.HumeError {
|
|
42
|
-
constructor(body) {
|
|
42
|
+
constructor(body, rawResponse) {
|
|
43
43
|
super({
|
|
44
44
|
message: "BadRequestError",
|
|
45
45
|
statusCode: 400,
|
|
46
46
|
body: body,
|
|
47
|
+
rawResponse: rawResponse,
|
|
47
48
|
});
|
|
48
49
|
Object.setPrototypeOf(this, BadRequestError.prototype);
|
|
49
50
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as errors from "../../../../errors/index";
|
|
5
5
|
import * as Hume from "../../../index";
|
|
6
|
+
import * as core from "../../../../core";
|
|
6
7
|
export declare class UnprocessableEntityError extends errors.HumeError {
|
|
7
|
-
constructor(body: Hume.tts.HttpValidationError);
|
|
8
|
+
constructor(body: Hume.tts.HttpValidationError, rawResponse?: core.RawResponse);
|
|
8
9
|
}
|
|
@@ -39,11 +39,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.UnprocessableEntityError = void 0;
|
|
40
40
|
const errors = __importStar(require("../../../../errors/index"));
|
|
41
41
|
class UnprocessableEntityError extends errors.HumeError {
|
|
42
|
-
constructor(body) {
|
|
42
|
+
constructor(body, rawResponse) {
|
|
43
43
|
super({
|
|
44
44
|
message: "UnprocessableEntityError",
|
|
45
45
|
statusCode: 422,
|
|
46
46
|
body: body,
|
|
47
|
+
rawResponse: rawResponse,
|
|
47
48
|
});
|
|
48
49
|
Object.setPrototypeOf(this, UnprocessableEntityError.prototype);
|
|
49
50
|
}
|
|
@@ -10,6 +10,8 @@ export declare namespace Voices {
|
|
|
10
10
|
/** Specify a custom URL to connect the client to. */
|
|
11
11
|
baseUrl?: core.Supplier<string>;
|
|
12
12
|
apiKey?: core.Supplier<string | undefined>;
|
|
13
|
+
/** Additional headers to include in requests. */
|
|
14
|
+
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
|
|
13
15
|
fetcher?: core.FetchFunction;
|
|
14
16
|
}
|
|
15
17
|
interface RequestOptions {
|
|
@@ -20,7 +22,7 @@ export declare namespace Voices {
|
|
|
20
22
|
/** A hook to abort the request. */
|
|
21
23
|
abortSignal?: AbortSignal;
|
|
22
24
|
/** Additional headers to include in the request. */
|
|
23
|
-
headers?: Record<string, string>;
|
|
25
|
+
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
export declare class Voices {
|
|
@@ -56,7 +58,8 @@ export declare class Voices {
|
|
|
56
58
|
* name: "David Hume"
|
|
57
59
|
* })
|
|
58
60
|
*/
|
|
59
|
-
create(request: Hume.tts.PostedVoice, requestOptions?: Voices.RequestOptions):
|
|
61
|
+
create(request: Hume.tts.PostedVoice, requestOptions?: Voices.RequestOptions): core.HttpResponsePromise<Hume.tts.ReturnVoice>;
|
|
62
|
+
private __create;
|
|
60
63
|
/**
|
|
61
64
|
* Deletes a previously generated custom voice.
|
|
62
65
|
*
|
|
@@ -70,7 +73,8 @@ export declare class Voices {
|
|
|
70
73
|
* name: "David Hume"
|
|
71
74
|
* })
|
|
72
75
|
*/
|
|
73
|
-
delete(request: Hume.tts.VoicesDeleteRequest, requestOptions?: Voices.RequestOptions):
|
|
76
|
+
delete(request: Hume.tts.VoicesDeleteRequest, requestOptions?: Voices.RequestOptions): core.HttpResponsePromise<void>;
|
|
77
|
+
private __delete;
|
|
74
78
|
protected _getCustomAuthorizationHeaders(): Promise<{
|
|
75
79
|
"X-Hume-Api-Key": string | undefined;
|
|
76
80
|
}>;
|