hume 0.11.1 → 0.11.2

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 (176) 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 +4 -2
  10. package/api/resources/empathicVoice/resources/chatGroups/client/Client.js +74 -40
  11. package/api/resources/empathicVoice/resources/chats/client/Client.d.ts +2 -1
  12. package/api/resources/empathicVoice/resources/chats/client/Client.js +55 -30
  13. package/api/resources/empathicVoice/resources/configs/client/Client.d.ts +14 -7
  14. package/api/resources/empathicVoice/resources/configs/client/Client.js +134 -64
  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 +10 -5
  18. package/api/resources/empathicVoice/resources/customVoices/client/Client.js +88 -41
  19. package/api/resources/empathicVoice/resources/prompts/client/Client.d.ts +16 -8
  20. package/api/resources/empathicVoice/resources/prompts/client/Client.js +133 -62
  21. package/api/resources/empathicVoice/resources/tools/client/Client.d.ts +14 -7
  22. package/api/resources/empathicVoice/resources/tools/client/Client.js +134 -64
  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/resources/batch/client/Client.d.ts +12 -6
  33. package/api/resources/expressionMeasurement/resources/batch/client/Client.js +89 -38
  34. package/api/resources/tts/client/Client.d.ts +24 -18
  35. package/api/resources/tts/client/Client.js +84 -46
  36. package/api/resources/tts/client/index.d.ts +1 -1
  37. package/api/resources/tts/client/index.js +15 -0
  38. package/api/resources/tts/client/requests/SynthesizeJsonRequest.d.ts +36 -0
  39. package/api/resources/tts/client/requests/SynthesizeJsonRequest.js +5 -0
  40. package/api/resources/tts/client/requests/index.d.ts +1 -0
  41. package/api/resources/tts/client/requests/index.js +2 -0
  42. package/api/resources/tts/errors/BadRequestError.d.ts +2 -1
  43. package/api/resources/tts/errors/BadRequestError.js +2 -1
  44. package/api/resources/tts/errors/UnprocessableEntityError.d.ts +2 -1
  45. package/api/resources/tts/errors/UnprocessableEntityError.js +2 -1
  46. package/api/resources/tts/resources/voices/client/Client.d.ts +4 -2
  47. package/api/resources/tts/resources/voices/client/Client.js +45 -22
  48. package/api/resources/tts/types/Snippet.d.ts +2 -0
  49. package/api/resources/tts/types/SnippetAudioChunk.d.ts +2 -0
  50. package/core/fetcher/APIResponse.d.ts +10 -0
  51. package/core/fetcher/Fetcher.js +7 -0
  52. package/core/fetcher/Headers.d.ts +2 -0
  53. package/core/fetcher/Headers.js +84 -0
  54. package/core/fetcher/HttpResponsePromise.d.ts +58 -0
  55. package/core/fetcher/HttpResponsePromise.js +103 -0
  56. package/core/fetcher/RawResponse.d.ts +29 -0
  57. package/core/fetcher/RawResponse.js +44 -0
  58. package/core/fetcher/index.d.ts +3 -0
  59. package/core/fetcher/index.js +7 -1
  60. package/core/form-data-utils/FormDataWrapper.d.ts +3 -0
  61. package/core/form-data-utils/FormDataWrapper.js +48 -9
  62. package/core/pagination/Page.d.ts +5 -2
  63. package/core/pagination/Page.js +5 -2
  64. package/core/pagination/Pageable.d.ts +2 -0
  65. package/dist/Client.d.ts +11 -7
  66. package/dist/Client.js +54 -6
  67. package/dist/api/resources/empathicVoice/errors/BadRequestError.d.ts +2 -1
  68. package/dist/api/resources/empathicVoice/errors/BadRequestError.js +2 -1
  69. package/dist/api/resources/empathicVoice/resources/chatGroups/client/Client.d.ts +4 -2
  70. package/dist/api/resources/empathicVoice/resources/chatGroups/client/Client.js +74 -40
  71. package/dist/api/resources/empathicVoice/resources/chats/client/Client.d.ts +2 -1
  72. package/dist/api/resources/empathicVoice/resources/chats/client/Client.js +55 -30
  73. package/dist/api/resources/empathicVoice/resources/configs/client/Client.d.ts +14 -7
  74. package/dist/api/resources/empathicVoice/resources/configs/client/Client.js +134 -64
  75. package/dist/api/resources/empathicVoice/resources/configs/client/requests/PostedConfig.d.ts +1 -0
  76. package/dist/api/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.d.ts +1 -0
  77. package/dist/api/resources/empathicVoice/resources/customVoices/client/Client.d.ts +10 -5
  78. package/dist/api/resources/empathicVoice/resources/customVoices/client/Client.js +88 -41
  79. package/dist/api/resources/empathicVoice/resources/prompts/client/Client.d.ts +16 -8
  80. package/dist/api/resources/empathicVoice/resources/prompts/client/Client.js +133 -62
  81. package/dist/api/resources/empathicVoice/resources/tools/client/Client.d.ts +14 -7
  82. package/dist/api/resources/empathicVoice/resources/tools/client/Client.js +134 -64
  83. package/dist/api/resources/empathicVoice/types/PostedNudgeSpec.d.ts +12 -0
  84. package/dist/api/resources/empathicVoice/types/PostedNudgeSpec.js +5 -0
  85. package/dist/api/resources/empathicVoice/types/ReturnConfig.d.ts +1 -0
  86. package/dist/api/resources/empathicVoice/types/ReturnNudgeSpec.d.ts +12 -0
  87. package/dist/api/resources/empathicVoice/types/ReturnNudgeSpec.js +5 -0
  88. package/dist/api/resources/empathicVoice/types/WebhookEventChatStatus.d.ts +2 -1
  89. package/dist/api/resources/empathicVoice/types/WebhookEventChatStatus.js +1 -0
  90. package/dist/api/resources/empathicVoice/types/index.d.ts +2 -0
  91. package/dist/api/resources/empathicVoice/types/index.js +2 -0
  92. package/dist/api/resources/expressionMeasurement/resources/batch/client/Client.d.ts +12 -6
  93. package/dist/api/resources/expressionMeasurement/resources/batch/client/Client.js +89 -38
  94. package/dist/api/resources/tts/client/Client.d.ts +24 -18
  95. package/dist/api/resources/tts/client/Client.js +84 -46
  96. package/dist/api/resources/tts/client/index.d.ts +1 -1
  97. package/dist/api/resources/tts/client/index.js +15 -0
  98. package/dist/api/resources/tts/client/requests/SynthesizeJsonRequest.d.ts +36 -0
  99. package/dist/api/resources/tts/client/requests/SynthesizeJsonRequest.js +5 -0
  100. package/dist/api/resources/tts/client/requests/index.d.ts +1 -0
  101. package/dist/api/resources/tts/client/requests/index.js +2 -0
  102. package/dist/api/resources/tts/errors/BadRequestError.d.ts +2 -1
  103. package/dist/api/resources/tts/errors/BadRequestError.js +2 -1
  104. package/dist/api/resources/tts/errors/UnprocessableEntityError.d.ts +2 -1
  105. package/dist/api/resources/tts/errors/UnprocessableEntityError.js +2 -1
  106. package/dist/api/resources/tts/resources/voices/client/Client.d.ts +4 -2
  107. package/dist/api/resources/tts/resources/voices/client/Client.js +45 -22
  108. package/dist/api/resources/tts/types/Snippet.d.ts +2 -0
  109. package/dist/api/resources/tts/types/SnippetAudioChunk.d.ts +2 -0
  110. package/dist/core/fetcher/APIResponse.d.ts +10 -0
  111. package/dist/core/fetcher/Fetcher.js +7 -0
  112. package/dist/core/fetcher/Headers.d.ts +2 -0
  113. package/dist/core/fetcher/Headers.js +84 -0
  114. package/dist/core/fetcher/HttpResponsePromise.d.ts +58 -0
  115. package/dist/core/fetcher/HttpResponsePromise.js +103 -0
  116. package/dist/core/fetcher/RawResponse.d.ts +29 -0
  117. package/dist/core/fetcher/RawResponse.js +44 -0
  118. package/dist/core/fetcher/index.d.ts +3 -0
  119. package/dist/core/fetcher/index.js +7 -1
  120. package/dist/core/form-data-utils/FormDataWrapper.d.ts +3 -0
  121. package/dist/core/form-data-utils/FormDataWrapper.js +48 -9
  122. package/dist/core/pagination/Page.d.ts +5 -2
  123. package/dist/core/pagination/Page.js +5 -2
  124. package/dist/core/pagination/Pageable.d.ts +2 -0
  125. package/dist/errors/HumeError.d.ts +7 -2
  126. package/dist/errors/HumeError.js +10 -10
  127. package/dist/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfig.d.ts +2 -0
  128. package/dist/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfig.js +2 -0
  129. package/dist/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.d.ts +2 -0
  130. package/dist/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.js +2 -0
  131. package/dist/serialization/resources/empathicVoice/types/PostedNudgeSpec.d.ts +13 -0
  132. package/dist/serialization/resources/empathicVoice/types/PostedNudgeSpec.js +44 -0
  133. package/dist/serialization/resources/empathicVoice/types/ReturnConfig.d.ts +2 -0
  134. package/dist/serialization/resources/empathicVoice/types/ReturnConfig.js +2 -0
  135. package/dist/serialization/resources/empathicVoice/types/ReturnNudgeSpec.d.ts +13 -0
  136. package/dist/serialization/resources/empathicVoice/types/ReturnNudgeSpec.js +44 -0
  137. package/dist/serialization/resources/empathicVoice/types/WebhookEventChatStatus.d.ts +1 -1
  138. package/dist/serialization/resources/empathicVoice/types/WebhookEventChatStatus.js +1 -0
  139. package/dist/serialization/resources/empathicVoice/types/index.d.ts +2 -0
  140. package/dist/serialization/resources/empathicVoice/types/index.js +2 -0
  141. package/dist/serialization/resources/tts/types/Snippet.d.ts +1 -0
  142. package/dist/serialization/resources/tts/types/Snippet.js +1 -0
  143. package/dist/serialization/resources/tts/types/SnippetAudioChunk.d.ts +1 -0
  144. package/dist/serialization/resources/tts/types/SnippetAudioChunk.js +1 -0
  145. package/dist/version.d.ts +1 -1
  146. package/dist/version.js +1 -1
  147. package/dist/wrapper/expressionMeasurement/ExpressionMeasurementClient.js +2 -0
  148. package/dist/wrapper/expressionMeasurement/batch/BatchClient.d.ts +2 -1
  149. package/dist/wrapper/expressionMeasurement/batch/BatchClient.js +43 -17
  150. package/errors/HumeError.d.ts +7 -2
  151. package/errors/HumeError.js +10 -10
  152. package/package.json +3 -2
  153. package/reference.md +17 -15
  154. package/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfig.d.ts +2 -0
  155. package/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfig.js +2 -0
  156. package/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.d.ts +2 -0
  157. package/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.js +2 -0
  158. package/serialization/resources/empathicVoice/types/PostedNudgeSpec.d.ts +13 -0
  159. package/serialization/resources/empathicVoice/types/PostedNudgeSpec.js +44 -0
  160. package/serialization/resources/empathicVoice/types/ReturnConfig.d.ts +2 -0
  161. package/serialization/resources/empathicVoice/types/ReturnConfig.js +2 -0
  162. package/serialization/resources/empathicVoice/types/ReturnNudgeSpec.d.ts +13 -0
  163. package/serialization/resources/empathicVoice/types/ReturnNudgeSpec.js +44 -0
  164. package/serialization/resources/empathicVoice/types/WebhookEventChatStatus.d.ts +1 -1
  165. package/serialization/resources/empathicVoice/types/WebhookEventChatStatus.js +1 -0
  166. package/serialization/resources/empathicVoice/types/index.d.ts +2 -0
  167. package/serialization/resources/empathicVoice/types/index.js +2 -0
  168. package/serialization/resources/tts/types/Snippet.d.ts +1 -0
  169. package/serialization/resources/tts/types/Snippet.js +1 -0
  170. package/serialization/resources/tts/types/SnippetAudioChunk.d.ts +1 -0
  171. package/serialization/resources/tts/types/SnippetAudioChunk.js +1 -0
  172. package/version.d.ts +1 -1
  173. package/version.js +1 -1
  174. package/wrapper/expressionMeasurement/ExpressionMeasurementClient.js +2 -0
  175. package/wrapper/expressionMeasurement/batch/BatchClient.d.ts +2 -1
  176. package/wrapper/expressionMeasurement/batch/BatchClient.js +43 -17
@@ -69,50 +69,64 @@ class Tts {
69
69
  *
70
70
  * The response includes the base64-encoded audio and metadata in JSON format.
71
71
  *
72
- * @param {Hume.tts.PostedTts} request
72
+ * @param {Hume.tts.SynthesizeJsonRequest} request
73
73
  * @param {Tts.RequestOptions} requestOptions - Request-specific configuration.
74
74
  *
75
75
  * @throws {@link Hume.tts.UnprocessableEntityError}
76
76
  *
77
77
  * @example
78
78
  * 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: {
79
+ * body: {
84
80
  * 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
81
+ * text: "Beauty is no quality in things themselves: It exists merely in the mind which contemplates them.",
82
+ * description: "Middle-aged masculine voice with a clear, rhythmic Scots lilt, rounded vowels, and a warm, steady tone with an articulate, academic quality."
83
+ * }],
84
+ * context: {
85
+ * utterances: [{
86
+ * text: "How can people see beauty so differently?",
87
+ * description: "A curious student with a clear and respectful tone, seeking clarification on Hume's ideas with a straightforward question."
88
+ * }]
89
+ * },
90
+ * format: {
91
+ * type: "mp3"
92
+ * },
93
+ * numGenerations: 1
94
+ * }
93
95
  * })
94
96
  */
95
97
  synthesizeJson(request, requestOptions) {
98
+ return core.HttpResponsePromise.fromPromise(this.__synthesizeJson(request, requestOptions));
99
+ }
100
+ __synthesizeJson(request, requestOptions) {
96
101
  return __awaiter(this, void 0, void 0, function* () {
97
102
  var _a, _b, _c;
103
+ const { accessToken, body: _body } = request;
104
+ const _queryParams = {};
105
+ if (accessToken != null) {
106
+ _queryParams["access_token"] = accessToken;
107
+ }
98
108
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
99
109
  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
110
  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),
111
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.11.2", "User-Agent": "hume/0.11.2", "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),
102
112
  contentType: "application/json",
113
+ queryParameters: _queryParams,
103
114
  requestType: "json",
104
- body: serializers.tts.PostedTts.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
115
+ body: serializers.tts.PostedTts.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }),
105
116
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
106
117
  maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
107
118
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
108
119
  });
109
120
  if (_response.ok) {
110
- return serializers.tts.ReturnTts.parseOrThrow(_response.body, {
111
- unrecognizedObjectKeys: "passthrough",
112
- allowUnrecognizedUnionMembers: true,
113
- allowUnrecognizedEnumValues: true,
114
- breadcrumbsPrefix: ["response"],
115
- });
121
+ return {
122
+ data: serializers.tts.ReturnTts.parseOrThrow(_response.body, {
123
+ unrecognizedObjectKeys: "passthrough",
124
+ allowUnrecognizedUnionMembers: true,
125
+ allowUnrecognizedEnumValues: true,
126
+ breadcrumbsPrefix: ["response"],
127
+ }),
128
+ rawResponse: _response.rawResponse,
129
+ };
116
130
  }
117
131
  if (_response.error.reason === "status-code") {
118
132
  switch (_response.error.statusCode) {
@@ -122,11 +136,12 @@ class Tts {
122
136
  allowUnrecognizedUnionMembers: true,
123
137
  allowUnrecognizedEnumValues: true,
124
138
  breadcrumbsPrefix: ["response"],
125
- }));
139
+ }), _response.rawResponse);
126
140
  default:
127
141
  throw new errors.HumeError({
128
142
  statusCode: _response.error.statusCode,
129
143
  body: _response.error.body,
144
+ rawResponse: _response.rawResponse,
130
145
  });
131
146
  }
132
147
  }
@@ -135,12 +150,14 @@ class Tts {
135
150
  throw new errors.HumeError({
136
151
  statusCode: _response.error.statusCode,
137
152
  body: _response.error.rawBody,
153
+ rawResponse: _response.rawResponse,
138
154
  });
139
155
  case "timeout":
140
156
  throw new errors.HumeTimeoutError("Timeout exceeded when calling POST /v0/tts.");
141
157
  case "unknown":
142
158
  throw new errors.HumeError({
143
159
  message: _response.error.errorMessage,
160
+ rawResponse: _response.rawResponse,
144
161
  });
145
162
  }
146
163
  });
@@ -152,12 +169,15 @@ class Tts {
152
169
  * @throws {@link Hume.tts.UnprocessableEntityError}
153
170
  */
154
171
  synthesizeFile(request, requestOptions) {
172
+ return core.HttpResponsePromise.fromPromise(this.__synthesizeFile(request, requestOptions));
173
+ }
174
+ __synthesizeFile(request, requestOptions) {
155
175
  return __awaiter(this, void 0, void 0, function* () {
156
176
  var _a, _b, _c;
157
177
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
158
178
  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
179
  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),
180
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.11.2", "User-Agent": "hume/0.11.2", "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),
161
181
  contentType: "application/json",
162
182
  requestType: "json",
163
183
  body: serializers.tts.PostedTts.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -167,7 +187,7 @@ class Tts {
167
187
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
168
188
  });
169
189
  if (_response.ok) {
170
- return _response.body;
190
+ return { data: _response.body, rawResponse: _response.rawResponse };
171
191
  }
172
192
  if (_response.error.reason === "status-code") {
173
193
  switch (_response.error.statusCode) {
@@ -177,11 +197,12 @@ class Tts {
177
197
  allowUnrecognizedUnionMembers: true,
178
198
  allowUnrecognizedEnumValues: true,
179
199
  breadcrumbsPrefix: ["response"],
180
- }));
200
+ }), _response.rawResponse);
181
201
  default:
182
202
  throw new errors.HumeError({
183
203
  statusCode: _response.error.statusCode,
184
204
  body: _response.error.body,
205
+ rawResponse: _response.rawResponse,
185
206
  });
186
207
  }
187
208
  }
@@ -190,12 +211,14 @@ class Tts {
190
211
  throw new errors.HumeError({
191
212
  statusCode: _response.error.statusCode,
192
213
  body: _response.error.rawBody,
214
+ rawResponse: _response.rawResponse,
193
215
  });
194
216
  case "timeout":
195
217
  throw new errors.HumeTimeoutError("Timeout exceeded when calling POST /v0/tts/file.");
196
218
  case "unknown":
197
219
  throw new errors.HumeError({
198
220
  message: _response.error.errorMessage,
221
+ rawResponse: _response.rawResponse,
199
222
  });
200
223
  }
201
224
  });
@@ -205,12 +228,15 @@ class Tts {
205
228
  * @throws {@link Hume.tts.UnprocessableEntityError}
206
229
  */
207
230
  synthesizeFileStreaming(request, requestOptions) {
231
+ return core.HttpResponsePromise.fromPromise(this.__synthesizeFileStreaming(request, requestOptions));
232
+ }
233
+ __synthesizeFileStreaming(request, requestOptions) {
208
234
  return __awaiter(this, void 0, void 0, function* () {
209
235
  var _a, _b, _c;
210
236
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
211
237
  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
238
  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),
239
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.11.2", "User-Agent": "hume/0.11.2", "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),
214
240
  contentType: "application/json",
215
241
  requestType: "json",
216
242
  body: serializers.tts.PostedTts.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -220,7 +246,7 @@ class Tts {
220
246
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
221
247
  });
222
248
  if (_response.ok) {
223
- return _response.body;
249
+ return { data: _response.body, rawResponse: _response.rawResponse };
224
250
  }
225
251
  if (_response.error.reason === "status-code") {
226
252
  switch (_response.error.statusCode) {
@@ -230,11 +256,12 @@ class Tts {
230
256
  allowUnrecognizedUnionMembers: true,
231
257
  allowUnrecognizedEnumValues: true,
232
258
  breadcrumbsPrefix: ["response"],
233
- }));
259
+ }), _response.rawResponse);
234
260
  default:
235
261
  throw new errors.HumeError({
236
262
  statusCode: _response.error.statusCode,
237
263
  body: _response.error.body,
264
+ rawResponse: _response.rawResponse,
238
265
  });
239
266
  }
240
267
  }
@@ -243,12 +270,14 @@ class Tts {
243
270
  throw new errors.HumeError({
244
271
  statusCode: _response.error.statusCode,
245
272
  body: _response.error.rawBody,
273
+ rawResponse: _response.rawResponse,
246
274
  });
247
275
  case "timeout":
248
276
  throw new errors.HumeTimeoutError("Timeout exceeded when calling POST /v0/tts/stream/file.");
249
277
  case "unknown":
250
278
  throw new errors.HumeError({
251
279
  message: _response.error.errorMessage,
280
+ rawResponse: _response.rawResponse,
252
281
  });
253
282
  }
254
283
  });
@@ -259,12 +288,15 @@ class Tts {
259
288
  * The response is a stream of JSON objects including audio encoded in base64.
260
289
  */
261
290
  synthesizeJsonStreaming(request, requestOptions) {
291
+ return core.HttpResponsePromise.fromPromise(this.__synthesizeJsonStreaming(request, requestOptions));
292
+ }
293
+ __synthesizeJsonStreaming(request, requestOptions) {
262
294
  return __awaiter(this, void 0, void 0, function* () {
263
295
  var _a, _b, _c;
264
296
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
265
297
  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
298
  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),
299
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.11.2", "User-Agent": "hume/0.11.2", "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),
268
300
  contentType: "application/json",
269
301
  requestType: "json",
270
302
  body: serializers.tts.PostedTts.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -274,22 +306,25 @@ class Tts {
274
306
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
275
307
  });
276
308
  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
- });
309
+ return {
310
+ data: new core.Stream({
311
+ stream: _response.body,
312
+ parse: (data) => __awaiter(this, void 0, void 0, function* () {
313
+ return serializers.tts.SnippetAudioChunk.parseOrThrow(data, {
314
+ unrecognizedObjectKeys: "passthrough",
315
+ allowUnrecognizedUnionMembers: true,
316
+ allowUnrecognizedEnumValues: true,
317
+ breadcrumbsPrefix: ["response"],
318
+ });
319
+ }),
320
+ signal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
321
+ eventShape: {
322
+ type: "json",
323
+ messageTerminator: "\n",
324
+ },
286
325
  }),
287
- signal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
288
- eventShape: {
289
- type: "json",
290
- messageTerminator: "\n",
291
- },
292
- });
326
+ rawResponse: _response.rawResponse,
327
+ };
293
328
  }
294
329
  if (_response.error.reason === "status-code") {
295
330
  switch (_response.error.statusCode) {
@@ -299,11 +334,12 @@ class Tts {
299
334
  allowUnrecognizedUnionMembers: true,
300
335
  allowUnrecognizedEnumValues: true,
301
336
  breadcrumbsPrefix: ["response"],
302
- }));
337
+ }), _response.rawResponse);
303
338
  default:
304
339
  throw new errors.HumeError({
305
340
  statusCode: _response.error.statusCode,
306
341
  body: _response.error.body,
342
+ rawResponse: _response.rawResponse,
307
343
  });
308
344
  }
309
345
  }
@@ -312,12 +348,14 @@ class Tts {
312
348
  throw new errors.HumeError({
313
349
  statusCode: _response.error.statusCode,
314
350
  body: _response.error.rawBody,
351
+ rawResponse: _response.rawResponse,
315
352
  });
316
353
  case "timeout":
317
354
  throw new errors.HumeTimeoutError("Timeout exceeded when calling POST /v0/tts/stream/json.");
318
355
  case "unknown":
319
356
  throw new errors.HumeError({
320
357
  message: _response.error.errorMessage,
358
+ rawResponse: _response.rawResponse,
321
359
  });
322
360
  }
323
361
  });
@@ -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
  }
@@ -56,7 +56,8 @@ export declare class Voices {
56
56
  * name: "David Hume"
57
57
  * })
58
58
  */
59
- create(request: Hume.tts.PostedVoice, requestOptions?: Voices.RequestOptions): Promise<Hume.tts.ReturnVoice>;
59
+ create(request: Hume.tts.PostedVoice, requestOptions?: Voices.RequestOptions): core.HttpResponsePromise<Hume.tts.ReturnVoice>;
60
+ private __create;
60
61
  /**
61
62
  * Deletes a previously generated custom voice.
62
63
  *
@@ -70,7 +71,8 @@ export declare class Voices {
70
71
  * name: "David Hume"
71
72
  * })
72
73
  */
73
- delete(request: Hume.tts.VoicesDeleteRequest, requestOptions?: Voices.RequestOptions): Promise<void>;
74
+ delete(request: Hume.tts.VoicesDeleteRequest, requestOptions?: Voices.RequestOptions): core.HttpResponsePromise<void>;
75
+ private __delete;
74
76
  protected _getCustomAuthorizationHeaders(): Promise<{
75
77
  "X-Hume-Api-Key": string | undefined;
76
78
  }>;