@humeai/audio-decisions 0.0.1 → 0.2.0

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 (896) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +411 -2
  3. package/dist/cjs/BaseClient.d.ts +54 -0
  4. package/dist/cjs/BaseClient.js +77 -0
  5. package/dist/cjs/Client.d.ts +29 -0
  6. package/dist/cjs/Client.js +88 -0
  7. package/dist/cjs/api/errors/BadRequestError.d.ts +7 -0
  8. package/dist/cjs/api/errors/BadRequestError.js +54 -0
  9. package/dist/cjs/api/errors/ContentTooLargeError.d.ts +7 -0
  10. package/dist/cjs/api/errors/ContentTooLargeError.js +54 -0
  11. package/dist/cjs/api/errors/ForbiddenError.d.ts +7 -0
  12. package/dist/cjs/api/errors/ForbiddenError.js +54 -0
  13. package/dist/cjs/api/errors/InternalServerError.d.ts +7 -0
  14. package/dist/cjs/api/errors/InternalServerError.js +54 -0
  15. package/dist/cjs/api/errors/NotFoundError.d.ts +7 -0
  16. package/dist/cjs/api/errors/NotFoundError.js +54 -0
  17. package/dist/cjs/api/errors/PaymentRequiredError.d.ts +7 -0
  18. package/dist/cjs/api/errors/PaymentRequiredError.js +54 -0
  19. package/dist/cjs/api/errors/ServiceUnavailableError.d.ts +7 -0
  20. package/dist/cjs/api/errors/ServiceUnavailableError.js +54 -0
  21. package/dist/cjs/api/errors/TooManyRequestsError.d.ts +7 -0
  22. package/dist/cjs/api/errors/TooManyRequestsError.js +54 -0
  23. package/dist/cjs/api/errors/UnauthorizedError.d.ts +7 -0
  24. package/dist/cjs/api/errors/UnauthorizedError.js +54 -0
  25. package/dist/cjs/api/errors/UnsupportedMediaTypeError.d.ts +7 -0
  26. package/dist/cjs/api/errors/UnsupportedMediaTypeError.js +54 -0
  27. package/dist/cjs/api/errors/index.d.ts +10 -0
  28. package/dist/cjs/api/errors/index.js +26 -0
  29. package/dist/cjs/api/index.d.ts +3 -0
  30. package/dist/cjs/api/index.js +19 -0
  31. package/dist/cjs/api/resources/decisions/client/Client.d.ts +284 -0
  32. package/dist/cjs/api/resources/decisions/client/Client.js +564 -0
  33. package/dist/cjs/api/resources/decisions/client/index.d.ts +1 -0
  34. package/dist/cjs/api/resources/decisions/client/index.js +17 -0
  35. package/dist/cjs/api/resources/decisions/client/requests/DecisionsUpload.d.ts +118 -0
  36. package/dist/cjs/api/resources/decisions/client/requests/DecisionsUpload.js +3 -0
  37. package/dist/cjs/api/resources/decisions/client/requests/InputTokensRequest.d.ts +44 -0
  38. package/dist/cjs/api/resources/decisions/client/requests/InputTokensRequest.js +3 -0
  39. package/dist/cjs/api/resources/decisions/client/requests/index.d.ts +2 -0
  40. package/dist/cjs/api/resources/decisions/client/requests/index.js +2 -0
  41. package/dist/cjs/api/resources/decisions/exports.d.ts +2 -0
  42. package/dist/cjs/api/resources/decisions/exports.js +21 -0
  43. package/dist/cjs/api/resources/decisions/index.d.ts +1 -0
  44. package/dist/cjs/api/resources/decisions/index.js +17 -0
  45. package/dist/cjs/api/resources/index.d.ts +4 -0
  46. package/dist/cjs/api/resources/index.js +43 -0
  47. package/dist/cjs/api/resources/runs/client/Client.d.ts +60 -0
  48. package/dist/cjs/api/resources/runs/client/Client.js +306 -0
  49. package/dist/cjs/api/resources/runs/client/index.d.ts +1 -0
  50. package/dist/cjs/api/resources/runs/client/index.js +17 -0
  51. package/dist/cjs/api/resources/runs/client/requests/GetRunsRequest.d.ts +10 -0
  52. package/dist/cjs/api/resources/runs/client/requests/GetRunsRequest.js +3 -0
  53. package/dist/cjs/api/resources/runs/client/requests/ListRunsRequest.d.ts +19 -0
  54. package/dist/cjs/api/resources/runs/client/requests/ListRunsRequest.js +3 -0
  55. package/dist/cjs/api/resources/runs/client/requests/index.d.ts +2 -0
  56. package/dist/cjs/api/resources/runs/client/requests/index.js +2 -0
  57. package/dist/cjs/api/resources/runs/exports.d.ts +2 -0
  58. package/dist/cjs/api/resources/runs/exports.js +21 -0
  59. package/dist/cjs/api/resources/runs/index.d.ts +1 -0
  60. package/dist/cjs/api/resources/runs/index.js +17 -0
  61. package/dist/cjs/api/types/Answer.d.ts +19 -0
  62. package/dist/cjs/api/types/Answer.js +3 -0
  63. package/dist/cjs/api/types/Answers.d.ts +7 -0
  64. package/dist/cjs/api/types/Answers.js +3 -0
  65. package/dist/cjs/api/types/ChoiceAnswer.d.ts +11 -0
  66. package/dist/cjs/api/types/ChoiceAnswer.js +3 -0
  67. package/dist/cjs/api/types/ChoiceQuestion.d.ts +10 -0
  68. package/dist/cjs/api/types/ChoiceQuestion.js +3 -0
  69. package/dist/cjs/api/types/Criterion.d.ts +9 -0
  70. package/dist/cjs/api/types/Criterion.js +3 -0
  71. package/dist/cjs/api/types/DecisionsRequest.d.ts +9 -0
  72. package/dist/cjs/api/types/DecisionsRequest.js +3 -0
  73. package/dist/cjs/api/types/DecisionsResponse.d.ts +10 -0
  74. package/dist/cjs/api/types/DecisionsResponse.js +3 -0
  75. package/dist/cjs/api/types/ErrorCode.d.ts +58 -0
  76. package/dist/cjs/api/types/ErrorCode.js +61 -0
  77. package/dist/cjs/api/types/ErrorType.d.ts +5 -0
  78. package/dist/cjs/api/types/ErrorType.js +8 -0
  79. package/dist/cjs/api/types/Error_.d.ts +15 -0
  80. package/dist/cjs/api/types/Error_.js +3 -0
  81. package/dist/cjs/api/types/GatewayError.d.ts +9 -0
  82. package/dist/cjs/api/types/GatewayError.js +3 -0
  83. package/dist/cjs/api/types/InputTokensResponse.d.ts +7 -0
  84. package/dist/cjs/api/types/InputTokensResponse.js +3 -0
  85. package/dist/cjs/api/types/NoulAnswer.d.ts +7 -0
  86. package/dist/cjs/api/types/NoulAnswer.js +3 -0
  87. package/dist/cjs/api/types/NoulCriteria.d.ts +9 -0
  88. package/dist/cjs/api/types/NoulCriteria.js +3 -0
  89. package/dist/cjs/api/types/NoulQuestion.d.ts +9 -0
  90. package/dist/cjs/api/types/NoulQuestion.js +3 -0
  91. package/dist/cjs/api/types/Question.d.ts +19 -0
  92. package/dist/cjs/api/types/Question.js +3 -0
  93. package/dist/cjs/api/types/Questions.d.ts +7 -0
  94. package/dist/cjs/api/types/Questions.js +3 -0
  95. package/dist/cjs/api/types/Received.d.ts +7 -0
  96. package/dist/cjs/api/types/Received.js +3 -0
  97. package/dist/cjs/api/types/Run.d.ts +18 -0
  98. package/dist/cjs/api/types/Run.js +3 -0
  99. package/dist/cjs/api/types/RunReceived.d.ts +9 -0
  100. package/dist/cjs/api/types/RunReceived.js +3 -0
  101. package/dist/cjs/api/types/RunStatus.d.ts +6 -0
  102. package/dist/cjs/api/types/RunStatus.js +9 -0
  103. package/dist/cjs/api/types/RunSummary.d.ts +16 -0
  104. package/dist/cjs/api/types/RunSummary.js +3 -0
  105. package/dist/cjs/api/types/RunsPage.d.ts +10 -0
  106. package/dist/cjs/api/types/RunsPage.js +3 -0
  107. package/dist/cjs/api/types/ScoreAnswer.d.ts +13 -0
  108. package/dist/cjs/api/types/ScoreAnswer.js +3 -0
  109. package/dist/cjs/api/types/ScoreQuestion.d.ts +9 -0
  110. package/dist/cjs/api/types/ScoreQuestion.js +3 -0
  111. package/dist/cjs/api/types/Span.d.ts +11 -0
  112. package/dist/cjs/api/types/Span.js +3 -0
  113. package/dist/cjs/api/types/SpanAnswer.d.ts +8 -0
  114. package/dist/cjs/api/types/SpanAnswer.js +3 -0
  115. package/dist/cjs/api/types/SpanQuestion.d.ts +7 -0
  116. package/dist/cjs/api/types/SpanQuestion.js +3 -0
  117. package/dist/cjs/api/types/index.d.ts +28 -0
  118. package/dist/cjs/api/types/index.js +44 -0
  119. package/dist/cjs/audio-helpers/bytes.d.ts +6 -0
  120. package/dist/cjs/audio-helpers/bytes.js +38 -0
  121. package/dist/cjs/audio-helpers/checks.d.ts +2 -0
  122. package/dist/cjs/audio-helpers/checks.js +25 -0
  123. package/dist/cjs/audio-helpers/chunks.d.ts +160 -0
  124. package/dist/cjs/audio-helpers/chunks.js +350 -0
  125. package/dist/cjs/audio-helpers/downmix.d.ts +17 -0
  126. package/dist/cjs/audio-helpers/downmix.js +291 -0
  127. package/dist/cjs/audio-helpers/errors.d.ts +4 -0
  128. package/dist/cjs/audio-helpers/errors.js +12 -0
  129. package/dist/cjs/audio-helpers/files.d.ts +27 -0
  130. package/dist/cjs/audio-helpers/files.js +178 -0
  131. package/dist/cjs/audio-helpers/index.d.ts +4 -0
  132. package/dist/cjs/audio-helpers/index.js +11 -0
  133. package/dist/cjs/audio-helpers/integers.d.ts +3 -0
  134. package/dist/cjs/audio-helpers/integers.js +26 -0
  135. package/dist/cjs/audio-helpers/mp3.d.ts +24 -0
  136. package/dist/cjs/audio-helpers/mp3.js +245 -0
  137. package/dist/cjs/audio-helpers/results.d.ts +74 -0
  138. package/dist/cjs/audio-helpers/results.js +187 -0
  139. package/dist/cjs/audio-helpers/wav.d.ts +21 -0
  140. package/dist/cjs/audio-helpers/wav.js +167 -0
  141. package/dist/cjs/auth/HeaderAuthProvider.d.ts +20 -0
  142. package/dist/cjs/auth/HeaderAuthProvider.js +83 -0
  143. package/dist/cjs/auth/index.d.ts +1 -0
  144. package/dist/cjs/auth/index.js +5 -0
  145. package/dist/cjs/core/auth/AuthProvider.d.ts +8 -0
  146. package/dist/cjs/core/auth/AuthProvider.js +9 -0
  147. package/dist/cjs/core/auth/AuthRequest.d.ts +9 -0
  148. package/dist/cjs/core/auth/AuthRequest.js +2 -0
  149. package/dist/cjs/core/auth/BasicAuth.d.ts +8 -0
  150. package/dist/cjs/core/auth/BasicAuth.js +33 -0
  151. package/dist/cjs/core/auth/BearerToken.d.ts +7 -0
  152. package/dist/cjs/core/auth/BearerToken.js +16 -0
  153. package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +5 -0
  154. package/dist/cjs/core/auth/NoOpAuthProvider.js +9 -0
  155. package/dist/cjs/core/auth/index.d.ts +5 -0
  156. package/dist/cjs/core/auth/index.js +11 -0
  157. package/dist/cjs/core/base64.d.ts +2 -0
  158. package/dist/cjs/core/base64.js +26 -0
  159. package/dist/cjs/core/exports.d.ts +2 -0
  160. package/dist/cjs/core/exports.js +18 -0
  161. package/dist/cjs/core/fetcher/APIResponse.d.ts +20 -0
  162. package/dist/cjs/core/fetcher/APIResponse.js +2 -0
  163. package/dist/cjs/core/fetcher/BinaryResponse.d.ts +19 -0
  164. package/dist/cjs/core/fetcher/BinaryResponse.js +17 -0
  165. package/dist/cjs/core/fetcher/EndpointMetadata.d.ts +13 -0
  166. package/dist/cjs/core/fetcher/EndpointMetadata.js +2 -0
  167. package/dist/cjs/core/fetcher/EndpointSupplier.d.ts +12 -0
  168. package/dist/cjs/core/fetcher/EndpointSupplier.js +22 -0
  169. package/dist/cjs/core/fetcher/Fetcher.d.ts +56 -0
  170. package/dist/cjs/core/fetcher/Fetcher.js +275 -0
  171. package/dist/cjs/core/fetcher/Headers.d.ts +2 -0
  172. package/dist/cjs/core/fetcher/Headers.js +84 -0
  173. package/dist/cjs/core/fetcher/HttpResponsePromise.d.ts +58 -0
  174. package/dist/cjs/core/fetcher/HttpResponsePromise.js +103 -0
  175. package/dist/cjs/core/fetcher/RawResponse.d.ts +29 -0
  176. package/dist/cjs/core/fetcher/RawResponse.js +44 -0
  177. package/dist/cjs/core/fetcher/Supplier.d.ts +4 -0
  178. package/dist/cjs/core/fetcher/Supplier.js +22 -0
  179. package/dist/cjs/core/fetcher/createRequestUrl.d.ts +1 -0
  180. package/dist/cjs/core/fetcher/createRequestUrl.js +8 -0
  181. package/dist/cjs/core/fetcher/getErrorResponseBody.d.ts +1 -0
  182. package/dist/cjs/core/fetcher/getErrorResponseBody.js +58 -0
  183. package/dist/cjs/core/fetcher/getFetchFn.d.ts +1 -0
  184. package/dist/cjs/core/fetcher/getFetchFn.js +17 -0
  185. package/dist/cjs/core/fetcher/getHeader.d.ts +1 -0
  186. package/dist/cjs/core/fetcher/getHeader.js +11 -0
  187. package/dist/cjs/core/fetcher/getRequestBody.d.ts +7 -0
  188. package/dist/cjs/core/fetcher/getRequestBody.js +27 -0
  189. package/dist/cjs/core/fetcher/getResponseBody.d.ts +17 -0
  190. package/dist/cjs/core/fetcher/getResponseBody.js +85 -0
  191. package/dist/cjs/core/fetcher/index.d.ts +13 -0
  192. package/dist/cjs/core/fetcher/index.js +19 -0
  193. package/dist/cjs/core/fetcher/makePassthroughRequest.d.ts +49 -0
  194. package/dist/cjs/core/fetcher/makePassthroughRequest.js +173 -0
  195. package/dist/cjs/core/fetcher/makeRequest.d.ts +11 -0
  196. package/dist/cjs/core/fetcher/makeRequest.js +94 -0
  197. package/dist/cjs/core/fetcher/redactUrl.d.ts +2 -0
  198. package/dist/cjs/core/fetcher/redactUrl.js +88 -0
  199. package/dist/cjs/core/fetcher/requestWithRetries.d.ts +1 -0
  200. package/dist/cjs/core/fetcher/requestWithRetries.js +91 -0
  201. package/dist/cjs/core/fetcher/signals.d.ts +6 -0
  202. package/dist/cjs/core/fetcher/signals.js +33 -0
  203. package/dist/cjs/core/file/exports.d.ts +1 -0
  204. package/dist/cjs/core/file/exports.js +2 -0
  205. package/dist/cjs/core/file/file.d.ts +10 -0
  206. package/dist/cjs/core/file/file.js +225 -0
  207. package/dist/cjs/core/file/index.d.ts +2 -0
  208. package/dist/cjs/core/file/index.js +18 -0
  209. package/dist/cjs/core/file/types.d.ts +66 -0
  210. package/dist/cjs/core/file/types.js +2 -0
  211. package/dist/cjs/core/form-data-utils/FormDataWrapper.d.ts +15 -0
  212. package/dist/cjs/core/form-data-utils/FormDataWrapper.js +192 -0
  213. package/dist/cjs/core/form-data-utils/encodeAsFormParameter.d.ts +1 -0
  214. package/dist/cjs/core/form-data-utils/encodeAsFormParameter.js +12 -0
  215. package/dist/cjs/core/form-data-utils/index.d.ts +2 -0
  216. package/dist/cjs/core/form-data-utils/index.js +20 -0
  217. package/dist/cjs/core/headers.d.ts +2 -0
  218. package/dist/cjs/core/headers.js +31 -0
  219. package/dist/cjs/core/index.d.ts +9 -0
  220. package/dist/cjs/core/index.js +48 -0
  221. package/dist/cjs/core/json.d.ts +15 -0
  222. package/dist/cjs/core/json.js +24 -0
  223. package/dist/cjs/core/logging/exports.d.ts +18 -0
  224. package/dist/cjs/core/logging/exports.js +45 -0
  225. package/dist/cjs/core/logging/index.d.ts +1 -0
  226. package/dist/cjs/core/logging/index.js +17 -0
  227. package/dist/cjs/core/logging/logger.d.ts +126 -0
  228. package/dist/cjs/core/logging/logger.js +144 -0
  229. package/dist/cjs/core/requestBody.d.ts +12 -0
  230. package/dist/cjs/core/requestBody.js +26 -0
  231. package/dist/cjs/core/runtime/index.d.ts +1 -0
  232. package/dist/cjs/core/runtime/index.js +6 -0
  233. package/dist/cjs/core/runtime/runtime.d.ts +28 -0
  234. package/dist/cjs/core/runtime/runtime.js +176 -0
  235. package/dist/cjs/core/schemas/Schema.d.ts +88 -0
  236. package/dist/cjs/core/schemas/Schema.js +25 -0
  237. package/dist/cjs/core/schemas/builders/bigint/bigint.d.ts +2 -0
  238. package/dist/cjs/core/schemas/builders/bigint/bigint.js +53 -0
  239. package/dist/cjs/core/schemas/builders/bigint/index.d.ts +1 -0
  240. package/dist/cjs/core/schemas/builders/bigint/index.js +5 -0
  241. package/dist/cjs/core/schemas/builders/date/date.d.ts +2 -0
  242. package/dist/cjs/core/schemas/builders/date/date.js +62 -0
  243. package/dist/cjs/core/schemas/builders/date/index.d.ts +1 -0
  244. package/dist/cjs/core/schemas/builders/date/index.js +5 -0
  245. package/dist/cjs/core/schemas/builders/enum/enum.d.ts +3 -0
  246. package/dist/cjs/core/schemas/builders/enum/enum.js +45 -0
  247. package/dist/cjs/core/schemas/builders/enum/index.d.ts +1 -0
  248. package/dist/cjs/core/schemas/builders/enum/index.js +6 -0
  249. package/dist/cjs/core/schemas/builders/index.d.ts +14 -0
  250. package/dist/cjs/core/schemas/builders/index.js +30 -0
  251. package/dist/cjs/core/schemas/builders/lazy/index.d.ts +3 -0
  252. package/dist/cjs/core/schemas/builders/lazy/index.js +7 -0
  253. package/dist/cjs/core/schemas/builders/lazy/lazy.d.ts +5 -0
  254. package/dist/cjs/core/schemas/builders/lazy/lazy.js +24 -0
  255. package/dist/cjs/core/schemas/builders/lazy/lazyObject.d.ts +3 -0
  256. package/dist/cjs/core/schemas/builders/lazy/lazyObject.js +11 -0
  257. package/dist/cjs/core/schemas/builders/list/index.d.ts +1 -0
  258. package/dist/cjs/core/schemas/builders/list/index.js +5 -0
  259. package/dist/cjs/core/schemas/builders/list/list.d.ts +2 -0
  260. package/dist/cjs/core/schemas/builders/list/list.js +49 -0
  261. package/dist/cjs/core/schemas/builders/literals/booleanLiteral.d.ts +2 -0
  262. package/dist/cjs/core/schemas/builders/literals/booleanLiteral.js +28 -0
  263. package/dist/cjs/core/schemas/builders/literals/index.d.ts +2 -0
  264. package/dist/cjs/core/schemas/builders/literals/index.js +7 -0
  265. package/dist/cjs/core/schemas/builders/literals/stringLiteral.d.ts +2 -0
  266. package/dist/cjs/core/schemas/builders/literals/stringLiteral.js +28 -0
  267. package/dist/cjs/core/schemas/builders/object/index.d.ts +6 -0
  268. package/dist/cjs/core/schemas/builders/object/index.js +11 -0
  269. package/dist/cjs/core/schemas/builders/object/object.d.ts +3 -0
  270. package/dist/cjs/core/schemas/builders/object/object.js +354 -0
  271. package/dist/cjs/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts +6 -0
  272. package/dist/cjs/core/schemas/builders/object/objectWithoutOptionalProperties.js +7 -0
  273. package/dist/cjs/core/schemas/builders/object/property.d.ts +8 -0
  274. package/dist/cjs/core/schemas/builders/object/property.js +15 -0
  275. package/dist/cjs/core/schemas/builders/object/types.d.ts +31 -0
  276. package/dist/cjs/core/schemas/builders/object/types.js +2 -0
  277. package/dist/cjs/core/schemas/builders/object-like/getObjectLikeUtils.d.ts +9 -0
  278. package/dist/cjs/core/schemas/builders/object-like/getObjectLikeUtils.js +60 -0
  279. package/dist/cjs/core/schemas/builders/object-like/index.d.ts +2 -0
  280. package/dist/cjs/core/schemas/builders/object-like/index.js +6 -0
  281. package/dist/cjs/core/schemas/builders/object-like/types.d.ts +7 -0
  282. package/dist/cjs/core/schemas/builders/object-like/types.js +2 -0
  283. package/dist/cjs/core/schemas/builders/primitives/any.d.ts +2 -0
  284. package/dist/cjs/core/schemas/builders/primitives/any.js +9 -0
  285. package/dist/cjs/core/schemas/builders/primitives/boolean.d.ts +2 -0
  286. package/dist/cjs/core/schemas/builders/primitives/boolean.js +25 -0
  287. package/dist/cjs/core/schemas/builders/primitives/index.d.ts +6 -0
  288. package/dist/cjs/core/schemas/builders/primitives/index.js +15 -0
  289. package/dist/cjs/core/schemas/builders/primitives/never.d.ts +2 -0
  290. package/dist/cjs/core/schemas/builders/primitives/never.js +14 -0
  291. package/dist/cjs/core/schemas/builders/primitives/number.d.ts +2 -0
  292. package/dist/cjs/core/schemas/builders/primitives/number.js +25 -0
  293. package/dist/cjs/core/schemas/builders/primitives/string.d.ts +2 -0
  294. package/dist/cjs/core/schemas/builders/primitives/string.js +25 -0
  295. package/dist/cjs/core/schemas/builders/primitives/unknown.d.ts +2 -0
  296. package/dist/cjs/core/schemas/builders/primitives/unknown.js +6 -0
  297. package/dist/cjs/core/schemas/builders/record/index.d.ts +2 -0
  298. package/dist/cjs/core/schemas/builders/record/index.js +6 -0
  299. package/dist/cjs/core/schemas/builders/record/record.d.ts +4 -0
  300. package/dist/cjs/core/schemas/builders/record/record.js +131 -0
  301. package/dist/cjs/core/schemas/builders/record/types.d.ts +6 -0
  302. package/dist/cjs/core/schemas/builders/record/types.js +2 -0
  303. package/dist/cjs/core/schemas/builders/schema-utils/JsonError.d.ts +5 -0
  304. package/dist/cjs/core/schemas/builders/schema-utils/JsonError.js +13 -0
  305. package/dist/cjs/core/schemas/builders/schema-utils/ParseError.d.ts +5 -0
  306. package/dist/cjs/core/schemas/builders/schema-utils/ParseError.js +13 -0
  307. package/dist/cjs/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +21 -0
  308. package/dist/cjs/core/schemas/builders/schema-utils/getSchemaUtils.js +145 -0
  309. package/dist/cjs/core/schemas/builders/schema-utils/index.d.ts +4 -0
  310. package/dist/cjs/core/schemas/builders/schema-utils/index.js +11 -0
  311. package/dist/cjs/core/schemas/builders/schema-utils/stringifyValidationErrors.d.ts +2 -0
  312. package/dist/cjs/core/schemas/builders/schema-utils/stringifyValidationErrors.js +9 -0
  313. package/dist/cjs/core/schemas/builders/set/index.d.ts +1 -0
  314. package/dist/cjs/core/schemas/builders/set/index.js +5 -0
  315. package/dist/cjs/core/schemas/builders/set/set.d.ts +2 -0
  316. package/dist/cjs/core/schemas/builders/set/set.js +43 -0
  317. package/dist/cjs/core/schemas/builders/undiscriminated-union/index.d.ts +2 -0
  318. package/dist/cjs/core/schemas/builders/undiscriminated-union/index.js +5 -0
  319. package/dist/cjs/core/schemas/builders/undiscriminated-union/types.d.ts +4 -0
  320. package/dist/cjs/core/schemas/builders/undiscriminated-union/types.js +2 -0
  321. package/dist/cjs/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.d.ts +3 -0
  322. package/dist/cjs/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +39 -0
  323. package/dist/cjs/core/schemas/builders/union/discriminant.d.ts +5 -0
  324. package/dist/cjs/core/schemas/builders/union/discriminant.js +9 -0
  325. package/dist/cjs/core/schemas/builders/union/index.d.ts +4 -0
  326. package/dist/cjs/core/schemas/builders/union/index.js +7 -0
  327. package/dist/cjs/core/schemas/builders/union/types.d.ts +13 -0
  328. package/dist/cjs/core/schemas/builders/union/types.js +2 -0
  329. package/dist/cjs/core/schemas/builders/union/union.d.ts +4 -0
  330. package/dist/cjs/core/schemas/builders/union/union.js +126 -0
  331. package/dist/cjs/core/schemas/index.d.ts +2 -0
  332. package/dist/cjs/core/schemas/index.js +17 -0
  333. package/dist/cjs/core/schemas/utils/MaybePromise.d.ts +1 -0
  334. package/dist/cjs/core/schemas/utils/MaybePromise.js +2 -0
  335. package/dist/cjs/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +7 -0
  336. package/dist/cjs/core/schemas/utils/addQuestionMarksToNullableProperties.js +2 -0
  337. package/dist/cjs/core/schemas/utils/createIdentitySchemaCreator.d.ts +2 -0
  338. package/dist/cjs/core/schemas/utils/createIdentitySchemaCreator.js +15 -0
  339. package/dist/cjs/core/schemas/utils/entries.d.ts +1 -0
  340. package/dist/cjs/core/schemas/utils/entries.js +6 -0
  341. package/dist/cjs/core/schemas/utils/filterObject.d.ts +1 -0
  342. package/dist/cjs/core/schemas/utils/filterObject.js +13 -0
  343. package/dist/cjs/core/schemas/utils/getErrorMessageForIncorrectType.d.ts +1 -0
  344. package/dist/cjs/core/schemas/utils/getErrorMessageForIncorrectType.js +27 -0
  345. package/dist/cjs/core/schemas/utils/isPlainObject.d.ts +1 -0
  346. package/dist/cjs/core/schemas/utils/isPlainObject.js +15 -0
  347. package/dist/cjs/core/schemas/utils/keys.d.ts +1 -0
  348. package/dist/cjs/core/schemas/utils/keys.js +6 -0
  349. package/dist/cjs/core/schemas/utils/maybeSkipValidation.d.ts +2 -0
  350. package/dist/cjs/core/schemas/utils/maybeSkipValidation.js +27 -0
  351. package/dist/cjs/core/schemas/utils/partition.d.ts +1 -0
  352. package/dist/cjs/core/schemas/utils/partition.js +15 -0
  353. package/dist/cjs/core/url/QueryStringBuilder.d.ts +47 -0
  354. package/dist/cjs/core/url/QueryStringBuilder.js +83 -0
  355. package/dist/cjs/core/url/encodePathParam.d.ts +3 -0
  356. package/dist/cjs/core/url/encodePathParam.js +27 -0
  357. package/dist/cjs/core/url/index.d.ts +4 -0
  358. package/dist/cjs/core/url/index.js +11 -0
  359. package/dist/cjs/core/url/join.d.ts +1 -0
  360. package/dist/cjs/core/url/join.js +68 -0
  361. package/dist/cjs/core/url/qs.d.ts +7 -0
  362. package/dist/cjs/core/url/qs.js +76 -0
  363. package/dist/cjs/environments.d.ts +4 -0
  364. package/dist/cjs/environments.js +7 -0
  365. package/dist/cjs/errors/DecisionsError.d.ts +15 -0
  366. package/dist/cjs/errors/DecisionsError.js +53 -0
  367. package/dist/cjs/errors/DecisionsTimeoutError.d.ts +6 -0
  368. package/dist/cjs/errors/DecisionsTimeoutError.js +52 -0
  369. package/dist/cjs/errors/handleNonStatusCodeError.d.ts +2 -0
  370. package/dist/cjs/errors/handleNonStatusCodeError.js +68 -0
  371. package/dist/cjs/errors/index.d.ts +2 -0
  372. package/dist/cjs/errors/index.js +7 -0
  373. package/dist/cjs/exports.d.ts +1 -0
  374. package/dist/cjs/exports.js +17 -0
  375. package/dist/cjs/index.d.ts +7 -0
  376. package/dist/cjs/index.js +49 -0
  377. package/dist/cjs/serialization/index.d.ts +2 -0
  378. package/dist/cjs/serialization/index.js +18 -0
  379. package/dist/cjs/serialization/resources/decisions/client/index.d.ts +1 -0
  380. package/dist/cjs/serialization/resources/decisions/client/index.js +17 -0
  381. package/dist/cjs/serialization/resources/decisions/client/requests/InputTokensRequest.d.ts +12 -0
  382. package/dist/cjs/serialization/resources/decisions/client/requests/InputTokensRequest.js +44 -0
  383. package/dist/cjs/serialization/resources/decisions/client/requests/index.d.ts +1 -0
  384. package/dist/cjs/serialization/resources/decisions/client/requests/index.js +5 -0
  385. package/dist/cjs/serialization/resources/decisions/index.d.ts +1 -0
  386. package/dist/cjs/serialization/resources/decisions/index.js +17 -0
  387. package/dist/cjs/serialization/resources/index.d.ts +2 -0
  388. package/dist/cjs/serialization/resources/index.js +41 -0
  389. package/dist/cjs/serialization/types/Answer.d.ts +23 -0
  390. package/dist/cjs/serialization/types/Answer.js +53 -0
  391. package/dist/cjs/serialization/types/Answers.d.ts +10 -0
  392. package/dist/cjs/serialization/types/Answers.js +40 -0
  393. package/dist/cjs/serialization/types/ChoiceAnswer.d.ts +11 -0
  394. package/dist/cjs/serialization/types/ChoiceAnswer.js +43 -0
  395. package/dist/cjs/serialization/types/ChoiceQuestion.d.ts +11 -0
  396. package/dist/cjs/serialization/types/ChoiceQuestion.js +43 -0
  397. package/dist/cjs/serialization/types/Criterion.d.ts +10 -0
  398. package/dist/cjs/serialization/types/Criterion.js +42 -0
  399. package/dist/cjs/serialization/types/DecisionsRequest.d.ts +11 -0
  400. package/dist/cjs/serialization/types/DecisionsRequest.js +43 -0
  401. package/dist/cjs/serialization/types/DecisionsResponse.d.ts +13 -0
  402. package/dist/cjs/serialization/types/DecisionsResponse.js +45 -0
  403. package/dist/cjs/serialization/types/ErrorCode.d.ts +7 -0
  404. package/dist/cjs/serialization/types/ErrorCode.js +54 -0
  405. package/dist/cjs/serialization/types/ErrorType.d.ts +7 -0
  406. package/dist/cjs/serialization/types/ErrorType.js +39 -0
  407. package/dist/cjs/serialization/types/Error_.d.ts +15 -0
  408. package/dist/cjs/serialization/types/Error_.js +47 -0
  409. package/dist/cjs/serialization/types/GatewayError.d.ts +10 -0
  410. package/dist/cjs/serialization/types/GatewayError.js +42 -0
  411. package/dist/cjs/serialization/types/InputTokensResponse.d.ts +9 -0
  412. package/dist/cjs/serialization/types/InputTokensResponse.js +41 -0
  413. package/dist/cjs/serialization/types/NoulAnswer.d.ts +9 -0
  414. package/dist/cjs/serialization/types/NoulAnswer.js +41 -0
  415. package/dist/cjs/serialization/types/NoulCriteria.d.ts +10 -0
  416. package/dist/cjs/serialization/types/NoulCriteria.js +42 -0
  417. package/dist/cjs/serialization/types/NoulQuestion.d.ts +11 -0
  418. package/dist/cjs/serialization/types/NoulQuestion.js +43 -0
  419. package/dist/cjs/serialization/types/Question.d.ts +23 -0
  420. package/dist/cjs/serialization/types/Question.js +53 -0
  421. package/dist/cjs/serialization/types/Questions.d.ts +10 -0
  422. package/dist/cjs/serialization/types/Questions.js +40 -0
  423. package/dist/cjs/serialization/types/Received.d.ts +9 -0
  424. package/dist/cjs/serialization/types/Received.js +41 -0
  425. package/dist/cjs/serialization/types/Run.d.ts +18 -0
  426. package/dist/cjs/serialization/types/Run.js +50 -0
  427. package/dist/cjs/serialization/types/RunReceived.d.ts +10 -0
  428. package/dist/cjs/serialization/types/RunReceived.js +42 -0
  429. package/dist/cjs/serialization/types/RunStatus.d.ts +7 -0
  430. package/dist/cjs/serialization/types/RunStatus.js +39 -0
  431. package/dist/cjs/serialization/types/RunSummary.d.ts +16 -0
  432. package/dist/cjs/serialization/types/RunSummary.js +48 -0
  433. package/dist/cjs/serialization/types/RunsPage.d.ts +11 -0
  434. package/dist/cjs/serialization/types/RunsPage.js +43 -0
  435. package/dist/cjs/serialization/types/ScoreAnswer.d.ts +12 -0
  436. package/dist/cjs/serialization/types/ScoreAnswer.js +44 -0
  437. package/dist/cjs/serialization/types/ScoreQuestion.d.ts +10 -0
  438. package/dist/cjs/serialization/types/ScoreQuestion.js +42 -0
  439. package/dist/cjs/serialization/types/Span.d.ts +11 -0
  440. package/dist/cjs/serialization/types/Span.js +43 -0
  441. package/dist/cjs/serialization/types/SpanAnswer.d.ts +10 -0
  442. package/dist/cjs/serialization/types/SpanAnswer.js +42 -0
  443. package/dist/cjs/serialization/types/SpanQuestion.d.ts +9 -0
  444. package/dist/cjs/serialization/types/SpanQuestion.js +41 -0
  445. package/dist/cjs/serialization/types/index.d.ts +28 -0
  446. package/dist/cjs/serialization/types/index.js +44 -0
  447. package/dist/cjs/version.d.ts +1 -0
  448. package/dist/cjs/version.js +4 -0
  449. package/dist/esm/BaseClient.d.mts +54 -0
  450. package/dist/esm/BaseClient.mjs +40 -0
  451. package/dist/esm/Client.d.mts +29 -0
  452. package/dist/esm/Client.mjs +51 -0
  453. package/dist/esm/api/errors/BadRequestError.d.mts +7 -0
  454. package/dist/esm/api/errors/BadRequestError.mjs +17 -0
  455. package/dist/esm/api/errors/ContentTooLargeError.d.mts +7 -0
  456. package/dist/esm/api/errors/ContentTooLargeError.mjs +17 -0
  457. package/dist/esm/api/errors/ForbiddenError.d.mts +7 -0
  458. package/dist/esm/api/errors/ForbiddenError.mjs +17 -0
  459. package/dist/esm/api/errors/InternalServerError.d.mts +7 -0
  460. package/dist/esm/api/errors/InternalServerError.mjs +17 -0
  461. package/dist/esm/api/errors/NotFoundError.d.mts +7 -0
  462. package/dist/esm/api/errors/NotFoundError.mjs +17 -0
  463. package/dist/esm/api/errors/PaymentRequiredError.d.mts +7 -0
  464. package/dist/esm/api/errors/PaymentRequiredError.mjs +17 -0
  465. package/dist/esm/api/errors/ServiceUnavailableError.d.mts +7 -0
  466. package/dist/esm/api/errors/ServiceUnavailableError.mjs +17 -0
  467. package/dist/esm/api/errors/TooManyRequestsError.d.mts +7 -0
  468. package/dist/esm/api/errors/TooManyRequestsError.mjs +17 -0
  469. package/dist/esm/api/errors/UnauthorizedError.d.mts +7 -0
  470. package/dist/esm/api/errors/UnauthorizedError.mjs +17 -0
  471. package/dist/esm/api/errors/UnsupportedMediaTypeError.d.mts +7 -0
  472. package/dist/esm/api/errors/UnsupportedMediaTypeError.mjs +17 -0
  473. package/dist/esm/api/errors/index.d.mts +10 -0
  474. package/dist/esm/api/errors/index.mjs +10 -0
  475. package/dist/esm/api/index.d.mts +3 -0
  476. package/dist/esm/api/index.mjs +3 -0
  477. package/dist/esm/api/resources/decisions/client/Client.d.mts +284 -0
  478. package/dist/esm/api/resources/decisions/client/Client.mjs +527 -0
  479. package/dist/esm/api/resources/decisions/client/index.d.mts +1 -0
  480. package/dist/esm/api/resources/decisions/client/index.mjs +1 -0
  481. package/dist/esm/api/resources/decisions/client/requests/DecisionsUpload.d.mts +118 -0
  482. package/dist/esm/api/resources/decisions/client/requests/DecisionsUpload.mjs +2 -0
  483. package/dist/esm/api/resources/decisions/client/requests/InputTokensRequest.d.mts +44 -0
  484. package/dist/esm/api/resources/decisions/client/requests/InputTokensRequest.mjs +2 -0
  485. package/dist/esm/api/resources/decisions/client/requests/index.d.mts +2 -0
  486. package/dist/esm/api/resources/decisions/client/requests/index.mjs +1 -0
  487. package/dist/esm/api/resources/decisions/exports.d.mts +2 -0
  488. package/dist/esm/api/resources/decisions/exports.mjs +3 -0
  489. package/dist/esm/api/resources/decisions/index.d.mts +1 -0
  490. package/dist/esm/api/resources/decisions/index.mjs +1 -0
  491. package/dist/esm/api/resources/index.d.mts +4 -0
  492. package/dist/esm/api/resources/index.mjs +4 -0
  493. package/dist/esm/api/resources/runs/client/Client.d.mts +60 -0
  494. package/dist/esm/api/resources/runs/client/Client.mjs +269 -0
  495. package/dist/esm/api/resources/runs/client/index.d.mts +1 -0
  496. package/dist/esm/api/resources/runs/client/index.mjs +1 -0
  497. package/dist/esm/api/resources/runs/client/requests/GetRunsRequest.d.mts +10 -0
  498. package/dist/esm/api/resources/runs/client/requests/GetRunsRequest.mjs +2 -0
  499. package/dist/esm/api/resources/runs/client/requests/ListRunsRequest.d.mts +19 -0
  500. package/dist/esm/api/resources/runs/client/requests/ListRunsRequest.mjs +2 -0
  501. package/dist/esm/api/resources/runs/client/requests/index.d.mts +2 -0
  502. package/dist/esm/api/resources/runs/client/requests/index.mjs +1 -0
  503. package/dist/esm/api/resources/runs/exports.d.mts +2 -0
  504. package/dist/esm/api/resources/runs/exports.mjs +3 -0
  505. package/dist/esm/api/resources/runs/index.d.mts +1 -0
  506. package/dist/esm/api/resources/runs/index.mjs +1 -0
  507. package/dist/esm/api/types/Answer.d.mts +19 -0
  508. package/dist/esm/api/types/Answer.mjs +2 -0
  509. package/dist/esm/api/types/Answers.d.mts +7 -0
  510. package/dist/esm/api/types/Answers.mjs +2 -0
  511. package/dist/esm/api/types/ChoiceAnswer.d.mts +11 -0
  512. package/dist/esm/api/types/ChoiceAnswer.mjs +2 -0
  513. package/dist/esm/api/types/ChoiceQuestion.d.mts +10 -0
  514. package/dist/esm/api/types/ChoiceQuestion.mjs +2 -0
  515. package/dist/esm/api/types/Criterion.d.mts +9 -0
  516. package/dist/esm/api/types/Criterion.mjs +2 -0
  517. package/dist/esm/api/types/DecisionsRequest.d.mts +9 -0
  518. package/dist/esm/api/types/DecisionsRequest.mjs +2 -0
  519. package/dist/esm/api/types/DecisionsResponse.d.mts +10 -0
  520. package/dist/esm/api/types/DecisionsResponse.mjs +2 -0
  521. package/dist/esm/api/types/ErrorCode.d.mts +58 -0
  522. package/dist/esm/api/types/ErrorCode.mjs +58 -0
  523. package/dist/esm/api/types/ErrorType.d.mts +5 -0
  524. package/dist/esm/api/types/ErrorType.mjs +5 -0
  525. package/dist/esm/api/types/Error_.d.mts +15 -0
  526. package/dist/esm/api/types/Error_.mjs +2 -0
  527. package/dist/esm/api/types/GatewayError.d.mts +9 -0
  528. package/dist/esm/api/types/GatewayError.mjs +2 -0
  529. package/dist/esm/api/types/InputTokensResponse.d.mts +7 -0
  530. package/dist/esm/api/types/InputTokensResponse.mjs +2 -0
  531. package/dist/esm/api/types/NoulAnswer.d.mts +7 -0
  532. package/dist/esm/api/types/NoulAnswer.mjs +2 -0
  533. package/dist/esm/api/types/NoulCriteria.d.mts +9 -0
  534. package/dist/esm/api/types/NoulCriteria.mjs +2 -0
  535. package/dist/esm/api/types/NoulQuestion.d.mts +9 -0
  536. package/dist/esm/api/types/NoulQuestion.mjs +2 -0
  537. package/dist/esm/api/types/Question.d.mts +19 -0
  538. package/dist/esm/api/types/Question.mjs +2 -0
  539. package/dist/esm/api/types/Questions.d.mts +7 -0
  540. package/dist/esm/api/types/Questions.mjs +2 -0
  541. package/dist/esm/api/types/Received.d.mts +7 -0
  542. package/dist/esm/api/types/Received.mjs +2 -0
  543. package/dist/esm/api/types/Run.d.mts +18 -0
  544. package/dist/esm/api/types/Run.mjs +2 -0
  545. package/dist/esm/api/types/RunReceived.d.mts +9 -0
  546. package/dist/esm/api/types/RunReceived.mjs +2 -0
  547. package/dist/esm/api/types/RunStatus.d.mts +6 -0
  548. package/dist/esm/api/types/RunStatus.mjs +6 -0
  549. package/dist/esm/api/types/RunSummary.d.mts +16 -0
  550. package/dist/esm/api/types/RunSummary.mjs +2 -0
  551. package/dist/esm/api/types/RunsPage.d.mts +10 -0
  552. package/dist/esm/api/types/RunsPage.mjs +2 -0
  553. package/dist/esm/api/types/ScoreAnswer.d.mts +13 -0
  554. package/dist/esm/api/types/ScoreAnswer.mjs +2 -0
  555. package/dist/esm/api/types/ScoreQuestion.d.mts +9 -0
  556. package/dist/esm/api/types/ScoreQuestion.mjs +2 -0
  557. package/dist/esm/api/types/Span.d.mts +11 -0
  558. package/dist/esm/api/types/Span.mjs +2 -0
  559. package/dist/esm/api/types/SpanAnswer.d.mts +8 -0
  560. package/dist/esm/api/types/SpanAnswer.mjs +2 -0
  561. package/dist/esm/api/types/SpanQuestion.d.mts +7 -0
  562. package/dist/esm/api/types/SpanQuestion.mjs +2 -0
  563. package/dist/esm/api/types/index.d.mts +28 -0
  564. package/dist/esm/api/types/index.mjs +28 -0
  565. package/dist/esm/audio-helpers/bytes.d.mts +6 -0
  566. package/dist/esm/audio-helpers/bytes.mjs +32 -0
  567. package/dist/esm/audio-helpers/checks.d.mts +2 -0
  568. package/dist/esm/audio-helpers/checks.mjs +21 -0
  569. package/dist/esm/audio-helpers/chunks.d.mts +160 -0
  570. package/dist/esm/audio-helpers/chunks.mjs +346 -0
  571. package/dist/esm/audio-helpers/downmix.d.mts +17 -0
  572. package/dist/esm/audio-helpers/downmix.mjs +287 -0
  573. package/dist/esm/audio-helpers/errors.d.mts +4 -0
  574. package/dist/esm/audio-helpers/errors.mjs +8 -0
  575. package/dist/esm/audio-helpers/files.d.mts +27 -0
  576. package/dist/esm/audio-helpers/files.mjs +173 -0
  577. package/dist/esm/audio-helpers/index.d.mts +4 -0
  578. package/dist/esm/audio-helpers/index.mjs +5 -0
  579. package/dist/esm/audio-helpers/integers.d.mts +3 -0
  580. package/dist/esm/audio-helpers/integers.mjs +21 -0
  581. package/dist/esm/audio-helpers/mp3.d.mts +24 -0
  582. package/dist/esm/audio-helpers/mp3.mjs +239 -0
  583. package/dist/esm/audio-helpers/results.d.mts +74 -0
  584. package/dist/esm/audio-helpers/results.mjs +181 -0
  585. package/dist/esm/audio-helpers/wav.d.mts +21 -0
  586. package/dist/esm/audio-helpers/wav.mjs +161 -0
  587. package/dist/esm/auth/HeaderAuthProvider.d.mts +20 -0
  588. package/dist/esm/auth/HeaderAuthProvider.mjs +46 -0
  589. package/dist/esm/auth/index.d.mts +1 -0
  590. package/dist/esm/auth/index.mjs +1 -0
  591. package/dist/esm/core/auth/AuthProvider.d.mts +8 -0
  592. package/dist/esm/core/auth/AuthProvider.mjs +6 -0
  593. package/dist/esm/core/auth/AuthRequest.d.mts +9 -0
  594. package/dist/esm/core/auth/AuthRequest.mjs +1 -0
  595. package/dist/esm/core/auth/BasicAuth.d.mts +8 -0
  596. package/dist/esm/core/auth/BasicAuth.mjs +30 -0
  597. package/dist/esm/core/auth/BearerToken.d.mts +7 -0
  598. package/dist/esm/core/auth/BearerToken.mjs +13 -0
  599. package/dist/esm/core/auth/NoOpAuthProvider.d.mts +5 -0
  600. package/dist/esm/core/auth/NoOpAuthProvider.mjs +5 -0
  601. package/dist/esm/core/auth/index.d.mts +5 -0
  602. package/dist/esm/core/auth/index.mjs +4 -0
  603. package/dist/esm/core/base64.d.mts +2 -0
  604. package/dist/esm/core/base64.mjs +22 -0
  605. package/dist/esm/core/exports.d.mts +2 -0
  606. package/dist/esm/core/exports.mjs +2 -0
  607. package/dist/esm/core/fetcher/APIResponse.d.mts +20 -0
  608. package/dist/esm/core/fetcher/APIResponse.mjs +1 -0
  609. package/dist/esm/core/fetcher/BinaryResponse.d.mts +19 -0
  610. package/dist/esm/core/fetcher/BinaryResponse.mjs +14 -0
  611. package/dist/esm/core/fetcher/EndpointMetadata.d.mts +13 -0
  612. package/dist/esm/core/fetcher/EndpointMetadata.mjs +1 -0
  613. package/dist/esm/core/fetcher/EndpointSupplier.d.mts +12 -0
  614. package/dist/esm/core/fetcher/EndpointSupplier.mjs +19 -0
  615. package/dist/esm/core/fetcher/Fetcher.d.mts +56 -0
  616. package/dist/esm/core/fetcher/Fetcher.mjs +271 -0
  617. package/dist/esm/core/fetcher/Headers.d.mts +2 -0
  618. package/dist/esm/core/fetcher/Headers.mjs +82 -0
  619. package/dist/esm/core/fetcher/HttpResponsePromise.d.mts +58 -0
  620. package/dist/esm/core/fetcher/HttpResponsePromise.mjs +99 -0
  621. package/dist/esm/core/fetcher/RawResponse.d.mts +29 -0
  622. package/dist/esm/core/fetcher/RawResponse.mjs +40 -0
  623. package/dist/esm/core/fetcher/Supplier.d.mts +4 -0
  624. package/dist/esm/core/fetcher/Supplier.mjs +19 -0
  625. package/dist/esm/core/fetcher/createRequestUrl.d.mts +1 -0
  626. package/dist/esm/core/fetcher/createRequestUrl.mjs +5 -0
  627. package/dist/esm/core/fetcher/getErrorResponseBody.d.mts +1 -0
  628. package/dist/esm/core/fetcher/getErrorResponseBody.mjs +55 -0
  629. package/dist/esm/core/fetcher/getFetchFn.d.mts +1 -0
  630. package/dist/esm/core/fetcher/getFetchFn.mjs +14 -0
  631. package/dist/esm/core/fetcher/getHeader.d.mts +1 -0
  632. package/dist/esm/core/fetcher/getHeader.mjs +8 -0
  633. package/dist/esm/core/fetcher/getRequestBody.d.mts +7 -0
  634. package/dist/esm/core/fetcher/getRequestBody.mjs +24 -0
  635. package/dist/esm/core/fetcher/getResponseBody.d.mts +17 -0
  636. package/dist/esm/core/fetcher/getResponseBody.mjs +81 -0
  637. package/dist/esm/core/fetcher/index.d.mts +13 -0
  638. package/dist/esm/core/fetcher/index.mjs +7 -0
  639. package/dist/esm/core/fetcher/makePassthroughRequest.d.mts +49 -0
  640. package/dist/esm/core/fetcher/makePassthroughRequest.mjs +170 -0
  641. package/dist/esm/core/fetcher/makeRequest.d.mts +11 -0
  642. package/dist/esm/core/fetcher/makeRequest.mjs +87 -0
  643. package/dist/esm/core/fetcher/redactUrl.d.mts +2 -0
  644. package/dist/esm/core/fetcher/redactUrl.mjs +84 -0
  645. package/dist/esm/core/fetcher/requestWithRetries.d.mts +1 -0
  646. package/dist/esm/core/fetcher/requestWithRetries.mjs +88 -0
  647. package/dist/esm/core/fetcher/signals.d.mts +6 -0
  648. package/dist/esm/core/fetcher/signals.mjs +28 -0
  649. package/dist/esm/core/file/exports.d.mts +1 -0
  650. package/dist/esm/core/file/exports.mjs +1 -0
  651. package/dist/esm/core/file/file.d.mts +10 -0
  652. package/dist/esm/core/file/file.mjs +188 -0
  653. package/dist/esm/core/file/index.d.mts +2 -0
  654. package/dist/esm/core/file/index.mjs +2 -0
  655. package/dist/esm/core/file/types.d.mts +66 -0
  656. package/dist/esm/core/file/types.mjs +1 -0
  657. package/dist/esm/core/form-data-utils/FormDataWrapper.d.mts +15 -0
  658. package/dist/esm/core/form-data-utils/FormDataWrapper.mjs +154 -0
  659. package/dist/esm/core/form-data-utils/encodeAsFormParameter.d.mts +1 -0
  660. package/dist/esm/core/form-data-utils/encodeAsFormParameter.mjs +9 -0
  661. package/dist/esm/core/form-data-utils/index.d.mts +2 -0
  662. package/dist/esm/core/form-data-utils/index.mjs +2 -0
  663. package/dist/esm/core/headers.d.mts +2 -0
  664. package/dist/esm/core/headers.mjs +27 -0
  665. package/dist/esm/core/index.d.mts +9 -0
  666. package/dist/esm/core/index.mjs +9 -0
  667. package/dist/esm/core/json.d.mts +15 -0
  668. package/dist/esm/core/json.mjs +19 -0
  669. package/dist/esm/core/logging/exports.d.mts +18 -0
  670. package/dist/esm/core/logging/exports.mjs +9 -0
  671. package/dist/esm/core/logging/index.d.mts +1 -0
  672. package/dist/esm/core/logging/index.mjs +1 -0
  673. package/dist/esm/core/logging/logger.d.mts +126 -0
  674. package/dist/esm/core/logging/logger.mjs +138 -0
  675. package/dist/esm/core/requestBody.d.mts +12 -0
  676. package/dist/esm/core/requestBody.mjs +23 -0
  677. package/dist/esm/core/runtime/index.d.mts +1 -0
  678. package/dist/esm/core/runtime/index.mjs +1 -0
  679. package/dist/esm/core/runtime/runtime.d.mts +28 -0
  680. package/dist/esm/core/runtime/runtime.mjs +172 -0
  681. package/dist/esm/core/schemas/Schema.d.mts +88 -0
  682. package/dist/esm/core/schemas/Schema.mjs +22 -0
  683. package/dist/esm/core/schemas/builders/bigint/bigint.d.mts +2 -0
  684. package/dist/esm/core/schemas/builders/bigint/bigint.mjs +50 -0
  685. package/dist/esm/core/schemas/builders/bigint/index.d.mts +1 -0
  686. package/dist/esm/core/schemas/builders/bigint/index.mjs +1 -0
  687. package/dist/esm/core/schemas/builders/date/date.d.mts +2 -0
  688. package/dist/esm/core/schemas/builders/date/date.mjs +59 -0
  689. package/dist/esm/core/schemas/builders/date/index.d.mts +1 -0
  690. package/dist/esm/core/schemas/builders/date/index.mjs +1 -0
  691. package/dist/esm/core/schemas/builders/enum/enum.d.mts +3 -0
  692. package/dist/esm/core/schemas/builders/enum/enum.mjs +41 -0
  693. package/dist/esm/core/schemas/builders/enum/index.d.mts +1 -0
  694. package/dist/esm/core/schemas/builders/enum/index.mjs +1 -0
  695. package/dist/esm/core/schemas/builders/index.d.mts +14 -0
  696. package/dist/esm/core/schemas/builders/index.mjs +14 -0
  697. package/dist/esm/core/schemas/builders/lazy/index.d.mts +3 -0
  698. package/dist/esm/core/schemas/builders/lazy/index.mjs +2 -0
  699. package/dist/esm/core/schemas/builders/lazy/lazy.d.mts +5 -0
  700. package/dist/esm/core/schemas/builders/lazy/lazy.mjs +19 -0
  701. package/dist/esm/core/schemas/builders/lazy/lazyObject.d.mts +3 -0
  702. package/dist/esm/core/schemas/builders/lazy/lazyObject.mjs +8 -0
  703. package/dist/esm/core/schemas/builders/list/index.d.mts +1 -0
  704. package/dist/esm/core/schemas/builders/list/index.mjs +1 -0
  705. package/dist/esm/core/schemas/builders/list/list.d.mts +2 -0
  706. package/dist/esm/core/schemas/builders/list/list.mjs +46 -0
  707. package/dist/esm/core/schemas/builders/literals/booleanLiteral.d.mts +2 -0
  708. package/dist/esm/core/schemas/builders/literals/booleanLiteral.mjs +25 -0
  709. package/dist/esm/core/schemas/builders/literals/index.d.mts +2 -0
  710. package/dist/esm/core/schemas/builders/literals/index.mjs +2 -0
  711. package/dist/esm/core/schemas/builders/literals/stringLiteral.d.mts +2 -0
  712. package/dist/esm/core/schemas/builders/literals/stringLiteral.mjs +25 -0
  713. package/dist/esm/core/schemas/builders/object/index.d.mts +6 -0
  714. package/dist/esm/core/schemas/builders/object/index.mjs +3 -0
  715. package/dist/esm/core/schemas/builders/object/object.d.mts +3 -0
  716. package/dist/esm/core/schemas/builders/object/object.mjs +350 -0
  717. package/dist/esm/core/schemas/builders/object/objectWithoutOptionalProperties.d.mts +6 -0
  718. package/dist/esm/core/schemas/builders/object/objectWithoutOptionalProperties.mjs +4 -0
  719. package/dist/esm/core/schemas/builders/object/property.d.mts +8 -0
  720. package/dist/esm/core/schemas/builders/object/property.mjs +11 -0
  721. package/dist/esm/core/schemas/builders/object/types.d.mts +31 -0
  722. package/dist/esm/core/schemas/builders/object/types.mjs +1 -0
  723. package/dist/esm/core/schemas/builders/object-like/getObjectLikeUtils.d.mts +9 -0
  724. package/dist/esm/core/schemas/builders/object-like/getObjectLikeUtils.mjs +56 -0
  725. package/dist/esm/core/schemas/builders/object-like/index.d.mts +2 -0
  726. package/dist/esm/core/schemas/builders/object-like/index.mjs +1 -0
  727. package/dist/esm/core/schemas/builders/object-like/types.d.mts +7 -0
  728. package/dist/esm/core/schemas/builders/object-like/types.mjs +1 -0
  729. package/dist/esm/core/schemas/builders/primitives/any.d.mts +2 -0
  730. package/dist/esm/core/schemas/builders/primitives/any.mjs +6 -0
  731. package/dist/esm/core/schemas/builders/primitives/boolean.d.mts +2 -0
  732. package/dist/esm/core/schemas/builders/primitives/boolean.mjs +22 -0
  733. package/dist/esm/core/schemas/builders/primitives/index.d.mts +6 -0
  734. package/dist/esm/core/schemas/builders/primitives/index.mjs +6 -0
  735. package/dist/esm/core/schemas/builders/primitives/never.d.mts +2 -0
  736. package/dist/esm/core/schemas/builders/primitives/never.mjs +11 -0
  737. package/dist/esm/core/schemas/builders/primitives/number.d.mts +2 -0
  738. package/dist/esm/core/schemas/builders/primitives/number.mjs +22 -0
  739. package/dist/esm/core/schemas/builders/primitives/string.d.mts +2 -0
  740. package/dist/esm/core/schemas/builders/primitives/string.mjs +22 -0
  741. package/dist/esm/core/schemas/builders/primitives/unknown.d.mts +2 -0
  742. package/dist/esm/core/schemas/builders/primitives/unknown.mjs +3 -0
  743. package/dist/esm/core/schemas/builders/record/index.d.mts +2 -0
  744. package/dist/esm/core/schemas/builders/record/index.mjs +1 -0
  745. package/dist/esm/core/schemas/builders/record/record.d.mts +4 -0
  746. package/dist/esm/core/schemas/builders/record/record.mjs +127 -0
  747. package/dist/esm/core/schemas/builders/record/types.d.mts +6 -0
  748. package/dist/esm/core/schemas/builders/record/types.mjs +1 -0
  749. package/dist/esm/core/schemas/builders/schema-utils/JsonError.d.mts +5 -0
  750. package/dist/esm/core/schemas/builders/schema-utils/JsonError.mjs +9 -0
  751. package/dist/esm/core/schemas/builders/schema-utils/ParseError.d.mts +5 -0
  752. package/dist/esm/core/schemas/builders/schema-utils/ParseError.mjs +9 -0
  753. package/dist/esm/core/schemas/builders/schema-utils/getSchemaUtils.d.mts +21 -0
  754. package/dist/esm/core/schemas/builders/schema-utils/getSchemaUtils.mjs +138 -0
  755. package/dist/esm/core/schemas/builders/schema-utils/index.d.mts +4 -0
  756. package/dist/esm/core/schemas/builders/schema-utils/index.mjs +3 -0
  757. package/dist/esm/core/schemas/builders/schema-utils/stringifyValidationErrors.d.mts +2 -0
  758. package/dist/esm/core/schemas/builders/schema-utils/stringifyValidationErrors.mjs +6 -0
  759. package/dist/esm/core/schemas/builders/set/index.d.mts +1 -0
  760. package/dist/esm/core/schemas/builders/set/index.mjs +1 -0
  761. package/dist/esm/core/schemas/builders/set/set.d.mts +2 -0
  762. package/dist/esm/core/schemas/builders/set/set.mjs +40 -0
  763. package/dist/esm/core/schemas/builders/undiscriminated-union/index.d.mts +2 -0
  764. package/dist/esm/core/schemas/builders/undiscriminated-union/index.mjs +1 -0
  765. package/dist/esm/core/schemas/builders/undiscriminated-union/types.d.mts +4 -0
  766. package/dist/esm/core/schemas/builders/undiscriminated-union/types.mjs +1 -0
  767. package/dist/esm/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.d.mts +3 -0
  768. package/dist/esm/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.mjs +36 -0
  769. package/dist/esm/core/schemas/builders/union/discriminant.d.mts +5 -0
  770. package/dist/esm/core/schemas/builders/union/discriminant.mjs +6 -0
  771. package/dist/esm/core/schemas/builders/union/index.d.mts +4 -0
  772. package/dist/esm/core/schemas/builders/union/index.mjs +2 -0
  773. package/dist/esm/core/schemas/builders/union/types.d.mts +13 -0
  774. package/dist/esm/core/schemas/builders/union/types.mjs +1 -0
  775. package/dist/esm/core/schemas/builders/union/union.d.mts +4 -0
  776. package/dist/esm/core/schemas/builders/union/union.mjs +123 -0
  777. package/dist/esm/core/schemas/index.d.mts +2 -0
  778. package/dist/esm/core/schemas/index.mjs +1 -0
  779. package/dist/esm/core/schemas/utils/MaybePromise.d.mts +1 -0
  780. package/dist/esm/core/schemas/utils/MaybePromise.mjs +1 -0
  781. package/dist/esm/core/schemas/utils/addQuestionMarksToNullableProperties.d.mts +7 -0
  782. package/dist/esm/core/schemas/utils/addQuestionMarksToNullableProperties.mjs +1 -0
  783. package/dist/esm/core/schemas/utils/createIdentitySchemaCreator.d.mts +2 -0
  784. package/dist/esm/core/schemas/utils/createIdentitySchemaCreator.mjs +12 -0
  785. package/dist/esm/core/schemas/utils/entries.d.mts +1 -0
  786. package/dist/esm/core/schemas/utils/entries.mjs +3 -0
  787. package/dist/esm/core/schemas/utils/filterObject.d.mts +1 -0
  788. package/dist/esm/core/schemas/utils/filterObject.mjs +10 -0
  789. package/dist/esm/core/schemas/utils/getErrorMessageForIncorrectType.d.mts +1 -0
  790. package/dist/esm/core/schemas/utils/getErrorMessageForIncorrectType.mjs +24 -0
  791. package/dist/esm/core/schemas/utils/isPlainObject.d.mts +1 -0
  792. package/dist/esm/core/schemas/utils/isPlainObject.mjs +12 -0
  793. package/dist/esm/core/schemas/utils/keys.d.mts +1 -0
  794. package/dist/esm/core/schemas/utils/keys.mjs +3 -0
  795. package/dist/esm/core/schemas/utils/maybeSkipValidation.d.mts +2 -0
  796. package/dist/esm/core/schemas/utils/maybeSkipValidation.mjs +24 -0
  797. package/dist/esm/core/schemas/utils/partition.d.mts +1 -0
  798. package/dist/esm/core/schemas/utils/partition.mjs +12 -0
  799. package/dist/esm/core/url/QueryStringBuilder.d.mts +47 -0
  800. package/dist/esm/core/url/QueryStringBuilder.mjs +80 -0
  801. package/dist/esm/core/url/encodePathParam.d.mts +3 -0
  802. package/dist/esm/core/url/encodePathParam.mjs +24 -0
  803. package/dist/esm/core/url/index.d.mts +4 -0
  804. package/dist/esm/core/url/index.mjs +4 -0
  805. package/dist/esm/core/url/join.d.mts +1 -0
  806. package/dist/esm/core/url/join.mjs +65 -0
  807. package/dist/esm/core/url/qs.d.mts +7 -0
  808. package/dist/esm/core/url/qs.mjs +73 -0
  809. package/dist/esm/environments.d.mts +4 -0
  810. package/dist/esm/environments.mjs +4 -0
  811. package/dist/esm/errors/DecisionsError.d.mts +15 -0
  812. package/dist/esm/errors/DecisionsError.mjs +49 -0
  813. package/dist/esm/errors/DecisionsTimeoutError.d.mts +6 -0
  814. package/dist/esm/errors/DecisionsTimeoutError.mjs +15 -0
  815. package/dist/esm/errors/handleNonStatusCodeError.d.mts +2 -0
  816. package/dist/esm/errors/handleNonStatusCodeError.mjs +32 -0
  817. package/dist/esm/errors/index.d.mts +2 -0
  818. package/dist/esm/errors/index.mjs +2 -0
  819. package/dist/esm/exports.d.mts +1 -0
  820. package/dist/esm/exports.mjs +1 -0
  821. package/dist/esm/index.d.mts +7 -0
  822. package/dist/esm/index.mjs +6 -0
  823. package/dist/esm/serialization/index.d.mts +2 -0
  824. package/dist/esm/serialization/index.mjs +2 -0
  825. package/dist/esm/serialization/resources/decisions/client/index.d.mts +1 -0
  826. package/dist/esm/serialization/resources/decisions/client/index.mjs +1 -0
  827. package/dist/esm/serialization/resources/decisions/client/requests/InputTokensRequest.d.mts +12 -0
  828. package/dist/esm/serialization/resources/decisions/client/requests/InputTokensRequest.mjs +8 -0
  829. package/dist/esm/serialization/resources/decisions/client/requests/index.d.mts +1 -0
  830. package/dist/esm/serialization/resources/decisions/client/requests/index.mjs +1 -0
  831. package/dist/esm/serialization/resources/decisions/index.d.mts +1 -0
  832. package/dist/esm/serialization/resources/decisions/index.mjs +1 -0
  833. package/dist/esm/serialization/resources/index.d.mts +2 -0
  834. package/dist/esm/serialization/resources/index.mjs +2 -0
  835. package/dist/esm/serialization/types/Answer.d.mts +23 -0
  836. package/dist/esm/serialization/types/Answer.mjs +17 -0
  837. package/dist/esm/serialization/types/Answers.d.mts +10 -0
  838. package/dist/esm/serialization/types/Answers.mjs +4 -0
  839. package/dist/esm/serialization/types/ChoiceAnswer.d.mts +11 -0
  840. package/dist/esm/serialization/types/ChoiceAnswer.mjs +7 -0
  841. package/dist/esm/serialization/types/ChoiceQuestion.d.mts +11 -0
  842. package/dist/esm/serialization/types/ChoiceQuestion.mjs +7 -0
  843. package/dist/esm/serialization/types/Criterion.d.mts +10 -0
  844. package/dist/esm/serialization/types/Criterion.mjs +6 -0
  845. package/dist/esm/serialization/types/DecisionsRequest.d.mts +11 -0
  846. package/dist/esm/serialization/types/DecisionsRequest.mjs +7 -0
  847. package/dist/esm/serialization/types/DecisionsResponse.d.mts +13 -0
  848. package/dist/esm/serialization/types/DecisionsResponse.mjs +9 -0
  849. package/dist/esm/serialization/types/ErrorCode.d.mts +7 -0
  850. package/dist/esm/serialization/types/ErrorCode.mjs +18 -0
  851. package/dist/esm/serialization/types/ErrorType.d.mts +7 -0
  852. package/dist/esm/serialization/types/ErrorType.mjs +3 -0
  853. package/dist/esm/serialization/types/Error_.d.mts +15 -0
  854. package/dist/esm/serialization/types/Error_.mjs +11 -0
  855. package/dist/esm/serialization/types/GatewayError.d.mts +10 -0
  856. package/dist/esm/serialization/types/GatewayError.mjs +6 -0
  857. package/dist/esm/serialization/types/InputTokensResponse.d.mts +9 -0
  858. package/dist/esm/serialization/types/InputTokensResponse.mjs +5 -0
  859. package/dist/esm/serialization/types/NoulAnswer.d.mts +9 -0
  860. package/dist/esm/serialization/types/NoulAnswer.mjs +5 -0
  861. package/dist/esm/serialization/types/NoulCriteria.d.mts +10 -0
  862. package/dist/esm/serialization/types/NoulCriteria.mjs +6 -0
  863. package/dist/esm/serialization/types/NoulQuestion.d.mts +11 -0
  864. package/dist/esm/serialization/types/NoulQuestion.mjs +7 -0
  865. package/dist/esm/serialization/types/Question.d.mts +23 -0
  866. package/dist/esm/serialization/types/Question.mjs +17 -0
  867. package/dist/esm/serialization/types/Questions.d.mts +10 -0
  868. package/dist/esm/serialization/types/Questions.mjs +4 -0
  869. package/dist/esm/serialization/types/Received.d.mts +9 -0
  870. package/dist/esm/serialization/types/Received.mjs +5 -0
  871. package/dist/esm/serialization/types/Run.d.mts +18 -0
  872. package/dist/esm/serialization/types/Run.mjs +14 -0
  873. package/dist/esm/serialization/types/RunReceived.d.mts +10 -0
  874. package/dist/esm/serialization/types/RunReceived.mjs +6 -0
  875. package/dist/esm/serialization/types/RunStatus.d.mts +7 -0
  876. package/dist/esm/serialization/types/RunStatus.mjs +3 -0
  877. package/dist/esm/serialization/types/RunSummary.d.mts +16 -0
  878. package/dist/esm/serialization/types/RunSummary.mjs +12 -0
  879. package/dist/esm/serialization/types/RunsPage.d.mts +11 -0
  880. package/dist/esm/serialization/types/RunsPage.mjs +7 -0
  881. package/dist/esm/serialization/types/ScoreAnswer.d.mts +12 -0
  882. package/dist/esm/serialization/types/ScoreAnswer.mjs +8 -0
  883. package/dist/esm/serialization/types/ScoreQuestion.d.mts +10 -0
  884. package/dist/esm/serialization/types/ScoreQuestion.mjs +6 -0
  885. package/dist/esm/serialization/types/Span.d.mts +11 -0
  886. package/dist/esm/serialization/types/Span.mjs +7 -0
  887. package/dist/esm/serialization/types/SpanAnswer.d.mts +10 -0
  888. package/dist/esm/serialization/types/SpanAnswer.mjs +6 -0
  889. package/dist/esm/serialization/types/SpanQuestion.d.mts +9 -0
  890. package/dist/esm/serialization/types/SpanQuestion.mjs +5 -0
  891. package/dist/esm/serialization/types/index.d.mts +28 -0
  892. package/dist/esm/serialization/types/index.mjs +28 -0
  893. package/dist/esm/version.d.mts +1 -0
  894. package/dist/esm/version.mjs +1 -0
  895. package/package.json +114 -8
  896. package/reference.md +327 -0
@@ -0,0 +1,160 @@
1
+ import type { Uploadable } from "../core/file/index.mjs";
2
+ import { type DownmixStrategy } from "./downmix.mjs";
3
+ declare const SPLITS: readonly ["even", "fixed"];
4
+ export type ChunkSplit = (typeof SPLITS)[number];
5
+ /** One chunk of a longer recording, a complete audio file to send to the Decisions API on its own. */
6
+ export interface AudioChunk {
7
+ /** Position of the chunk in the recording, starting at 0. */
8
+ readonly index: number;
9
+ /**
10
+ * Where the chunk starts in the recording, in milliseconds, rounded to the nearest millisecond.
11
+ * The first chunk of an MP3 file can start a few tens of milliseconds before 0.
12
+ */
13
+ readonly startMs: number;
14
+ /** Where the chunk ends in the recording, in milliseconds, rounded to the nearest millisecond. */
15
+ readonly endMs: number;
16
+ /** The chunk as a file in the recording's format, after any mixdown `downmixStrategy` asks for. */
17
+ readonly data: Uint8Array;
18
+ }
19
+ export declare namespace iterAudioChunks {
20
+ interface Options {
21
+ /**
22
+ * The longest a chunk can be, in milliseconds, from 1 to 300000. A WAV chunk must also be at
23
+ * most 24,000,000 bytes, which leaves room for the rest of its request within the API's limit
24
+ * of 25,000,000 bytes. 5 minutes of WAV fits only at just under 80,000 bytes per second, and
25
+ * always fits for mono or stereo under "mix". With "even", a WAV file that does not fit is cut
26
+ * into shorter chunks that do. With "fixed", it throws, and 16-bit stereo that is not mixed
27
+ * down needs a `maxChunkMs` of at most 136054 at 44.1 kHz and 124999 at 48 kHz.
28
+ */
29
+ maxChunkMs: number;
30
+ /** Where in the recording to start, in milliseconds. Defaults to the start of the recording. */
31
+ startMs?: number;
32
+ /**
33
+ * Where in the recording to stop, in milliseconds, no later than the recording's duration.
34
+ * Defaults to the end of the recording.
35
+ */
36
+ endMs?: number;
37
+ /**
38
+ * "even" for the fewest chunks of equal length, or "fixed" for chunks of `maxChunkMs` with a
39
+ * shorter last chunk. Defaults to "even".
40
+ */
41
+ split?: ChunkSplit;
42
+ /**
43
+ * How a WAV file is mixed down before it is cut. Audio above 16 kHz is resampled to 16 kHz
44
+ * with the filter the API uses, and audio at 16 kHz or below keeps its rate. Resampled audio
45
+ * is written as 32-bit floating point, the format the API converts every file to, so loud
46
+ * audio cannot clip.
47
+ *
48
+ * 1. "mix", the default, mixes two channels into one the way the API does, adding them at
49
+ * -3 dB each, so the model hears the same audio as it would from the original file. A file
50
+ * that this would not make smaller, such as 16-bit mono at 16 kHz, is cut as it is, and so
51
+ * is audio with more than two channels, or two channels whose header places them anywhere
52
+ * but front left and front right, because the API weighs those channels by the speaker
53
+ * positions the header declares.
54
+ * 2. "first_channel" keeps only the first channel of a file with more than one, so the model
55
+ * hears only that channel. The channel is copied exactly in the recording's sample format
56
+ * when that is no larger than resampling it, as it is at 16 kHz or below for every sample
57
+ * format but 64-bit floating point. Use it when that channel holds the speaker to judge.
58
+ * Mono audio is treated as by "mix".
59
+ * 3. "none" cuts the audio as it is.
60
+ */
61
+ downmixStrategy?: DownmixStrategy;
62
+ }
63
+ }
64
+ /** A chunk's place in the recording, with its data left to be copied when it is needed. */
65
+ interface PlannedChunk {
66
+ readonly index: number;
67
+ readonly startMs: number;
68
+ readonly endMs: number;
69
+ readonly build: () => Uint8Array;
70
+ }
71
+ /** A recording's chunks, with the filename and content type its upload would carry. */
72
+ export interface PlannedRecording {
73
+ readonly filename: string | undefined;
74
+ readonly contentType: string | undefined;
75
+ readonly chunks: Iterable<PlannedChunk>;
76
+ }
77
+ /**
78
+ * Splits a recording, or part of one, into chunks short enough for the Decisions API.
79
+ *
80
+ * `maxChunkMs` is the longest a chunk can be, and `split` decides how the recording is divided:
81
+ *
82
+ * 1. "even", the default, cuts the fewest chunks that fit, of equal length, so that the last chunk
83
+ * is not a short remainder: 10 minutes and 1 second at a `maxChunkMs` of 300000 is cut into 3
84
+ * chunks of about 200 seconds.
85
+ * 2. "fixed" makes every chunk `maxChunkMs` long except the last, which holds what remains: the
86
+ * same recording is cut into 2 chunks of 5 minutes and 1 of 1 second. The last chunk is billed
87
+ * for its context and questions like any other, however short it is. Use it when chunks must be
88
+ * the same length across recordings.
89
+ *
90
+ * No chunk is empty. Cuts fall where the format allows, as described below, so `startMs` and
91
+ * `endMs` on each chunk give where it actually starts and ends.
92
+ *
93
+ * The model hears audio at 16 kHz in one channel: the API resamples and mixes down every file
94
+ * before the model hears it. A WAV file is mixed down the same way before it is cut, by default, so
95
+ * that the chunks are smaller to upload while the model hears the same audio. `downmixStrategy`
96
+ * describes how. MP3 files are cut as they are, because they are already compressed.
97
+ *
98
+ * The whole recording is read into memory, mixed down and checked before the first chunk is
99
+ * produced, so that a file that cannot be split is rejected before any chunk is. The options are
100
+ * checked by this call, and the file when iteration starts, so errors about the file are thrown by
101
+ * the first `next()`. The mixdown runs on the calling thread, taking several seconds for an hour of
102
+ * audio above 16 kHz, and pauses regularly to let other work run. Each chunk's `data` is a copy, made
103
+ * as the chunk is produced, so keeping every chunk holds the recording in memory twice.
104
+ *
105
+ * Apart from the WAV mixdown `downmixStrategy` asks for, the audio is copied as it is, never decoded
106
+ * or re-encoded, so cuts fall where the format allows:
107
+ *
108
+ * 1. A WAV file is cut between samples, after the mixdown. With "fixed", a cut can fall up to one
109
+ * sample before `startMs` plus a whole multiple of `maxChunkMs`, so the cuts stay on that grid.
110
+ * Each chunk is a new WAV file in the sample format of the mixed-down audio, holding only its
111
+ * audio; other chunks in the file, such as metadata, are left out.
112
+ * 2. An MP3 file is cut between frames, which last 24 to 72 ms depending on the sample rate, so
113
+ * chunks can differ in length by a frame, and a "fixed" chunk can be up to one frame shorter
114
+ * than `maxChunkMs`. `startMs` and `endMs` move to the nearest frame boundary. A frame can store
115
+ * part of its audio data in the frames before it, and its sound continues from the frame before,
116
+ * so each chunk also starts with the frames its first new frame needs to decode exactly. That is
117
+ * usually a few frames, and up to about 2 seconds at the lowest bitrates. Those frames count
118
+ * toward `maxChunkMs` and repeat the end of the previous chunk, or start before `startMs`. Each
119
+ * chunk holds only the recording's frames; tags, and the header frame that states the whole
120
+ * file's length, are left out. When that header frame has a LAME tag, as files from LAME and
121
+ * ffmpeg do, it states the silence the encoder added at each end, which players skip. Times are
122
+ * then measured from where a player starts the whole file, so the first chunk starts before 0,
123
+ * by about 25 ms for a typical 44.1 kHz file, and the last ends where the player stops.
124
+ *
125
+ * @param file The recording, an MP3 or WAV file, in any form `create` accepts. MP3 files of MPEG-1,
126
+ * 2 and 2.5 layer III are supported, except free format. WAV files of integer PCM (8, 16, 24 or
127
+ * 32-bit) and floating point (32 or 64-bit) are supported, with either the basic or the extensible
128
+ * WAV header. A stream is read from where it is to its end. `{ path }` needs file system access,
129
+ * which browsers do not have.
130
+ * @param options How to cut the recording.
131
+ * @returns The chunks in order. Their times are measured from the start of the recording, not from
132
+ * `startMs`.
133
+ *
134
+ * @throws {TypeError} From this call, if `maxChunkMs`, `startMs` or `endMs` is not a safe integer, or
135
+ * `file` is a string, which is not read as a path.
136
+ * @throws {RangeError} From this call, if `split` is not "even" or "fixed", `downmixStrategy` is not
137
+ * "mix", "first_channel" or "none", `maxChunkMs` is out of range, or `startMs` and `endMs` do not
138
+ * select a range. From iteration, if `startMs` and `endMs` do
139
+ * not select audio within the recording, `maxChunkMs` is too long with "fixed" for a WAV chunk to
140
+ * fit the API's size limit, or too short for an MP3 chunk to hold a new frame and the frames it
141
+ * needs.
142
+ * @throws {UnsupportedAudioError} From iteration, if the recording is empty or not a file this helper supports, such
143
+ * as a compressed WAV or RF64 file. Any damage to an MP3 file is found before the first chunk, so no
144
+ * chunk is produced from a file that cannot be read to the end.
145
+ *
146
+ * @example
147
+ * import { iterAudioChunks } from "@humeai/audio-decisions/audio-helpers";
148
+ *
149
+ * for await (const chunk of iterAudioChunks({ path: "call.wav" }, { maxChunkMs: 60_000 })) {
150
+ * console.log(chunk.index, chunk.startMs, chunk.endMs, chunk.data.length);
151
+ * }
152
+ */
153
+ export declare function iterAudioChunks(file: Uploadable, options: iterAudioChunks.Options): AsyncGenerator<AudioChunk, void, undefined>;
154
+ /**
155
+ * Checks `options` and `file`, and returns a function that reads the file, mixes it down and plans
156
+ * the chunks `iterAudioChunks` gives, without copying any chunk's data. The function rejects with a
157
+ * DecisionsError if `signal` aborts during the mixdown.
158
+ */
159
+ export declare function prepareChunks(file: Uploadable, options: iterAudioChunks.Options): (signal?: AbortSignal) => Promise<PlannedRecording>;
160
+ export {};
@@ -0,0 +1,346 @@
1
+ // Maintained by hand and listed in .fernignore, so SDK regeneration leaves it in place.
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
12
+ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
13
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
14
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
15
+ return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
16
+ function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
17
+ function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
18
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
19
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
20
+ function fulfill(value) { resume("next", value); }
21
+ function reject(value) { resume("throw", value); }
22
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
23
+ };
24
+ import { checkChoice, checkInteger } from "./checks.mjs";
25
+ import { checkDownmixStrategy, downmixWav } from "./downmix.mjs";
26
+ import { UnsupportedAudioError } from "./errors.mjs";
27
+ import { checkFile, readFile } from "./files.mjs";
28
+ import { ceilDiv, floorDiv, roundDiv } from "./integers.mjs";
29
+ import { framesNeededBefore, isMp3, mp3Chunk, parseMp3 } from "./mp3.mjs";
30
+ import { isWav, parseWav, wavChunk } from "./wav.mjs";
31
+ // The Decisions API accepts audio up to 5 minutes long.
32
+ const MAX_CHUNK_MS = 300000;
33
+ // The API accepts a request body of up to this many bytes, its JSON part and multipart headers included.
34
+ const MAX_REQUEST_BYTES = 25000000;
35
+ // The rest is left for the JSON part and multipart headers, so a chunk this size is accepted with any
36
+ // common request.
37
+ const MAX_CHUNK_BYTES = 24000000;
38
+ const SPLITS = ["even", "fixed"];
39
+ /**
40
+ * Splits a recording, or part of one, into chunks short enough for the Decisions API.
41
+ *
42
+ * `maxChunkMs` is the longest a chunk can be, and `split` decides how the recording is divided:
43
+ *
44
+ * 1. "even", the default, cuts the fewest chunks that fit, of equal length, so that the last chunk
45
+ * is not a short remainder: 10 minutes and 1 second at a `maxChunkMs` of 300000 is cut into 3
46
+ * chunks of about 200 seconds.
47
+ * 2. "fixed" makes every chunk `maxChunkMs` long except the last, which holds what remains: the
48
+ * same recording is cut into 2 chunks of 5 minutes and 1 of 1 second. The last chunk is billed
49
+ * for its context and questions like any other, however short it is. Use it when chunks must be
50
+ * the same length across recordings.
51
+ *
52
+ * No chunk is empty. Cuts fall where the format allows, as described below, so `startMs` and
53
+ * `endMs` on each chunk give where it actually starts and ends.
54
+ *
55
+ * The model hears audio at 16 kHz in one channel: the API resamples and mixes down every file
56
+ * before the model hears it. A WAV file is mixed down the same way before it is cut, by default, so
57
+ * that the chunks are smaller to upload while the model hears the same audio. `downmixStrategy`
58
+ * describes how. MP3 files are cut as they are, because they are already compressed.
59
+ *
60
+ * The whole recording is read into memory, mixed down and checked before the first chunk is
61
+ * produced, so that a file that cannot be split is rejected before any chunk is. The options are
62
+ * checked by this call, and the file when iteration starts, so errors about the file are thrown by
63
+ * the first `next()`. The mixdown runs on the calling thread, taking several seconds for an hour of
64
+ * audio above 16 kHz, and pauses regularly to let other work run. Each chunk's `data` is a copy, made
65
+ * as the chunk is produced, so keeping every chunk holds the recording in memory twice.
66
+ *
67
+ * Apart from the WAV mixdown `downmixStrategy` asks for, the audio is copied as it is, never decoded
68
+ * or re-encoded, so cuts fall where the format allows:
69
+ *
70
+ * 1. A WAV file is cut between samples, after the mixdown. With "fixed", a cut can fall up to one
71
+ * sample before `startMs` plus a whole multiple of `maxChunkMs`, so the cuts stay on that grid.
72
+ * Each chunk is a new WAV file in the sample format of the mixed-down audio, holding only its
73
+ * audio; other chunks in the file, such as metadata, are left out.
74
+ * 2. An MP3 file is cut between frames, which last 24 to 72 ms depending on the sample rate, so
75
+ * chunks can differ in length by a frame, and a "fixed" chunk can be up to one frame shorter
76
+ * than `maxChunkMs`. `startMs` and `endMs` move to the nearest frame boundary. A frame can store
77
+ * part of its audio data in the frames before it, and its sound continues from the frame before,
78
+ * so each chunk also starts with the frames its first new frame needs to decode exactly. That is
79
+ * usually a few frames, and up to about 2 seconds at the lowest bitrates. Those frames count
80
+ * toward `maxChunkMs` and repeat the end of the previous chunk, or start before `startMs`. Each
81
+ * chunk holds only the recording's frames; tags, and the header frame that states the whole
82
+ * file's length, are left out. When that header frame has a LAME tag, as files from LAME and
83
+ * ffmpeg do, it states the silence the encoder added at each end, which players skip. Times are
84
+ * then measured from where a player starts the whole file, so the first chunk starts before 0,
85
+ * by about 25 ms for a typical 44.1 kHz file, and the last ends where the player stops.
86
+ *
87
+ * @param file The recording, an MP3 or WAV file, in any form `create` accepts. MP3 files of MPEG-1,
88
+ * 2 and 2.5 layer III are supported, except free format. WAV files of integer PCM (8, 16, 24 or
89
+ * 32-bit) and floating point (32 or 64-bit) are supported, with either the basic or the extensible
90
+ * WAV header. A stream is read from where it is to its end. `{ path }` needs file system access,
91
+ * which browsers do not have.
92
+ * @param options How to cut the recording.
93
+ * @returns The chunks in order. Their times are measured from the start of the recording, not from
94
+ * `startMs`.
95
+ *
96
+ * @throws {TypeError} From this call, if `maxChunkMs`, `startMs` or `endMs` is not a safe integer, or
97
+ * `file` is a string, which is not read as a path.
98
+ * @throws {RangeError} From this call, if `split` is not "even" or "fixed", `downmixStrategy` is not
99
+ * "mix", "first_channel" or "none", `maxChunkMs` is out of range, or `startMs` and `endMs` do not
100
+ * select a range. From iteration, if `startMs` and `endMs` do
101
+ * not select audio within the recording, `maxChunkMs` is too long with "fixed" for a WAV chunk to
102
+ * fit the API's size limit, or too short for an MP3 chunk to hold a new frame and the frames it
103
+ * needs.
104
+ * @throws {UnsupportedAudioError} From iteration, if the recording is empty or not a file this helper supports, such
105
+ * as a compressed WAV or RF64 file. Any damage to an MP3 file is found before the first chunk, so no
106
+ * chunk is produced from a file that cannot be read to the end.
107
+ *
108
+ * @example
109
+ * import { iterAudioChunks } from "@humeai/audio-decisions/audio-helpers";
110
+ *
111
+ * for await (const chunk of iterAudioChunks({ path: "call.wav" }, { maxChunkMs: 60_000 })) {
112
+ * console.log(chunk.index, chunk.startMs, chunk.endMs, chunk.data.length);
113
+ * }
114
+ */
115
+ export function iterAudioChunks(file, options) {
116
+ return produceChunks(prepareChunks(file, options));
117
+ }
118
+ function produceChunks(planRecording) {
119
+ return __asyncGenerator(this, arguments, function* produceChunks_1() {
120
+ for (const chunk of (yield __await(planRecording())).chunks) {
121
+ yield yield __await({ index: chunk.index, startMs: chunk.startMs, endMs: chunk.endMs, data: chunk.build() });
122
+ }
123
+ });
124
+ }
125
+ /**
126
+ * Checks `options` and `file`, and returns a function that reads the file, mixes it down and plans
127
+ * the chunks `iterAudioChunks` gives, without copying any chunk's data. The function rejects with a
128
+ * DecisionsError if `signal` aborts during the mixdown.
129
+ */
130
+ export function prepareChunks(file, options) {
131
+ const checked = checkChunkOptions(options);
132
+ checkFile(file);
133
+ // A generator that read the file itself would keep the recording in memory for the whole job, even
134
+ // after a WAV file is mixed down into a smaller copy.
135
+ return (signal) => __awaiter(this, void 0, void 0, function* () {
136
+ const { data, filename, contentType } = yield readFile(file);
137
+ return { filename, contentType, chunks: yield planAudioChunks(data, checked, signal) };
138
+ });
139
+ }
140
+ function checkChunkOptions(options) {
141
+ const split = checkChoice("split", options.split === undefined ? "even" : options.split, SPLITS);
142
+ const downmixStrategy = checkDownmixStrategy(options.downmixStrategy);
143
+ const maxChunkMs = checkInteger("maxChunkMs", options.maxChunkMs);
144
+ if (maxChunkMs < 1 || maxChunkMs > MAX_CHUNK_MS) {
145
+ throw new RangeError(`maxChunkMs must be between 1 and ${MAX_CHUNK_MS}, got ${maxChunkMs}.`);
146
+ }
147
+ const startMs = options.startMs === undefined ? 0 : checkInteger("startMs", options.startMs);
148
+ if (startMs < 0) {
149
+ throw new RangeError(`startMs must not be negative, got ${startMs}.`);
150
+ }
151
+ const endMs = options.endMs === undefined ? undefined : checkInteger("endMs", options.endMs);
152
+ if (endMs !== undefined && endMs <= startMs) {
153
+ throw new RangeError(`endMs must be greater than startMs, got ${endMs}.`);
154
+ }
155
+ return { maxChunkMs, startMs, endMs, split, downmixStrategy };
156
+ }
157
+ function planAudioChunks(data, options, signal) {
158
+ return __awaiter(this, void 0, void 0, function* () {
159
+ var _a;
160
+ if (isWav(data)) {
161
+ const wav = parseWav(data);
162
+ const mixed = (_a = (yield downmixWav(data, wav, options.downmixStrategy, signal))) !== null && _a !== void 0 ? _a : { data, wav };
163
+ return wavChunks(mixed.data, mixed.wav, options);
164
+ }
165
+ if (isMp3(data)) {
166
+ return mp3Chunks(data, parseMp3(data), options);
167
+ }
168
+ throw new UnsupportedAudioError("Unsupported audio format. Only MP3 and WAV files can be split into chunks.");
169
+ });
170
+ }
171
+ /** The first and last positions of the range `startMs` and `endMs` select from `length` positions. */
172
+ function selectRange(length, msAt, positionAt, startMs, endMs) {
173
+ if (length === 0) {
174
+ throw new UnsupportedAudioError("The audio is empty.");
175
+ }
176
+ // The longest range allowed ends at the duration that the final chunk reports.
177
+ // A recording shorter than half a millisecond has a duration of 0 ms but still starts at 0.
178
+ const durationMs = msAt(length);
179
+ if (startMs > 0 && startMs >= durationMs) {
180
+ throw new RangeError(`startMs must be less than the recording's duration of ${durationMs} ms, got ${startMs}.`);
181
+ }
182
+ if (endMs !== undefined && endMs > durationMs) {
183
+ throw new RangeError(`endMs must not exceed the recording's duration of ${durationMs} ms, got ${endMs}.`);
184
+ }
185
+ // The duration is rounded to the millisecond, so it can fall short of the final position. An MP3
186
+ // recording can start and end partway through a frame, so its first and last frames are kept whole.
187
+ const first = startMs === 0 ? 0 : positionAt(startMs);
188
+ const last = endMs === undefined || endMs >= durationMs ? length : Math.min(positionAt(endMs), length);
189
+ return [first, last];
190
+ }
191
+ function wavChunks(data, wav, { maxChunkMs, startMs, endMs, split }) {
192
+ const msAt = (sample) => toMs(sample, wav.sampleRate);
193
+ const [first, last] = selectRange(wav.sampleCount, msAt, (ms) => toSample(ms, wav.sampleRate), startMs, endMs);
194
+ // When maxChunkMs is not a whole number of samples, a chunk can be up to one sample longer.
195
+ const longest = ceilDiv(maxChunkMs * wav.sampleRate, 1000);
196
+ const fitting = wavSamplesThatFit(wav);
197
+ let cuts;
198
+ if (split === "even") {
199
+ cuts = evenWavCuts(first, last, Math.min(longest, fitting));
200
+ }
201
+ else {
202
+ checkWavSize(wav, Math.min(longest, last - first), fitting);
203
+ cuts = fixedWavCuts(wav, maxChunkMs, startMs, first, last);
204
+ }
205
+ return plan(cuts, msAt, (start, end) => wavChunk(data, wav, start, end));
206
+ }
207
+ function wavSamplesThatFit(wav) {
208
+ // An MP3 chunk needs no such limit: at the highest bitrate, 5 minutes of MP3 is about 12 MB.
209
+ // The header holds the RIFF, fmt and data chunk headers, and the data can need a padding byte.
210
+ const headerBytes = 28 + wav.fmt.length + 1;
211
+ return floorDiv(MAX_CHUNK_BYTES - headerBytes, wav.frameBytes);
212
+ }
213
+ function checkWavSize(wav, longest, fitting) {
214
+ if (longest <= fitting) {
215
+ return;
216
+ }
217
+ const fittingMs = floorDiv(fitting * 1000, wav.sampleRate);
218
+ throw new RangeError(`maxChunkMs must be at most ${fittingMs} for this WAV file with split="fixed", so that the request for` +
219
+ ` each chunk fits within the API limit of ${MAX_REQUEST_BYTES.toLocaleString("en-US")} bytes.` +
220
+ ` split="even" cuts shorter chunks that fit instead, and mono or stereo audio mixed down with` +
221
+ ` downmixStrategy="mix" fits 5-minute chunks.`);
222
+ }
223
+ function mp3Chunks(data, mp3, { maxChunkMs, startMs, endMs, split }) {
224
+ const msAt = (frame) => mp3TimeMs(mp3, frame);
225
+ const [first, last] = selectRange(mp3.frameCount, msAt, (ms) => frameAt(mp3, ms), startMs, endMs);
226
+ // Rounding down keeps every chunk within maxChunkMs, so a maxChunkMs of 300000 stays within the
227
+ // API's limit.
228
+ const framesPerChunk = floorDiv(maxChunkMs * mp3.sampleRate, 1000 * mp3.samplesPerFrame);
229
+ const frameMs = framesMs(mp3, 1);
230
+ if (framesPerChunk === 0) {
231
+ throw new RangeError(`maxChunkMs must be at least ${frameMs} ms, the length of one frame of this MP3 file.`);
232
+ }
233
+ if (last <= first) {
234
+ throw new RangeError(`startMs and endMs must be at least ${frameMs} ms apart, the length of one frame of this MP3 file.`);
235
+ }
236
+ // A chunk that could hold only the frames needed before its first new frame would never advance.
237
+ // Filling fails only when this check does, which also rejects a maxChunkMs that happens to work
238
+ // for this range's cuts but not for every frame in it.
239
+ let neededBefore = 0;
240
+ for (let frame = first; frame < last; frame++) {
241
+ neededBefore = Math.max(neededBefore, framesNeededBefore(mp3, frame));
242
+ }
243
+ const filled = fillMp3Chunks(mp3, framesPerChunk, first, last);
244
+ if (filled === undefined || framesPerChunk <= neededBefore) {
245
+ throw new RangeError(`maxChunkMs must be at least ${framesMs(mp3, neededBefore + 1)} ms for this MP3 file. Its frames` +
246
+ ` need up to ${neededBefore} frames before them to decode, and a chunk must hold those along with` +
247
+ " at least one new frame.");
248
+ }
249
+ const cuts = split === "even" ? evenMp3Cuts(mp3, filled, framesPerChunk, first, last) : filled;
250
+ return plan(cuts, msAt, (start, end) => mp3Chunk(data, mp3, start, end));
251
+ }
252
+ function frameAt(mp3, ms) {
253
+ // Times given by the caller are often ones a chunk reported, which are rounded to the
254
+ // millisecond, so they move to the nearest frame boundary rather than the one before.
255
+ return roundDiv(ms * mp3.sampleRate + 1000 * mp3.leadingSamples, 1000 * mp3.samplesPerFrame);
256
+ }
257
+ function framesMs(mp3, frames) {
258
+ return ceilDiv(frames * mp3.samplesPerFrame * 1000, mp3.sampleRate);
259
+ }
260
+ function mp3TimeMs(mp3, frame) {
261
+ // Times are measured from where a player starts the recording, after the samples the encoder and
262
+ // decoder add, so the first chunk can start before 0 ms. The player also stops before the
263
+ // samples added at the end.
264
+ return toMs(Math.min(frame * mp3.samplesPerFrame, mp3.endSample) - mp3.leadingSamples, mp3.sampleRate);
265
+ }
266
+ function evenMp3Cuts(mp3, filled, framesPerChunk, first, last) {
267
+ // Filling every chunk gives the fewest chunks but can leave a short last chunk. The shortest
268
+ // chunk length that needs no more chunks than that shares the frames out evenly instead.
269
+ let cuts = filled;
270
+ let low = 1;
271
+ let high = framesPerChunk;
272
+ while (low < high) {
273
+ const middle = Math.floor((low + high) / 2);
274
+ const shorter = fillMp3Chunks(mp3, middle, first, last);
275
+ if (shorter !== undefined && shorter.length <= cuts.length) {
276
+ cuts = shorter;
277
+ high = middle;
278
+ }
279
+ else {
280
+ low = middle + 1;
281
+ }
282
+ }
283
+ return cuts;
284
+ }
285
+ /** Cuts chunks of `framesPerChunk` frames, or undefined when a chunk cannot hold a new frame. */
286
+ function fillMp3Chunks(mp3, framesPerChunk, first, last) {
287
+ const cuts = [];
288
+ let next = first;
289
+ while (next < last) {
290
+ // Without the frames before it, the first new frame decodes wrongly. They repeat the end of
291
+ // the previous chunk.
292
+ const start = next - framesNeededBefore(mp3, next);
293
+ if (start + framesPerChunk <= next) {
294
+ return undefined;
295
+ }
296
+ const end = Math.min(start + framesPerChunk, last);
297
+ cuts.push([start, end]);
298
+ next = end;
299
+ }
300
+ return cuts;
301
+ }
302
+ function* evenWavCuts(first, last, longest) {
303
+ const length = last - first;
304
+ const count = ceilDiv(length, longest);
305
+ // Chunk i starts at first + floor(length * i / count). That product can pass
306
+ // Number.MAX_SAFE_INTEGER, so the cuts are stepped by the quotient and carry the remainder.
307
+ const step = floorDiv(length, count);
308
+ const extra = length - step * count;
309
+ let start = first;
310
+ let remainder = 0;
311
+ for (let index = 0; index < count; index++) {
312
+ let end = start + step;
313
+ remainder += extra;
314
+ if (remainder >= count) {
315
+ remainder -= count;
316
+ end += 1;
317
+ }
318
+ yield [start, end];
319
+ start = end;
320
+ }
321
+ }
322
+ function* fixedWavCuts(wav, maxChunkMs, startMs, first, last) {
323
+ let start = first;
324
+ let index = 0;
325
+ while (start < last) {
326
+ // Each cut is computed from startMs rather than from the previous cut, so rounding does not
327
+ // accumulate.
328
+ const end = Math.min(toSample(startMs + (index + 1) * maxChunkMs, wav.sampleRate), last);
329
+ yield [start, end];
330
+ index += 1;
331
+ start = end;
332
+ }
333
+ }
334
+ function* plan(cuts, msAt, build) {
335
+ let index = 0;
336
+ for (const [start, end] of cuts) {
337
+ yield { index, startMs: msAt(start), endMs: msAt(end), build: () => build(start, end) };
338
+ index += 1;
339
+ }
340
+ }
341
+ function toSample(ms, sampleRate) {
342
+ return floorDiv(ms * sampleRate, 1000);
343
+ }
344
+ function toMs(sample, sampleRate) {
345
+ return roundDiv(sample * 1000, sampleRate);
346
+ }
@@ -0,0 +1,17 @@
1
+ import { type WavAudio } from "./wav.mjs";
2
+ declare const STRATEGIES: readonly ["mix", "first_channel", "none"];
3
+ /** How a WAV file is mixed down before it is sent: "mix", "first_channel", or "none" to send it as it is. */
4
+ export type DownmixStrategy = (typeof STRATEGIES)[number];
5
+ interface Downmixed {
6
+ readonly data: Uint8Array;
7
+ readonly wav: WavAudio;
8
+ }
9
+ export declare function checkDownmixStrategy(strategy?: unknown): DownmixStrategy;
10
+ /**
11
+ * The samples of `wav` mixed down by `strategy` into one channel, with a description of them, or
12
+ * undefined when the file is best sent as it is: the API would mix it the same way and converting it
13
+ * would not make it smaller. Resampled audio is at most MODEL_SAMPLE_RATE, in 32-bit floating point.
14
+ * Rejects with a DecisionsError once `signal` aborts.
15
+ */
16
+ export declare function downmixWav(data: Uint8Array, wav: WavAudio, strategy: DownmixStrategy, signal?: AbortSignal): Promise<Downmixed | undefined>;
17
+ export {};