@speechall/sdk 0.0.1 → 2.0.4

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 (151) hide show
  1. package/.beads/README.md +81 -0
  2. package/.beads/config.yaml +62 -0
  3. package/.beads/issues.jsonl +46 -0
  4. package/.beads/metadata.json +4 -0
  5. package/.env.example +5 -0
  6. package/.fernignore +45 -0
  7. package/.gitattributes +3 -0
  8. package/.github/copilot-instructions.md +78 -0
  9. package/.github/workflows/auto-release-simple.yml.deprecated +106 -0
  10. package/.github/workflows/auto-release.yml +67 -0
  11. package/.github/workflows/ci.yml +41 -0
  12. package/.github/workflows/release.yml +57 -0
  13. package/AGENTS.md +94 -0
  14. package/CHANGELOG.md +58 -0
  15. package/CLAUDE.md +75 -0
  16. package/README.md +294 -155
  17. package/examples/CLAUDE.md +136 -0
  18. package/examples/advanced-options.ts +213 -0
  19. package/examples/basic-transcription.ts +66 -0
  20. package/examples/error-handling.ts +251 -0
  21. package/examples/list-models.ts +112 -0
  22. package/examples/remote-transcription.ts +60 -0
  23. package/fern/fern.config.json +4 -0
  24. package/fern/generators.yml +43 -0
  25. package/jest.config.js +11 -0
  26. package/package.json +26 -44
  27. package/regenerate.sh +45 -0
  28. package/scripts/fix-generated-code.sh +25 -0
  29. package/src/BaseClient.ts +82 -0
  30. package/src/Client.ts +30 -0
  31. package/src/api/errors/BadRequestError.ts +22 -0
  32. package/src/api/errors/GatewayTimeoutError.ts +22 -0
  33. package/src/api/errors/InternalServerError.ts +22 -0
  34. package/src/api/errors/NotFoundError.ts +22 -0
  35. package/src/api/errors/PaymentRequiredError.ts +22 -0
  36. package/src/api/errors/ServiceUnavailableError.ts +22 -0
  37. package/src/api/errors/TooManyRequestsError.ts +22 -0
  38. package/src/api/errors/UnauthorizedError.ts +22 -0
  39. package/src/api/errors/index.ts +8 -0
  40. package/src/api/index.ts +3 -0
  41. package/src/api/resources/index.ts +5 -0
  42. package/src/api/resources/replacementRules/client/Client.ts +148 -0
  43. package/src/api/resources/replacementRules/client/index.ts +1 -0
  44. package/src/api/resources/replacementRules/client/requests/CreateReplacementRulesetRequest.ts +25 -0
  45. package/src/api/resources/replacementRules/client/requests/index.ts +1 -0
  46. package/src/api/resources/replacementRules/index.ts +2 -0
  47. package/src/api/resources/replacementRules/types/CreateReplacementRulesetResponse.ts +6 -0
  48. package/src/api/resources/replacementRules/types/index.ts +1 -0
  49. package/src/api/resources/speechToText/client/Client.ts +275 -0
  50. package/src/api/resources/speechToText/client/index.ts +1 -0
  51. package/src/api/resources/speechToText/client/requests/RemoteTranscriptionConfiguration.ts +20 -0
  52. package/src/api/resources/speechToText/client/requests/TranscribeRequest.ts +26 -0
  53. package/src/api/resources/speechToText/client/requests/index.ts +2 -0
  54. package/src/api/resources/speechToText/index.ts +1 -0
  55. package/src/api/types/BaseTranscriptionConfiguration.ts +29 -0
  56. package/src/api/types/ErrorResponse.ts +11 -0
  57. package/src/api/types/ExactRule.ts +13 -0
  58. package/src/api/types/RegexGroupRule.ts +28 -0
  59. package/src/api/types/RegexRule.ts +28 -0
  60. package/src/api/types/ReplacementRule.ts +25 -0
  61. package/src/api/types/SpeechToTextModel.ts +90 -0
  62. package/src/api/types/TranscriptLanguageCode.ts +114 -0
  63. package/src/api/types/TranscriptOutputFormat.ts +18 -0
  64. package/src/api/types/TranscriptionDetailed.ts +19 -0
  65. package/src/api/types/TranscriptionModelIdentifier.ts +80 -0
  66. package/src/api/types/TranscriptionOnlyText.ts +11 -0
  67. package/src/api/types/TranscriptionProvider.ts +23 -0
  68. package/src/api/types/TranscriptionResponse.ts +8 -0
  69. package/src/api/types/TranscriptionSegment.ts +17 -0
  70. package/src/api/types/TranscriptionWord.ts +17 -0
  71. package/src/api/types/index.ts +16 -0
  72. package/src/auth/BearerAuthProvider.ts +37 -0
  73. package/src/auth/index.ts +1 -0
  74. package/src/core/auth/AuthProvider.ts +6 -0
  75. package/src/core/auth/AuthRequest.ts +9 -0
  76. package/src/core/auth/BasicAuth.ts +32 -0
  77. package/src/core/auth/BearerToken.ts +20 -0
  78. package/src/core/auth/NoOpAuthProvider.ts +8 -0
  79. package/src/core/auth/index.ts +5 -0
  80. package/src/core/base64.ts +27 -0
  81. package/src/core/exports.ts +2 -0
  82. package/src/core/fetcher/APIResponse.ts +23 -0
  83. package/src/core/fetcher/BinaryResponse.ts +34 -0
  84. package/src/core/fetcher/EndpointMetadata.ts +13 -0
  85. package/src/core/fetcher/EndpointSupplier.ts +14 -0
  86. package/src/core/fetcher/Fetcher.ts +391 -0
  87. package/src/core/fetcher/Headers.ts +93 -0
  88. package/src/core/fetcher/HttpResponsePromise.ts +116 -0
  89. package/src/core/fetcher/RawResponse.ts +61 -0
  90. package/src/core/fetcher/Supplier.ts +11 -0
  91. package/src/core/fetcher/createRequestUrl.ts +6 -0
  92. package/src/core/fetcher/getErrorResponseBody.ts +33 -0
  93. package/src/core/fetcher/getFetchFn.ts +3 -0
  94. package/src/core/fetcher/getHeader.ts +8 -0
  95. package/src/core/fetcher/getRequestBody.ts +20 -0
  96. package/src/core/fetcher/getResponseBody.ts +58 -0
  97. package/src/core/fetcher/index.ts +11 -0
  98. package/src/core/fetcher/makeRequest.ts +42 -0
  99. package/src/core/fetcher/requestWithRetries.ts +64 -0
  100. package/src/core/fetcher/signals.ts +26 -0
  101. package/src/core/file/exports.ts +1 -0
  102. package/src/core/file/file.ts +217 -0
  103. package/src/core/file/index.ts +2 -0
  104. package/src/core/file/types.ts +81 -0
  105. package/src/core/headers.ts +35 -0
  106. package/src/core/index.ts +7 -0
  107. package/src/core/json.ts +27 -0
  108. package/src/core/logging/exports.ts +19 -0
  109. package/src/core/logging/index.ts +1 -0
  110. package/src/core/logging/logger.ts +203 -0
  111. package/src/core/runtime/index.ts +1 -0
  112. package/src/core/runtime/runtime.ts +134 -0
  113. package/src/core/url/encodePathParam.ts +18 -0
  114. package/src/core/url/index.ts +3 -0
  115. package/src/core/url/join.ts +79 -0
  116. package/src/core/url/qs.ts +74 -0
  117. package/src/environments.ts +7 -0
  118. package/src/errors/SpeechallError.ts +58 -0
  119. package/src/errors/SpeechallTimeoutError.ts +13 -0
  120. package/src/errors/handleNonStatusCodeError.ts +37 -0
  121. package/src/errors/index.ts +2 -0
  122. package/src/exports.ts +1 -0
  123. package/src/index.ts +6 -0
  124. package/test-import.ts +17 -0
  125. package/tests/integration/api.test.ts +93 -0
  126. package/tests/unit/client.test.ts +91 -0
  127. package/tsconfig.json +20 -0
  128. package/dist/api.d.ts +0 -467
  129. package/dist/api.d.ts.map +0 -1
  130. package/dist/api.js +0 -592
  131. package/dist/base.d.ts +0 -32
  132. package/dist/base.d.ts.map +0 -1
  133. package/dist/base.js +0 -35
  134. package/dist/common.d.ts +0 -14
  135. package/dist/common.d.ts.map +0 -1
  136. package/dist/common.js +0 -91
  137. package/dist/configuration.d.ts +0 -23
  138. package/dist/configuration.d.ts.map +0 -1
  139. package/dist/configuration.js +0 -25
  140. package/dist/esm/api.js +0 -574
  141. package/dist/esm/base.js +0 -27
  142. package/dist/esm/common.js +0 -79
  143. package/dist/esm/configuration.js +0 -21
  144. package/dist/esm/example.js +0 -131
  145. package/dist/esm/index.js +0 -2
  146. package/dist/example.d.ts +0 -3
  147. package/dist/example.d.ts.map +0 -1
  148. package/dist/example.js +0 -133
  149. package/dist/index.d.ts +0 -3
  150. package/dist/index.d.ts.map +0 -1
  151. package/dist/index.js +0 -18
@@ -0,0 +1,148 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+
3
+ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
4
+ import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";
5
+ import { mergeHeaders } from "../../../../core/headers.js";
6
+ import * as core from "../../../../core/index.js";
7
+ import * as environments from "../../../../environments.js";
8
+ import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";
9
+ import * as errors from "../../../../errors/index.js";
10
+ import * as Speechall from "../../../index.js";
11
+
12
+ export declare namespace ReplacementRulesClient {
13
+ export type Options = BaseClientOptions;
14
+
15
+ export interface RequestOptions extends BaseRequestOptions {}
16
+ }
17
+
18
+ /**
19
+ * Operations for creating and managing custom rulesets to find and replace text within transcriptions.
20
+ */
21
+ export class ReplacementRulesClient {
22
+ protected readonly _options: NormalizedClientOptionsWithAuth<ReplacementRulesClient.Options>;
23
+
24
+ constructor(options: ReplacementRulesClient.Options) {
25
+ this._options = normalizeClientOptionsWithAuth(options);
26
+ }
27
+
28
+ /**
29
+ * Defines a named set of replacement rules (exact match, regex) that can be applied during transcription requests using its `ruleset_id`.
30
+ * Rules within a set are applied sequentially to the transcription text.
31
+ *
32
+ * @param {Speechall.CreateReplacementRulesetRequest} request
33
+ * @param {ReplacementRulesClient.RequestOptions} requestOptions - Request-specific configuration.
34
+ *
35
+ * @throws {@link Speechall.BadRequestError}
36
+ * @throws {@link Speechall.UnauthorizedError}
37
+ * @throws {@link Speechall.PaymentRequiredError}
38
+ * @throws {@link Speechall.TooManyRequestsError}
39
+ * @throws {@link Speechall.InternalServerError}
40
+ * @throws {@link Speechall.ServiceUnavailableError}
41
+ * @throws {@link Speechall.GatewayTimeoutError}
42
+ *
43
+ * @example
44
+ * await client.replacementRules.createReplacementRuleset({
45
+ * name: "Acme Corp Corrections",
46
+ * rules: [{
47
+ * kind: "exact",
48
+ * search: "customer X",
49
+ * replacement: "[REDACTED CUSTOMER NAME]"
50
+ * }, {
51
+ * kind: "regex",
52
+ * pattern: "\\b\\d{4}\\b",
53
+ * replacement: "[REDACTED YEAR]"
54
+ * }]
55
+ * })
56
+ */
57
+ public createReplacementRuleset(
58
+ request: Speechall.CreateReplacementRulesetRequest,
59
+ requestOptions?: ReplacementRulesClient.RequestOptions,
60
+ ): core.HttpResponsePromise<Speechall.CreateReplacementRulesetResponse> {
61
+ return core.HttpResponsePromise.fromPromise(this.__createReplacementRuleset(request, requestOptions));
62
+ }
63
+
64
+ private async __createReplacementRuleset(
65
+ request: Speechall.CreateReplacementRulesetRequest,
66
+ requestOptions?: ReplacementRulesClient.RequestOptions,
67
+ ): Promise<core.WithRawResponse<Speechall.CreateReplacementRulesetResponse>> {
68
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
69
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
70
+ _authRequest.headers,
71
+ this._options?.headers,
72
+ requestOptions?.headers,
73
+ );
74
+ const _response = await core.fetcher({
75
+ url: core.url.join(
76
+ (await core.Supplier.get(this._options.baseUrl)) ??
77
+ (await core.Supplier.get(this._options.environment)) ??
78
+ environments.SpeechallEnvironment.Default,
79
+ "replacement-rulesets",
80
+ ),
81
+ method: "POST",
82
+ headers: _headers,
83
+ contentType: "application/json",
84
+ queryParameters: requestOptions?.queryParams,
85
+ requestType: "json",
86
+ body: request,
87
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
88
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
89
+ abortSignal: requestOptions?.abortSignal,
90
+ fetchFn: this._options?.fetch,
91
+ logging: this._options.logging,
92
+ });
93
+ if (_response.ok) {
94
+ return {
95
+ data: _response.body as Speechall.CreateReplacementRulesetResponse,
96
+ rawResponse: _response.rawResponse,
97
+ };
98
+ }
99
+
100
+ if (_response.error.reason === "status-code") {
101
+ switch (_response.error.statusCode) {
102
+ case 400:
103
+ throw new Speechall.BadRequestError(
104
+ _response.error.body as Speechall.ErrorResponse,
105
+ _response.rawResponse,
106
+ );
107
+ case 401:
108
+ throw new Speechall.UnauthorizedError(
109
+ _response.error.body as Speechall.ErrorResponse,
110
+ _response.rawResponse,
111
+ );
112
+ case 402:
113
+ throw new Speechall.PaymentRequiredError(
114
+ _response.error.body as Speechall.ErrorResponse,
115
+ _response.rawResponse,
116
+ );
117
+ case 429:
118
+ throw new Speechall.TooManyRequestsError(
119
+ _response.error.body as Speechall.ErrorResponse,
120
+ _response.rawResponse,
121
+ );
122
+ case 500:
123
+ throw new Speechall.InternalServerError(
124
+ _response.error.body as Speechall.ErrorResponse,
125
+ _response.rawResponse,
126
+ );
127
+ case 503:
128
+ throw new Speechall.ServiceUnavailableError(
129
+ _response.error.body as Speechall.ErrorResponse,
130
+ _response.rawResponse,
131
+ );
132
+ case 504:
133
+ throw new Speechall.GatewayTimeoutError(
134
+ _response.error.body as Speechall.ErrorResponse,
135
+ _response.rawResponse,
136
+ );
137
+ default:
138
+ throw new errors.SpeechallError({
139
+ statusCode: _response.error.statusCode,
140
+ body: _response.error.body,
141
+ rawResponse: _response.rawResponse,
142
+ });
143
+ }
144
+ }
145
+
146
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/replacement-rulesets");
147
+ }
148
+ }
@@ -0,0 +1 @@
1
+ export * from "./requests/index.js";
@@ -0,0 +1,25 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+
3
+ import type * as Speechall from "../../../../index.js";
4
+
5
+ /**
6
+ * @example
7
+ * {
8
+ * name: "Acme Corp Corrections",
9
+ * rules: [{
10
+ * kind: "exact",
11
+ * search: "customer X",
12
+ * replacement: "[REDACTED CUSTOMER NAME]"
13
+ * }, {
14
+ * kind: "regex",
15
+ * pattern: "\\b\\d{4}\\b",
16
+ * replacement: "[REDACTED YEAR]"
17
+ * }]
18
+ * }
19
+ */
20
+ export interface CreateReplacementRulesetRequest {
21
+ /** A user-defined name for this ruleset for easier identification. */
22
+ name: string;
23
+ /** An ordered array of replacement rules. Rules are applied in the order they appear in this list. See the `ReplacementRule` schema for different rule types (exact, regex, regex_group). */
24
+ rules: Speechall.ReplacementRule[];
25
+ }
@@ -0,0 +1 @@
1
+ export type { CreateReplacementRulesetRequest } from "./CreateReplacementRulesetRequest.js";
@@ -0,0 +1,2 @@
1
+ export * from "./client/index.js";
2
+ export * from "./types/index.js";
@@ -0,0 +1,6 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+
3
+ export interface CreateReplacementRulesetResponse {
4
+ /** The unique identifier (UUID) generated for this ruleset. Use this ID in the `ruleset_id` parameter of transcription requests. */
5
+ id: string;
6
+ }
@@ -0,0 +1 @@
1
+ export * from "./CreateReplacementRulesetResponse.js";
@@ -0,0 +1,275 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+
3
+ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
4
+ import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";
5
+ import { mergeHeaders } from "../../../../core/headers.js";
6
+ import * as core from "../../../../core/index.js";
7
+ import * as environments from "../../../../environments.js";
8
+ import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";
9
+ import * as errors from "../../../../errors/index.js";
10
+ import * as Speechall from "../../../index.js";
11
+
12
+ export declare namespace SpeechToTextClient {
13
+ export type Options = BaseClientOptions;
14
+
15
+ export interface RequestOptions extends BaseRequestOptions {
16
+ }
17
+ }
18
+
19
+ /**
20
+ * Primary endpoints for converting audio streams or files into text transcripts.
21
+ */
22
+ export class SpeechToTextClient {
23
+ protected readonly _options: NormalizedClientOptionsWithAuth<SpeechToTextClient.Options>;
24
+
25
+ constructor(options: SpeechToTextClient.Options) {
26
+
27
+
28
+ this._options = normalizeClientOptionsWithAuth(options);
29
+
30
+ }
31
+
32
+ /**
33
+ * This endpoint allows you to send raw audio data in the request body for transcription.
34
+ * You can specify the desired model, language, output format, and various provider-specific features using query parameters.
35
+ * Suitable for transcribing local audio files.
36
+ *
37
+ * @param {core.file.Uploadable} uploadable
38
+ * @param {Speechall.TranscribeRequest} request
39
+ * @param {SpeechToTextClient.RequestOptions} requestOptions - Request-specific configuration.
40
+ *
41
+ * @throws {@link Speechall.BadRequestError}
42
+ * @throws {@link Speechall.UnauthorizedError}
43
+ * @throws {@link Speechall.PaymentRequiredError}
44
+ * @throws {@link Speechall.NotFoundError}
45
+ * @throws {@link Speechall.TooManyRequestsError}
46
+ * @throws {@link Speechall.InternalServerError}
47
+ * @throws {@link Speechall.ServiceUnavailableError}
48
+ * @throws {@link Speechall.GatewayTimeoutError}
49
+ */
50
+ public transcribe(uploadable: core.file.Uploadable, request: Speechall.TranscribeRequest, requestOptions?: SpeechToTextClient.RequestOptions): core.HttpResponsePromise<Speechall.TranscriptionResponse> {
51
+ return core.HttpResponsePromise.fromPromise(this.__transcribe(uploadable, request, requestOptions));
52
+ }
53
+
54
+ private async __transcribe(uploadable: core.file.Uploadable, request: Speechall.TranscribeRequest, requestOptions?: SpeechToTextClient.RequestOptions): Promise<core.WithRawResponse<Speechall.TranscriptionResponse>> {
55
+ const _queryParams: Record<string, string | string[] | object | object[] | null> = {};
56
+ _queryParams.model = request.model;
57
+ if (request.language != null) {
58
+ _queryParams.language = request.language;
59
+ }
60
+
61
+ if (request.output_format != null) {
62
+ _queryParams.output_format = request.output_format;
63
+ }
64
+
65
+ if (request.ruleset_id != null) {
66
+ _queryParams.ruleset_id = request.ruleset_id;
67
+ }
68
+
69
+ if (request.punctuation != null) {
70
+ _queryParams.punctuation = request.punctuation.toString();
71
+ }
72
+
73
+ if (request.diarization != null) {
74
+ _queryParams.diarization = request.diarization.toString();
75
+ }
76
+
77
+ if (request.initial_prompt != null) {
78
+ _queryParams.initial_prompt = request.initial_prompt;
79
+ }
80
+
81
+ if (request.temperature != null) {
82
+ _queryParams.temperature = request.temperature.toString();
83
+ }
84
+
85
+ if (request.speakers_expected != null) {
86
+ _queryParams.speakers_expected = request.speakers_expected.toString();
87
+ }
88
+
89
+ if (request.custom_vocabulary != null) {
90
+ if (Array.isArray(request.custom_vocabulary)) {
91
+ _queryParams.custom_vocabulary = request.custom_vocabulary.map(item => item);
92
+ }
93
+ else {
94
+ _queryParams.custom_vocabulary = request.custom_vocabulary;
95
+ }
96
+ }
97
+
98
+ const _binaryUploadRequest = await core.file.toBinaryUploadRequest(uploadable);
99
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
100
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(_authRequest.headers, this._options?.headers, _binaryUploadRequest.headers, requestOptions?.headers);
101
+ const _response = await core.fetcher({
102
+ url: core.url.join(await core.Supplier.get(this._options.baseUrl) ?? (await core.Supplier.get(this._options.environment) ?? environments.SpeechallEnvironment.Default), "transcribe"),
103
+ method: "POST",
104
+ headers: _headers,
105
+ contentType: "audio/*",
106
+ queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
107
+ requestType: "bytes",
108
+ duplex: "half",
109
+ body: _binaryUploadRequest.body,
110
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
111
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
112
+ abortSignal: requestOptions?.abortSignal,
113
+ fetchFn: this._options?.fetch,
114
+ logging: this._options.logging
115
+ });
116
+ if (_response.ok) {
117
+ return { data: _response.body as Speechall.TranscriptionResponse, rawResponse: _response.rawResponse };
118
+ }
119
+
120
+ if (_response.error.reason === "status-code") {
121
+ switch (_response.error.statusCode) {
122
+ case 400: throw new Speechall.BadRequestError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
123
+ case 401: throw new Speechall.UnauthorizedError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
124
+ case 402: throw new Speechall.PaymentRequiredError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
125
+ case 404: throw new Speechall.NotFoundError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
126
+ case 429: throw new Speechall.TooManyRequestsError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
127
+ case 500: throw new Speechall.InternalServerError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
128
+ case 503: throw new Speechall.ServiceUnavailableError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
129
+ case 504: throw new Speechall.GatewayTimeoutError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
130
+ default: throw new errors.SpeechallError({
131
+ statusCode: _response.error.statusCode,
132
+ body: _response.error.body,
133
+ rawResponse: _response.rawResponse
134
+ });
135
+ }
136
+ }
137
+
138
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/transcribe");
139
+ }
140
+
141
+ /**
142
+ * This endpoint allows you to transcribe an audio file hosted at a publicly accessible URL.
143
+ * Provide the URL and transcription options within the JSON request body.
144
+ * Useful for transcribing files already stored online.
145
+ *
146
+ * @param {Speechall.RemoteTranscriptionConfiguration} request
147
+ * @param {SpeechToTextClient.RequestOptions} requestOptions - Request-specific configuration.
148
+ *
149
+ * @throws {@link Speechall.BadRequestError}
150
+ * @throws {@link Speechall.UnauthorizedError}
151
+ * @throws {@link Speechall.PaymentRequiredError}
152
+ * @throws {@link Speechall.NotFoundError}
153
+ * @throws {@link Speechall.TooManyRequestsError}
154
+ * @throws {@link Speechall.InternalServerError}
155
+ * @throws {@link Speechall.ServiceUnavailableError}
156
+ * @throws {@link Speechall.GatewayTimeoutError}
157
+ *
158
+ * @example
159
+ * await client.speechToText.transcribeRemote({
160
+ * model: "openai.whisper-1",
161
+ * language: "en",
162
+ * output_format: "json",
163
+ * diarization: true,
164
+ * file_url: "https://example.com/path/to/audio.mp3"
165
+ * })
166
+ */
167
+ public transcribeRemote(request: Speechall.RemoteTranscriptionConfiguration, requestOptions?: SpeechToTextClient.RequestOptions): core.HttpResponsePromise<Speechall.TranscriptionResponse> {
168
+ return core.HttpResponsePromise.fromPromise(this.__transcribeRemote(request, requestOptions));
169
+ }
170
+
171
+ private async __transcribeRemote(request: Speechall.RemoteTranscriptionConfiguration, requestOptions?: SpeechToTextClient.RequestOptions): Promise<core.WithRawResponse<Speechall.TranscriptionResponse>> {
172
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
173
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
174
+ const _response = await core.fetcher({
175
+ url: core.url.join(await core.Supplier.get(this._options.baseUrl) ?? (await core.Supplier.get(this._options.environment) ?? environments.SpeechallEnvironment.Default), "transcribe-remote"),
176
+ method: "POST",
177
+ headers: _headers,
178
+ contentType: "application/json",
179
+ queryParameters: requestOptions?.queryParams,
180
+ requestType: "json",
181
+ body: request,
182
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
183
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
184
+ abortSignal: requestOptions?.abortSignal,
185
+ fetchFn: this._options?.fetch,
186
+ logging: this._options.logging
187
+ });
188
+ if (_response.ok) {
189
+ return { data: _response.body as Speechall.TranscriptionResponse, rawResponse: _response.rawResponse };
190
+ }
191
+
192
+ if (_response.error.reason === "status-code") {
193
+ switch (_response.error.statusCode) {
194
+ case 400: throw new Speechall.BadRequestError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
195
+ case 401: throw new Speechall.UnauthorizedError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
196
+ case 402: throw new Speechall.PaymentRequiredError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
197
+ case 404: throw new Speechall.NotFoundError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
198
+ case 429: throw new Speechall.TooManyRequestsError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
199
+ case 500: throw new Speechall.InternalServerError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
200
+ case 503: throw new Speechall.ServiceUnavailableError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
201
+ case 504: throw new Speechall.GatewayTimeoutError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
202
+ default: throw new errors.SpeechallError({
203
+ statusCode: _response.error.statusCode,
204
+ body: _response.error.body,
205
+ rawResponse: _response.rawResponse
206
+ });
207
+ }
208
+ }
209
+
210
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/transcribe-remote");
211
+ }
212
+
213
+ /**
214
+ * Returns a detailed list of all STT models accessible through the Speechall API.
215
+ * Each model entry includes its identifier (`provider.model`), display name, description,
216
+ * supported features (languages, formats, punctuation, diarization), and performance characteristics.
217
+ * Use this endpoint to discover available models and their capabilities before making transcription requests.
218
+ *
219
+ * @param {SpeechToTextClient.RequestOptions} requestOptions - Request-specific configuration.
220
+ *
221
+ * @throws {@link Speechall.BadRequestError}
222
+ * @throws {@link Speechall.UnauthorizedError}
223
+ * @throws {@link Speechall.PaymentRequiredError}
224
+ * @throws {@link Speechall.NotFoundError}
225
+ * @throws {@link Speechall.TooManyRequestsError}
226
+ * @throws {@link Speechall.InternalServerError}
227
+ * @throws {@link Speechall.ServiceUnavailableError}
228
+ * @throws {@link Speechall.GatewayTimeoutError}
229
+ *
230
+ * @example
231
+ * await client.speechToText.listSpeechToTextModels()
232
+ */
233
+ public listSpeechToTextModels(requestOptions?: SpeechToTextClient.RequestOptions): core.HttpResponsePromise<Speechall.SpeechToTextModel[]> {
234
+ return core.HttpResponsePromise.fromPromise(this.__listSpeechToTextModels(requestOptions));
235
+ }
236
+
237
+ private async __listSpeechToTextModels(requestOptions?: SpeechToTextClient.RequestOptions): Promise<core.WithRawResponse<Speechall.SpeechToTextModel[]>> {
238
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
239
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
240
+ const _response = await core.fetcher({
241
+ url: core.url.join(await core.Supplier.get(this._options.baseUrl) ?? (await core.Supplier.get(this._options.environment) ?? environments.SpeechallEnvironment.Default), "speech-to-text-models"),
242
+ method: "GET",
243
+ headers: _headers,
244
+ queryParameters: requestOptions?.queryParams,
245
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
246
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
247
+ abortSignal: requestOptions?.abortSignal,
248
+ fetchFn: this._options?.fetch,
249
+ logging: this._options.logging
250
+ });
251
+ if (_response.ok) {
252
+ return { data: _response.body as Speechall.SpeechToTextModel[], rawResponse: _response.rawResponse };
253
+ }
254
+
255
+ if (_response.error.reason === "status-code") {
256
+ switch (_response.error.statusCode) {
257
+ case 400: throw new Speechall.BadRequestError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
258
+ case 401: throw new Speechall.UnauthorizedError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
259
+ case 402: throw new Speechall.PaymentRequiredError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
260
+ case 404: throw new Speechall.NotFoundError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
261
+ case 429: throw new Speechall.TooManyRequestsError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
262
+ case 500: throw new Speechall.InternalServerError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
263
+ case 503: throw new Speechall.ServiceUnavailableError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
264
+ case 504: throw new Speechall.GatewayTimeoutError(_response.error.body as Speechall.ErrorResponse, _response.rawResponse);
265
+ default: throw new errors.SpeechallError({
266
+ statusCode: _response.error.statusCode,
267
+ body: _response.error.body,
268
+ rawResponse: _response.rawResponse
269
+ });
270
+ }
271
+ }
272
+
273
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/speech-to-text-models");
274
+ }
275
+ }
@@ -0,0 +1 @@
1
+ export * from "./requests/index.js";
@@ -0,0 +1,20 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+
3
+ import type * as Speechall from "../../../../index.js";
4
+
5
+ /**
6
+ * @example
7
+ * {
8
+ * model: "openai.whisper-1",
9
+ * language: "en",
10
+ * output_format: "json",
11
+ * diarization: true,
12
+ * file_url: "https://example.com/path/to/audio.mp3"
13
+ * }
14
+ */
15
+ export interface RemoteTranscriptionConfiguration extends Speechall.BaseTranscriptionConfiguration {
16
+ /** The publicly accessible URL of the audio file to transcribe. The API server must be able to fetch the audio from this URL. */
17
+ file_url: string;
18
+ /** An array of replacement rules to be applied directly to this transcription request, in order. This allows defining rules inline instead of (or in addition to) using a pre-saved `ruleset_id`. */
19
+ replacement_ruleset?: Speechall.ReplacementRule[];
20
+ }
@@ -0,0 +1,26 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+
3
+ import type * as Speechall from "../../../../index.js";
4
+
5
+ export interface TranscribeRequest {
6
+ /** The identifier of the speech-to-text model to use for the transcription, in the format `provider.model`. See the `/speech-to-text-models` endpoint for available models. */
7
+ model: Speechall.TranscriptionModelIdentifier;
8
+ /** The language of the audio file in ISO 639-1 format (e.g., `en`, `es`, `fr`). Specify `auto` for automatic language detection (if supported by the model). Defaults to `en` if not provided. Providing the correct language improves accuracy and latency. */
9
+ language?: Speechall.TranscriptLanguageCode;
10
+ /** The desired format for the transcription output. Can be plain text, JSON objects (simple or detailed), or subtitle formats (SRT, VTT). Defaults to `text`. */
11
+ output_format?: Speechall.TranscriptOutputFormat;
12
+ /** The unique identifier (UUID) of a pre-defined replacement ruleset to apply to the final transcription text. Create rulesets using the `/replacement-rulesets` endpoint. */
13
+ ruleset_id?: string;
14
+ /** Enable automatic punctuation (commas, periods, question marks) in the transcription. Support varies by model/provider (e.g., Deepgram, AssemblyAI). Defaults to `true`. */
15
+ punctuation?: boolean;
16
+ /** Enable speaker diarization to identify and label different speakers in the audio. Support and quality vary by model/provider. Defaults to `false`. When enabled, the `speaker` field may be populated in the response segments. */
17
+ diarization?: boolean;
18
+ /** An optional text prompt to provide context, guide the model's style (e.g., spelling of specific names), or improve accuracy for subsequent audio segments. Support varies by model (e.g., OpenAI models). */
19
+ initial_prompt?: string;
20
+ /** Controls the randomness of the output for certain models (e.g., OpenAI). A value between 0 and 1. Lower values (e.g., 0.2) make the output more deterministic, while higher values (e.g., 0.8) make it more random. Defaults vary by model. */
21
+ temperature?: number;
22
+ /** Provides a hint to the diarization process about the number of expected speakers. May improve accuracy for some providers (e.g., RevAI, Deepgram). */
23
+ speakers_expected?: number;
24
+ /** Provide a list of specific words or phrases (e.g., proper nouns, jargon) to increase their recognition likelihood. Support varies by provider (e.g., Deepgram, AssemblyAI). */
25
+ custom_vocabulary?: string | string[];
26
+ }
@@ -0,0 +1,2 @@
1
+ export type { RemoteTranscriptionConfiguration } from "./RemoteTranscriptionConfiguration.js";
2
+ export type { TranscribeRequest } from "./TranscribeRequest.js";
@@ -0,0 +1 @@
1
+ export * from "./client/index.js";
@@ -0,0 +1,29 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+
3
+ import type * as Speechall from "../index.js";
4
+
5
+ /**
6
+ * Common configuration options for transcription, applicable to both direct uploads and remote URLs.
7
+ */
8
+ export interface BaseTranscriptionConfiguration {
9
+ /** The identifier of the speech-to-text model to use. */
10
+ model: Speechall.TranscriptionModelIdentifier;
11
+ /** The language code (ISO 639-1) of the audio. Defaults to `en`. Use `auto` for automatic detection if supported. */
12
+ language?: Speechall.TranscriptLanguageCode;
13
+ /** The desired format for the transcription output. Defaults to `text`. */
14
+ output_format?: Speechall.TranscriptOutputFormat;
15
+ /** The unique identifier (UUID) of a pre-defined replacement ruleset to apply to the final transcription text. */
16
+ ruleset_id?: string;
17
+ /** Whether to add punctuation. Support varies by model (e.g., Deepgram, AssemblyAI). Defaults to `true`. */
18
+ punctuation?: boolean;
19
+ /** Enable speaker diarization. Defaults to `false`. */
20
+ diarization?: boolean;
21
+ /** Optional text prompt to guide the transcription model. Support varies (e.g., OpenAI). */
22
+ initial_prompt?: string;
23
+ /** Controls output randomness for supported models (e.g., OpenAI). Value between 0 and 1. */
24
+ temperature?: number;
25
+ /** Hint for the number of expected speakers for diarization (e.g., RevAI, Deepgram). */
26
+ speakers_expected?: number;
27
+ /** List of custom words/phrases to improve recognition (e.g., Deepgram, AssemblyAI). */
28
+ custom_vocabulary?: string[];
29
+ }
@@ -0,0 +1,11 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+
3
+ /**
4
+ * Standard structure for error responses. May include additional properties depending on the error type.
5
+ */
6
+ export interface ErrorResponse {
7
+ /** A human-readable message describing the error. */
8
+ message: string;
9
+ /** Accepts any additional properties */
10
+ [key: string]: any;
11
+ }
@@ -0,0 +1,13 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+
3
+ /**
4
+ * Defines a replacement rule based on finding an exact string match.
5
+ */
6
+ export interface ExactRule {
7
+ /** The exact text string to search for within the transcription. */
8
+ search: string;
9
+ /** The text string to replace the found 'search' text with. */
10
+ replacement: string;
11
+ /** If true, the search will match only if the case is identical. If false (default), the search ignores case. */
12
+ caseSensitive?: boolean;
13
+ }
@@ -0,0 +1,28 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+
3
+ /**
4
+ * Defines a replacement rule that uses regex capture groups to apply different replacements to different parts of the matched text.
5
+ */
6
+ export interface RegexGroupRule {
7
+ /** The regular expression pattern containing capture groups `(...)`. The entire pattern must match for replacements to occur. */
8
+ pattern: string;
9
+ /** An object where keys are capture group numbers (as strings, e.g., "1", "2") and values are the respective replacement strings for those groups. Groups not listed are kept as matched. The entire match is reconstructed using these replacements. */
10
+ groupReplacements: Record<string, string>;
11
+ /** An array of flags to modify the regex behavior. */
12
+ flags?: RegexGroupRule.Flags.Item[];
13
+ }
14
+
15
+ export namespace RegexGroupRule {
16
+ export type Flags = Flags.Item[];
17
+
18
+ export namespace Flags {
19
+ export const Item = {
20
+ I: "i",
21
+ M: "m",
22
+ S: "s",
23
+ X: "x",
24
+ U: "u",
25
+ } as const;
26
+ export type Item = (typeof Item)[keyof typeof Item];
27
+ }
28
+ }
@@ -0,0 +1,28 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+
3
+ /**
4
+ * Defines a replacement rule based on matching a regular expression pattern.
5
+ */
6
+ export interface RegexRule {
7
+ /** The regular expression pattern to search for. Uses standard regex syntax (implementation specific, often PCRE-like). Remember to escape special characters if needed (e.g., `\\.` for a literal dot). */
8
+ pattern: string;
9
+ /** The replacement text. Can include backreferences to capture groups from the pattern, like `$1`, `$2`, etc. A literal `$` should be escaped (e.g., `$$`). */
10
+ replacement: string;
11
+ /** An array of flags to modify the regex behavior (e.g., 'i' for case-insensitivity). */
12
+ flags?: RegexRule.Flags.Item[];
13
+ }
14
+
15
+ export namespace RegexRule {
16
+ export type Flags = Flags.Item[];
17
+
18
+ export namespace Flags {
19
+ export const Item = {
20
+ I: "i",
21
+ M: "m",
22
+ S: "s",
23
+ X: "x",
24
+ U: "u",
25
+ } as const;
26
+ export type Item = (typeof Item)[keyof typeof Item];
27
+ }
28
+ }