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.
Files changed (203) hide show
  1. package/.mock/definition/empathic-voice/__package__.yml +24 -0
  2. package/.mock/definition/empathic-voice/configs.yml +2 -0
  3. package/.mock/definition/tts/__package__.yml +28 -0
  4. package/.mock/fern.config.json +1 -1
  5. package/Client.d.ts +11 -7
  6. package/Client.js +54 -6
  7. package/api/resources/empathicVoice/errors/BadRequestError.d.ts +2 -1
  8. package/api/resources/empathicVoice/errors/BadRequestError.js +2 -1
  9. package/api/resources/empathicVoice/resources/chatGroups/client/Client.d.ts +7 -3
  10. package/api/resources/empathicVoice/resources/chatGroups/client/Client.js +79 -52
  11. package/api/resources/empathicVoice/resources/chats/client/Client.d.ts +5 -2
  12. package/api/resources/empathicVoice/resources/chats/client/Client.js +59 -39
  13. package/api/resources/empathicVoice/resources/configs/client/Client.d.ts +17 -8
  14. package/api/resources/empathicVoice/resources/configs/client/Client.js +144 -83
  15. package/api/resources/empathicVoice/resources/configs/client/requests/PostedConfig.d.ts +1 -0
  16. package/api/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.d.ts +1 -0
  17. package/api/resources/empathicVoice/resources/customVoices/client/Client.d.ts +13 -6
  18. package/api/resources/empathicVoice/resources/customVoices/client/Client.js +95 -53
  19. package/api/resources/empathicVoice/resources/prompts/client/Client.d.ts +19 -9
  20. package/api/resources/empathicVoice/resources/prompts/client/Client.js +143 -81
  21. package/api/resources/empathicVoice/resources/tools/client/Client.d.ts +17 -8
  22. package/api/resources/empathicVoice/resources/tools/client/Client.js +144 -83
  23. package/api/resources/empathicVoice/types/PostedNudgeSpec.d.ts +12 -0
  24. package/api/resources/empathicVoice/types/PostedNudgeSpec.js +5 -0
  25. package/api/resources/empathicVoice/types/ReturnConfig.d.ts +1 -0
  26. package/api/resources/empathicVoice/types/ReturnNudgeSpec.d.ts +12 -0
  27. package/api/resources/empathicVoice/types/ReturnNudgeSpec.js +5 -0
  28. package/api/resources/empathicVoice/types/WebhookEventChatStatus.d.ts +2 -1
  29. package/api/resources/empathicVoice/types/WebhookEventChatStatus.js +1 -0
  30. package/api/resources/empathicVoice/types/index.d.ts +2 -0
  31. package/api/resources/empathicVoice/types/index.js +2 -0
  32. package/api/resources/expressionMeasurement/client/Client.d.ts +2 -0
  33. package/api/resources/expressionMeasurement/resources/batch/client/Client.d.ts +15 -7
  34. package/api/resources/expressionMeasurement/resources/batch/client/Client.js +96 -52
  35. package/api/resources/tts/client/Client.d.ts +27 -19
  36. package/api/resources/tts/client/Client.js +89 -50
  37. package/api/resources/tts/client/index.d.ts +1 -1
  38. package/api/resources/tts/client/index.js +15 -0
  39. package/api/resources/tts/client/requests/SynthesizeJsonRequest.d.ts +36 -0
  40. package/api/resources/tts/client/requests/SynthesizeJsonRequest.js +5 -0
  41. package/api/resources/tts/client/requests/index.d.ts +1 -0
  42. package/api/resources/tts/client/requests/index.js +2 -0
  43. package/api/resources/tts/errors/BadRequestError.d.ts +2 -1
  44. package/api/resources/tts/errors/BadRequestError.js +2 -1
  45. package/api/resources/tts/errors/UnprocessableEntityError.d.ts +2 -1
  46. package/api/resources/tts/errors/UnprocessableEntityError.js +2 -1
  47. package/api/resources/tts/resources/voices/client/Client.d.ts +7 -3
  48. package/api/resources/tts/resources/voices/client/Client.js +49 -29
  49. package/api/resources/tts/types/Snippet.d.ts +2 -0
  50. package/api/resources/tts/types/SnippetAudioChunk.d.ts +2 -0
  51. package/core/fetcher/APIResponse.d.ts +10 -0
  52. package/core/fetcher/Fetcher.d.ts +2 -1
  53. package/core/fetcher/Fetcher.js +29 -9
  54. package/core/fetcher/Headers.d.ts +2 -0
  55. package/core/fetcher/Headers.js +84 -0
  56. package/core/fetcher/HttpResponsePromise.d.ts +58 -0
  57. package/core/fetcher/HttpResponsePromise.js +103 -0
  58. package/core/fetcher/RawResponse.d.ts +29 -0
  59. package/core/fetcher/RawResponse.js +44 -0
  60. package/core/fetcher/index.d.ts +3 -0
  61. package/core/fetcher/index.js +7 -1
  62. package/core/form-data-utils/FormDataWrapper.d.ts +3 -0
  63. package/core/form-data-utils/FormDataWrapper.js +53 -13
  64. package/core/form-data-utils/toReadableStream.d.ts +1 -0
  65. package/core/form-data-utils/toReadableStream.js +50 -0
  66. package/core/headers.d.ts +3 -0
  67. package/core/headers.js +29 -0
  68. package/core/index.d.ts +4 -4
  69. package/core/index.js +5 -4
  70. package/core/pagination/Page.d.ts +5 -2
  71. package/core/pagination/Page.js +5 -2
  72. package/core/pagination/Pageable.d.ts +2 -0
  73. package/core/runtime/runtime.js +0 -1
  74. package/dist/Client.d.ts +11 -7
  75. package/dist/Client.js +54 -6
  76. package/dist/api/resources/empathicVoice/errors/BadRequestError.d.ts +2 -1
  77. package/dist/api/resources/empathicVoice/errors/BadRequestError.js +2 -1
  78. package/dist/api/resources/empathicVoice/resources/chatGroups/client/Client.d.ts +7 -3
  79. package/dist/api/resources/empathicVoice/resources/chatGroups/client/Client.js +79 -52
  80. package/dist/api/resources/empathicVoice/resources/chats/client/Client.d.ts +5 -2
  81. package/dist/api/resources/empathicVoice/resources/chats/client/Client.js +59 -39
  82. package/dist/api/resources/empathicVoice/resources/configs/client/Client.d.ts +17 -8
  83. package/dist/api/resources/empathicVoice/resources/configs/client/Client.js +144 -83
  84. package/dist/api/resources/empathicVoice/resources/configs/client/requests/PostedConfig.d.ts +1 -0
  85. package/dist/api/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.d.ts +1 -0
  86. package/dist/api/resources/empathicVoice/resources/customVoices/client/Client.d.ts +13 -6
  87. package/dist/api/resources/empathicVoice/resources/customVoices/client/Client.js +95 -53
  88. package/dist/api/resources/empathicVoice/resources/prompts/client/Client.d.ts +19 -9
  89. package/dist/api/resources/empathicVoice/resources/prompts/client/Client.js +143 -81
  90. package/dist/api/resources/empathicVoice/resources/tools/client/Client.d.ts +17 -8
  91. package/dist/api/resources/empathicVoice/resources/tools/client/Client.js +144 -83
  92. package/dist/api/resources/empathicVoice/types/PostedNudgeSpec.d.ts +12 -0
  93. package/dist/api/resources/empathicVoice/types/PostedNudgeSpec.js +5 -0
  94. package/dist/api/resources/empathicVoice/types/ReturnConfig.d.ts +1 -0
  95. package/dist/api/resources/empathicVoice/types/ReturnNudgeSpec.d.ts +12 -0
  96. package/dist/api/resources/empathicVoice/types/ReturnNudgeSpec.js +5 -0
  97. package/dist/api/resources/empathicVoice/types/WebhookEventChatStatus.d.ts +2 -1
  98. package/dist/api/resources/empathicVoice/types/WebhookEventChatStatus.js +1 -0
  99. package/dist/api/resources/empathicVoice/types/index.d.ts +2 -0
  100. package/dist/api/resources/empathicVoice/types/index.js +2 -0
  101. package/dist/api/resources/expressionMeasurement/client/Client.d.ts +2 -0
  102. package/dist/api/resources/expressionMeasurement/resources/batch/client/Client.d.ts +15 -7
  103. package/dist/api/resources/expressionMeasurement/resources/batch/client/Client.js +96 -52
  104. package/dist/api/resources/tts/client/Client.d.ts +27 -19
  105. package/dist/api/resources/tts/client/Client.js +89 -50
  106. package/dist/api/resources/tts/client/index.d.ts +1 -1
  107. package/dist/api/resources/tts/client/index.js +15 -0
  108. package/dist/api/resources/tts/client/requests/SynthesizeJsonRequest.d.ts +36 -0
  109. package/dist/api/resources/tts/client/requests/SynthesizeJsonRequest.js +5 -0
  110. package/dist/api/resources/tts/client/requests/index.d.ts +1 -0
  111. package/dist/api/resources/tts/client/requests/index.js +2 -0
  112. package/dist/api/resources/tts/errors/BadRequestError.d.ts +2 -1
  113. package/dist/api/resources/tts/errors/BadRequestError.js +2 -1
  114. package/dist/api/resources/tts/errors/UnprocessableEntityError.d.ts +2 -1
  115. package/dist/api/resources/tts/errors/UnprocessableEntityError.js +2 -1
  116. package/dist/api/resources/tts/resources/voices/client/Client.d.ts +7 -3
  117. package/dist/api/resources/tts/resources/voices/client/Client.js +49 -29
  118. package/dist/api/resources/tts/types/Snippet.d.ts +2 -0
  119. package/dist/api/resources/tts/types/SnippetAudioChunk.d.ts +2 -0
  120. package/dist/core/fetcher/APIResponse.d.ts +10 -0
  121. package/dist/core/fetcher/Fetcher.d.ts +2 -1
  122. package/dist/core/fetcher/Fetcher.js +29 -9
  123. package/dist/core/fetcher/Headers.d.ts +2 -0
  124. package/dist/core/fetcher/Headers.js +84 -0
  125. package/dist/core/fetcher/HttpResponsePromise.d.ts +58 -0
  126. package/dist/core/fetcher/HttpResponsePromise.js +103 -0
  127. package/dist/core/fetcher/RawResponse.d.ts +29 -0
  128. package/dist/core/fetcher/RawResponse.js +44 -0
  129. package/dist/core/fetcher/index.d.ts +3 -0
  130. package/dist/core/fetcher/index.js +7 -1
  131. package/dist/core/form-data-utils/FormDataWrapper.d.ts +3 -0
  132. package/dist/core/form-data-utils/FormDataWrapper.js +53 -13
  133. package/dist/core/form-data-utils/toReadableStream.d.ts +1 -0
  134. package/dist/core/form-data-utils/toReadableStream.js +50 -0
  135. package/dist/core/headers.d.ts +3 -0
  136. package/dist/core/headers.js +29 -0
  137. package/dist/core/index.d.ts +4 -4
  138. package/dist/core/index.js +5 -4
  139. package/dist/core/pagination/Page.d.ts +5 -2
  140. package/dist/core/pagination/Page.js +5 -2
  141. package/dist/core/pagination/Pageable.d.ts +2 -0
  142. package/dist/core/runtime/runtime.js +0 -1
  143. package/dist/errors/HumeError.d.ts +7 -2
  144. package/dist/errors/HumeError.js +10 -10
  145. package/dist/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfig.d.ts +2 -0
  146. package/dist/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfig.js +2 -0
  147. package/dist/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.d.ts +2 -0
  148. package/dist/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.js +2 -0
  149. package/dist/serialization/resources/empathicVoice/types/PostedNudgeSpec.d.ts +13 -0
  150. package/dist/serialization/resources/empathicVoice/types/PostedNudgeSpec.js +44 -0
  151. package/dist/serialization/resources/empathicVoice/types/ReturnConfig.d.ts +2 -0
  152. package/dist/serialization/resources/empathicVoice/types/ReturnConfig.js +2 -0
  153. package/dist/serialization/resources/empathicVoice/types/ReturnNudgeSpec.d.ts +13 -0
  154. package/dist/serialization/resources/empathicVoice/types/ReturnNudgeSpec.js +44 -0
  155. package/dist/serialization/resources/empathicVoice/types/WebhookEventChatStatus.d.ts +1 -1
  156. package/dist/serialization/resources/empathicVoice/types/WebhookEventChatStatus.js +1 -0
  157. package/dist/serialization/resources/empathicVoice/types/index.d.ts +2 -0
  158. package/dist/serialization/resources/empathicVoice/types/index.js +2 -0
  159. package/dist/serialization/resources/tts/types/Snippet.d.ts +1 -0
  160. package/dist/serialization/resources/tts/types/Snippet.js +1 -0
  161. package/dist/serialization/resources/tts/types/SnippetAudioChunk.d.ts +1 -0
  162. package/dist/serialization/resources/tts/types/SnippetAudioChunk.js +1 -0
  163. package/dist/version.d.ts +1 -1
  164. package/dist/version.js +1 -1
  165. package/dist/wrapper/expressionMeasurement/ExpressionMeasurementClient.js +2 -0
  166. package/dist/wrapper/expressionMeasurement/batch/BatchClient.d.ts +2 -1
  167. package/dist/wrapper/expressionMeasurement/batch/BatchClient.js +43 -17
  168. package/errors/HumeError.d.ts +7 -2
  169. package/errors/HumeError.js +10 -10
  170. package/package.json +9 -4
  171. package/reference.md +17 -15
  172. package/scripts/rename-to-esm-files.js +10 -2
  173. package/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfig.d.ts +2 -0
  174. package/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfig.js +2 -0
  175. package/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.d.ts +2 -0
  176. package/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.js +2 -0
  177. package/serialization/resources/empathicVoice/types/PostedNudgeSpec.d.ts +13 -0
  178. package/serialization/resources/empathicVoice/types/PostedNudgeSpec.js +44 -0
  179. package/serialization/resources/empathicVoice/types/ReturnConfig.d.ts +2 -0
  180. package/serialization/resources/empathicVoice/types/ReturnConfig.js +2 -0
  181. package/serialization/resources/empathicVoice/types/ReturnNudgeSpec.d.ts +13 -0
  182. package/serialization/resources/empathicVoice/types/ReturnNudgeSpec.js +44 -0
  183. package/serialization/resources/empathicVoice/types/WebhookEventChatStatus.d.ts +1 -1
  184. package/serialization/resources/empathicVoice/types/WebhookEventChatStatus.js +1 -0
  185. package/serialization/resources/empathicVoice/types/index.d.ts +2 -0
  186. package/serialization/resources/empathicVoice/types/index.js +2 -0
  187. package/serialization/resources/tts/types/Snippet.d.ts +1 -0
  188. package/serialization/resources/tts/types/Snippet.js +1 -0
  189. package/serialization/resources/tts/types/SnippetAudioChunk.d.ts +1 -0
  190. package/serialization/resources/tts/types/SnippetAudioChunk.js +1 -0
  191. package/version.d.ts +1 -1
  192. package/version.js +1 -1
  193. package/wrapper/expressionMeasurement/ExpressionMeasurementClient.js +2 -0
  194. package/wrapper/expressionMeasurement/batch/BatchClient.d.ts +2 -1
  195. package/wrapper/expressionMeasurement/batch/BatchClient.js +43 -17
  196. /package/core/{streaming-fetcher → stream}/Stream.d.ts +0 -0
  197. /package/core/{streaming-fetcher → stream}/Stream.js +0 -0
  198. /package/core/{streaming-fetcher → stream}/index.d.ts +0 -0
  199. /package/core/{streaming-fetcher → stream}/index.js +0 -0
  200. /package/dist/core/{streaming-fetcher → stream}/Stream.d.ts +0 -0
  201. /package/dist/core/{streaming-fetcher → stream}/Stream.js +0 -0
  202. /package/dist/core/{streaming-fetcher → stream}/index.d.ts +0 -0
  203. /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.PostedTts} request
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
- * utterances: [{
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: "How can people see beauty so differently?",
86
- * description: "A curious student with a clear and respectful tone, seeking clarification on Hume's ideas with a straightforward question."
87
- * }]
88
- * },
89
- * format: {
90
- * type: "mp3"
91
- * },
92
- * numGenerations: 1
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: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.11.1", "User-Agent": "hume/0.11.1", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.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(request, { unrecognizedObjectKeys: "strip" }),
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 serializers.tts.ReturnTts.parseOrThrow(_response.body, {
111
- unrecognizedObjectKeys: "passthrough",
112
- allowUnrecognizedUnionMembers: true,
113
- allowUnrecognizedEnumValues: true,
114
- breadcrumbsPrefix: ["response"],
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: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.11.1", "User-Agent": "hume/0.11.1", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.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: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.11.1", "User-Agent": "hume/0.11.1", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.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: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.11.1", "User-Agent": "hume/0.11.1", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.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 new core.Stream({
278
- stream: _response.body,
279
- parse: (data) => __awaiter(this, void 0, void 0, function* () {
280
- return serializers.tts.SnippetAudioChunk.parseOrThrow(data, {
281
- unrecognizedObjectKeys: "passthrough",
282
- allowUnrecognizedUnionMembers: true,
283
- allowUnrecognizedEnumValues: true,
284
- breadcrumbsPrefix: ["response"],
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
- signal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
288
- eventShape: {
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,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export { type SynthesizeJsonRequest } from "./SynthesizeJsonRequest";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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): Promise<Hume.tts.ReturnVoice>;
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): Promise<void>;
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
  }>;