sarvamai 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Client.d.ts +5 -5
- package/Client.js +3 -3
- package/README.md +8 -8
- package/api/errors/BadRequestError.d.ts +1 -1
- package/api/errors/BadRequestError.js +1 -1
- package/api/errors/ForbiddenError.d.ts +3 -3
- package/api/errors/ForbiddenError.js +1 -1
- package/api/errors/InternalServerError.d.ts +1 -1
- package/api/errors/InternalServerError.js +1 -1
- package/api/errors/ServiceUnavailableError.d.ts +3 -3
- package/api/errors/ServiceUnavailableError.js +1 -1
- package/api/errors/TooManyRequestsError.d.ts +3 -3
- package/api/errors/TooManyRequestsError.js +1 -1
- package/api/errors/UnprocessableEntityError.d.ts +1 -1
- package/api/errors/UnprocessableEntityError.js +1 -1
- package/api/resources/analytics/client/Client.d.ts +18 -18
- package/api/resources/analytics/client/Client.js +39 -39
- package/api/resources/analytics/client/requests/CallAnalyticsRequest.d.ts +2 -2
- package/api/resources/pdf/client/Client.d.ts +12 -12
- package/api/resources/pdf/client/Client.js +27 -27
- package/api/resources/pdf/client/requests/ParsePdfRequest.d.ts +3 -3
- package/api/resources/pdf/client/requests/TranslatePdfRequest.d.ts +2 -2
- package/api/resources/speechToText/client/Client.d.ts +18 -18
- package/api/resources/speechToText/client/Client.js +39 -39
- package/api/resources/speechToText/client/requests/SpeechToTextTranscriptionRequest.d.ts +3 -3
- package/api/resources/speechToText/client/requests/SpeechToTextTranslationRequest.d.ts +2 -2
- package/api/resources/text/client/Client.d.ts +23 -23
- package/api/resources/text/client/Client.js +52 -52
- package/api/resources/text/client/requests/TranslationRequest.d.ts +8 -8
- package/api/resources/text/client/requests/TransliterationRequest.d.ts +5 -5
- package/api/resources/textToSpeech/client/Client.d.ts +9 -9
- package/api/resources/textToSpeech/client/Client.js +18 -18
- package/api/resources/textToSpeech/client/requests/TextToSpeechRequest.d.ts +5 -5
- package/api/types/CallAnalyticsJobParameters.d.ts +3 -3
- package/api/types/CallAnalyticsJobRequest.d.ts +2 -2
- package/api/types/CallAnalyticsResponse.d.ts +4 -4
- package/api/types/DiarizedTranscript.d.ts +2 -2
- package/api/types/ErrorDetails.d.ts +2 -2
- package/api/types/ErrorMessage.d.ts +2 -2
- package/api/types/Question.d.ts +2 -2
- package/api/types/SpeechToTextResponse.d.ts +3 -3
- package/api/types/SpeechToTextTranslateResponse.d.ts +3 -3
- package/api/types/TextAnalyticsResponse.d.ts +2 -2
- package/dist/Client.d.ts +5 -5
- package/dist/Client.js +3 -3
- package/dist/api/errors/BadRequestError.d.ts +1 -1
- package/dist/api/errors/BadRequestError.js +1 -1
- package/dist/api/errors/ForbiddenError.d.ts +3 -3
- package/dist/api/errors/ForbiddenError.js +1 -1
- package/dist/api/errors/InternalServerError.d.ts +1 -1
- package/dist/api/errors/InternalServerError.js +1 -1
- package/dist/api/errors/ServiceUnavailableError.d.ts +3 -3
- package/dist/api/errors/ServiceUnavailableError.js +1 -1
- package/dist/api/errors/TooManyRequestsError.d.ts +3 -3
- package/dist/api/errors/TooManyRequestsError.js +1 -1
- package/dist/api/errors/UnprocessableEntityError.d.ts +1 -1
- package/dist/api/errors/UnprocessableEntityError.js +1 -1
- package/dist/api/resources/analytics/client/Client.d.ts +18 -18
- package/dist/api/resources/analytics/client/Client.js +39 -39
- package/dist/api/resources/analytics/client/requests/CallAnalyticsRequest.d.ts +2 -2
- package/dist/api/resources/pdf/client/Client.d.ts +12 -12
- package/dist/api/resources/pdf/client/Client.js +27 -27
- package/dist/api/resources/pdf/client/requests/ParsePdfRequest.d.ts +3 -3
- package/dist/api/resources/pdf/client/requests/TranslatePdfRequest.d.ts +2 -2
- package/dist/api/resources/speechToText/client/Client.d.ts +18 -18
- package/dist/api/resources/speechToText/client/Client.js +39 -39
- package/dist/api/resources/speechToText/client/requests/SpeechToTextTranscriptionRequest.d.ts +3 -3
- package/dist/api/resources/speechToText/client/requests/SpeechToTextTranslationRequest.d.ts +2 -2
- package/dist/api/resources/text/client/Client.d.ts +23 -23
- package/dist/api/resources/text/client/Client.js +52 -52
- package/dist/api/resources/text/client/requests/TranslationRequest.d.ts +8 -8
- package/dist/api/resources/text/client/requests/TransliterationRequest.d.ts +5 -5
- package/dist/api/resources/textToSpeech/client/Client.d.ts +9 -9
- package/dist/api/resources/textToSpeech/client/Client.js +18 -18
- package/dist/api/resources/textToSpeech/client/requests/TextToSpeechRequest.d.ts +5 -5
- package/dist/api/types/CallAnalyticsJobParameters.d.ts +3 -3
- package/dist/api/types/CallAnalyticsJobRequest.d.ts +2 -2
- package/dist/api/types/CallAnalyticsResponse.d.ts +4 -4
- package/dist/api/types/DiarizedTranscript.d.ts +2 -2
- package/dist/api/types/ErrorDetails.d.ts +2 -2
- package/dist/api/types/ErrorMessage.d.ts +2 -2
- package/dist/api/types/Question.d.ts +2 -2
- package/dist/api/types/SpeechToTextResponse.d.ts +3 -3
- package/dist/api/types/SpeechToTextTranslateResponse.d.ts +3 -3
- package/dist/api/types/TextAnalyticsResponse.d.ts +2 -2
- package/dist/environments.d.ts +2 -2
- package/dist/environments.js +2 -2
- package/dist/errors/{SarvamError.d.ts → SarvamAIError.d.ts} +1 -1
- package/{errors/SarvamError.js → dist/errors/SarvamAIError.js} +4 -4
- package/dist/errors/{SarvamTimeoutError.d.ts → SarvamAITimeoutError.d.ts} +1 -1
- package/{errors/SarvamTimeoutError.js → dist/errors/SarvamAITimeoutError.js} +4 -4
- package/dist/errors/index.d.ts +2 -2
- package/dist/errors/index.js +5 -5
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -6
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/environments.d.ts +2 -2
- package/environments.js +2 -2
- package/errors/{SarvamError.d.ts → SarvamAIError.d.ts} +1 -1
- package/{dist/errors/SarvamError.js → errors/SarvamAIError.js} +4 -4
- package/errors/{SarvamTimeoutError.d.ts → SarvamAITimeoutError.d.ts} +1 -1
- package/{dist/errors/SarvamTimeoutError.js → errors/SarvamAITimeoutError.js} +4 -4
- package/errors/index.d.ts +2 -2
- package/errors/index.js +5 -5
- package/index.d.ts +4 -4
- package/index.js +6 -6
- package/package.json +1 -1
- package/reference.md +20 -20
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -51,7 +51,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
51
51
|
exports.Pdf = void 0;
|
|
52
52
|
const environments = __importStar(require("../../../../environments"));
|
|
53
53
|
const core = __importStar(require("../../../../core"));
|
|
54
|
-
const
|
|
54
|
+
const SarvamAI = __importStar(require("../../../index"));
|
|
55
55
|
const url_join_1 = __importDefault(require("url-join"));
|
|
56
56
|
const errors = __importStar(require("../../../../errors/index"));
|
|
57
57
|
class Pdf {
|
|
@@ -62,12 +62,12 @@ class Pdf {
|
|
|
62
62
|
* Given a PDF, this API helps to get structured extraction of data in the document.The API returns a base64 encoded XML string containing the extracted data.
|
|
63
63
|
*
|
|
64
64
|
* @param {File | fs.ReadStream | Blob} pdf
|
|
65
|
-
* @param {
|
|
65
|
+
* @param {SarvamAI.ParsePdfRequest} request
|
|
66
66
|
* @param {Pdf.RequestOptions} requestOptions - Request-specific configuration.
|
|
67
67
|
*
|
|
68
|
-
* @throws {@link
|
|
69
|
-
* @throws {@link
|
|
70
|
-
* @throws {@link
|
|
68
|
+
* @throws {@link SarvamAI.BadRequestError}
|
|
69
|
+
* @throws {@link SarvamAI.UnprocessableEntityError}
|
|
70
|
+
* @throws {@link SarvamAI.InternalServerError}
|
|
71
71
|
*
|
|
72
72
|
* @example
|
|
73
73
|
* await client.pdf.parse(fs.createReadStream("/path/to/your/file"), {})
|
|
@@ -88,11 +88,11 @@ class Pdf {
|
|
|
88
88
|
}
|
|
89
89
|
const _maybeEncodedRequest = yield _request.getRequest();
|
|
90
90
|
const _response = yield core.fetcher({
|
|
91
|
-
url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.
|
|
91
|
+
url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.SarvamAIEnvironment.Production, "parse/parsepdf"),
|
|
92
92
|
method: "POST",
|
|
93
93
|
headers: Object.assign(Object.assign({ "api-subscription-key": (yield core.Supplier.get(this._options.apiSubscriptionKey)) != null
|
|
94
94
|
? yield core.Supplier.get(this._options.apiSubscriptionKey)
|
|
95
|
-
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.0.
|
|
95
|
+
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.0.3", "User-Agent": "sarvamai/0.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
96
96
|
requestType: "file",
|
|
97
97
|
duplex: _maybeEncodedRequest.duplex,
|
|
98
98
|
body: _maybeEncodedRequest.body,
|
|
@@ -106,13 +106,13 @@ class Pdf {
|
|
|
106
106
|
if (_response.error.reason === "status-code") {
|
|
107
107
|
switch (_response.error.statusCode) {
|
|
108
108
|
case 400:
|
|
109
|
-
throw new
|
|
109
|
+
throw new SarvamAI.BadRequestError(_response.error.body);
|
|
110
110
|
case 422:
|
|
111
|
-
throw new
|
|
111
|
+
throw new SarvamAI.UnprocessableEntityError(_response.error.body);
|
|
112
112
|
case 500:
|
|
113
|
-
throw new
|
|
113
|
+
throw new SarvamAI.InternalServerError(_response.error.body);
|
|
114
114
|
default:
|
|
115
|
-
throw new errors.
|
|
115
|
+
throw new errors.SarvamAIError({
|
|
116
116
|
statusCode: _response.error.statusCode,
|
|
117
117
|
body: _response.error.body,
|
|
118
118
|
});
|
|
@@ -120,14 +120,14 @@ class Pdf {
|
|
|
120
120
|
}
|
|
121
121
|
switch (_response.error.reason) {
|
|
122
122
|
case "non-json":
|
|
123
|
-
throw new errors.
|
|
123
|
+
throw new errors.SarvamAIError({
|
|
124
124
|
statusCode: _response.error.statusCode,
|
|
125
125
|
body: _response.error.rawBody,
|
|
126
126
|
});
|
|
127
127
|
case "timeout":
|
|
128
|
-
throw new errors.
|
|
128
|
+
throw new errors.SarvamAITimeoutError("Timeout exceeded when calling POST /parse/parsepdf.");
|
|
129
129
|
case "unknown":
|
|
130
|
-
throw new errors.
|
|
130
|
+
throw new errors.SarvamAIError({
|
|
131
131
|
message: _response.error.errorMessage,
|
|
132
132
|
});
|
|
133
133
|
}
|
|
@@ -137,12 +137,12 @@ class Pdf {
|
|
|
137
137
|
* Given a PDF, this API helps to translate the content in the document
|
|
138
138
|
*
|
|
139
139
|
* @param {File | fs.ReadStream | Blob} pdf
|
|
140
|
-
* @param {
|
|
140
|
+
* @param {SarvamAI.TranslatePdfRequest} request
|
|
141
141
|
* @param {Pdf.RequestOptions} requestOptions - Request-specific configuration.
|
|
142
142
|
*
|
|
143
|
-
* @throws {@link
|
|
144
|
-
* @throws {@link
|
|
145
|
-
* @throws {@link
|
|
143
|
+
* @throws {@link SarvamAI.BadRequestError}
|
|
144
|
+
* @throws {@link SarvamAI.UnprocessableEntityError}
|
|
145
|
+
* @throws {@link SarvamAI.InternalServerError}
|
|
146
146
|
*
|
|
147
147
|
* @example
|
|
148
148
|
* await client.pdf.translate(fs.createReadStream("/path/to/your/file"), {})
|
|
@@ -166,11 +166,11 @@ class Pdf {
|
|
|
166
166
|
}
|
|
167
167
|
const _maybeEncodedRequest = yield _request.getRequest();
|
|
168
168
|
const _response = yield core.fetcher({
|
|
169
|
-
url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.
|
|
169
|
+
url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.SarvamAIEnvironment.Production, "parse/translatepdf"),
|
|
170
170
|
method: "POST",
|
|
171
171
|
headers: Object.assign(Object.assign({ "api-subscription-key": (yield core.Supplier.get(this._options.apiSubscriptionKey)) != null
|
|
172
172
|
? yield core.Supplier.get(this._options.apiSubscriptionKey)
|
|
173
|
-
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.0.
|
|
173
|
+
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.0.3", "User-Agent": "sarvamai/0.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
174
174
|
requestType: "file",
|
|
175
175
|
duplex: _maybeEncodedRequest.duplex,
|
|
176
176
|
body: _maybeEncodedRequest.body,
|
|
@@ -184,13 +184,13 @@ class Pdf {
|
|
|
184
184
|
if (_response.error.reason === "status-code") {
|
|
185
185
|
switch (_response.error.statusCode) {
|
|
186
186
|
case 400:
|
|
187
|
-
throw new
|
|
187
|
+
throw new SarvamAI.BadRequestError(_response.error.body);
|
|
188
188
|
case 422:
|
|
189
|
-
throw new
|
|
189
|
+
throw new SarvamAI.UnprocessableEntityError(_response.error.body);
|
|
190
190
|
case 500:
|
|
191
|
-
throw new
|
|
191
|
+
throw new SarvamAI.InternalServerError(_response.error.body);
|
|
192
192
|
default:
|
|
193
|
-
throw new errors.
|
|
193
|
+
throw new errors.SarvamAIError({
|
|
194
194
|
statusCode: _response.error.statusCode,
|
|
195
195
|
body: _response.error.body,
|
|
196
196
|
});
|
|
@@ -198,14 +198,14 @@ class Pdf {
|
|
|
198
198
|
}
|
|
199
199
|
switch (_response.error.reason) {
|
|
200
200
|
case "non-json":
|
|
201
|
-
throw new errors.
|
|
201
|
+
throw new errors.SarvamAIError({
|
|
202
202
|
statusCode: _response.error.statusCode,
|
|
203
203
|
body: _response.error.rawBody,
|
|
204
204
|
});
|
|
205
205
|
case "timeout":
|
|
206
|
-
throw new errors.
|
|
206
|
+
throw new errors.SarvamAITimeoutError("Timeout exceeded when calling POST /parse/translatepdf.");
|
|
207
207
|
case "unknown":
|
|
208
|
-
throw new errors.
|
|
208
|
+
throw new errors.SarvamAIError({
|
|
209
209
|
message: _response.error.errorMessage,
|
|
210
210
|
});
|
|
211
211
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
3
|
*/
|
|
4
|
-
import * as
|
|
4
|
+
import * as SarvamAI from "../../../../index";
|
|
5
5
|
/**
|
|
6
6
|
* @example
|
|
7
7
|
* {}
|
|
@@ -15,7 +15,7 @@ export interface ParsePdfRequest {
|
|
|
15
15
|
* - small: Use this mode for economical and fast parsing
|
|
16
16
|
* - large: Use this mode for highest precision parsing
|
|
17
17
|
*/
|
|
18
|
-
sarvam_mode?:
|
|
18
|
+
sarvam_mode?: SarvamAI.SarvamMode;
|
|
19
19
|
/** Whether to cache the prompt for the parse request. This is useful when running multiple requests to the parsing endpoint. */
|
|
20
|
-
prompt_caching?:
|
|
20
|
+
prompt_caching?: SarvamAI.PromptCaching;
|
|
21
21
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
3
|
*/
|
|
4
|
-
import * as
|
|
4
|
+
import * as SarvamAI from "../../../../index";
|
|
5
5
|
/**
|
|
6
6
|
* @example
|
|
7
7
|
* {}
|
|
@@ -28,5 +28,5 @@ export interface TranslatePdfRequest {
|
|
|
28
28
|
* te = "te-IN"
|
|
29
29
|
* Example: "hi-IN" for Hindi
|
|
30
30
|
*/
|
|
31
|
-
output_lang?:
|
|
31
|
+
output_lang?: SarvamAI.Language;
|
|
32
32
|
}
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as environments from "../../../../environments";
|
|
5
5
|
import * as core from "../../../../core";
|
|
6
|
-
import * as
|
|
6
|
+
import * as SarvamAI from "../../../index";
|
|
7
7
|
import * as fs from "fs";
|
|
8
8
|
import { Blob } from "buffer";
|
|
9
9
|
export declare namespace SpeechToText {
|
|
10
10
|
interface Options {
|
|
11
|
-
environment?: core.Supplier<environments.
|
|
11
|
+
environment?: core.Supplier<environments.SarvamAIEnvironment | string>;
|
|
12
12
|
/** Specify a custom URL to connect the client to. */
|
|
13
13
|
baseUrl?: core.Supplier<string>;
|
|
14
14
|
/** Override the api-subscription-key header */
|
|
@@ -46,20 +46,20 @@ export declare class SpeechToText {
|
|
|
46
46
|
* - Please refer to [dashboard.sarvam.ai](https://dashboard.sarvam.ai) for detailed pricing information
|
|
47
47
|
*
|
|
48
48
|
* @param {File | fs.ReadStream | Blob} file
|
|
49
|
-
* @param {
|
|
49
|
+
* @param {SarvamAI.SpeechToTextTranscriptionRequest} request
|
|
50
50
|
* @param {SpeechToText.RequestOptions} requestOptions - Request-specific configuration.
|
|
51
51
|
*
|
|
52
|
-
* @throws {@link
|
|
53
|
-
* @throws {@link
|
|
54
|
-
* @throws {@link
|
|
55
|
-
* @throws {@link
|
|
56
|
-
* @throws {@link
|
|
57
|
-
* @throws {@link
|
|
52
|
+
* @throws {@link SarvamAI.BadRequestError}
|
|
53
|
+
* @throws {@link SarvamAI.ForbiddenError}
|
|
54
|
+
* @throws {@link SarvamAI.UnprocessableEntityError}
|
|
55
|
+
* @throws {@link SarvamAI.TooManyRequestsError}
|
|
56
|
+
* @throws {@link SarvamAI.InternalServerError}
|
|
57
|
+
* @throws {@link SarvamAI.ServiceUnavailableError}
|
|
58
58
|
*
|
|
59
59
|
* @example
|
|
60
60
|
* await client.speechToText.transcribe(fs.createReadStream("/path/to/your/file"), {})
|
|
61
61
|
*/
|
|
62
|
-
transcribe(file: File | fs.ReadStream | Blob, request:
|
|
62
|
+
transcribe(file: File | fs.ReadStream | Blob, request: SarvamAI.SpeechToTextTranscriptionRequest, requestOptions?: SpeechToText.RequestOptions): Promise<SarvamAI.SpeechToTextResponse>;
|
|
63
63
|
/**
|
|
64
64
|
* ## Real-Time Speech to Text Translation API
|
|
65
65
|
*
|
|
@@ -76,18 +76,18 @@ export declare class SpeechToText {
|
|
|
76
76
|
* - Please refer to [dashboard.sarvam.ai](https://dashboard.sarvam.ai) for detailed pricing information
|
|
77
77
|
*
|
|
78
78
|
* @param {File | fs.ReadStream | Blob} file
|
|
79
|
-
* @param {
|
|
79
|
+
* @param {SarvamAI.SpeechToTextTranslationRequest} request
|
|
80
80
|
* @param {SpeechToText.RequestOptions} requestOptions - Request-specific configuration.
|
|
81
81
|
*
|
|
82
|
-
* @throws {@link
|
|
83
|
-
* @throws {@link
|
|
84
|
-
* @throws {@link
|
|
85
|
-
* @throws {@link
|
|
86
|
-
* @throws {@link
|
|
87
|
-
* @throws {@link
|
|
82
|
+
* @throws {@link SarvamAI.BadRequestError}
|
|
83
|
+
* @throws {@link SarvamAI.ForbiddenError}
|
|
84
|
+
* @throws {@link SarvamAI.UnprocessableEntityError}
|
|
85
|
+
* @throws {@link SarvamAI.TooManyRequestsError}
|
|
86
|
+
* @throws {@link SarvamAI.InternalServerError}
|
|
87
|
+
* @throws {@link SarvamAI.ServiceUnavailableError}
|
|
88
88
|
*
|
|
89
89
|
* @example
|
|
90
90
|
* await client.speechToText.translate(fs.createReadStream("/path/to/your/file"), {})
|
|
91
91
|
*/
|
|
92
|
-
translate(file: File | fs.ReadStream | Blob, request:
|
|
92
|
+
translate(file: File | fs.ReadStream | Blob, request: SarvamAI.SpeechToTextTranslationRequest, requestOptions?: SpeechToText.RequestOptions): Promise<SarvamAI.SpeechToTextTranslateResponse>;
|
|
93
93
|
}
|
|
@@ -51,7 +51,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
51
51
|
exports.SpeechToText = void 0;
|
|
52
52
|
const environments = __importStar(require("../../../../environments"));
|
|
53
53
|
const core = __importStar(require("../../../../core"));
|
|
54
|
-
const
|
|
54
|
+
const SarvamAI = __importStar(require("../../../index"));
|
|
55
55
|
const url_join_1 = __importDefault(require("url-join"));
|
|
56
56
|
const errors = __importStar(require("../../../../errors/index"));
|
|
57
57
|
class SpeechToText {
|
|
@@ -74,15 +74,15 @@ class SpeechToText {
|
|
|
74
74
|
* - Please refer to [dashboard.sarvam.ai](https://dashboard.sarvam.ai) for detailed pricing information
|
|
75
75
|
*
|
|
76
76
|
* @param {File | fs.ReadStream | Blob} file
|
|
77
|
-
* @param {
|
|
77
|
+
* @param {SarvamAI.SpeechToTextTranscriptionRequest} request
|
|
78
78
|
* @param {SpeechToText.RequestOptions} requestOptions - Request-specific configuration.
|
|
79
79
|
*
|
|
80
|
-
* @throws {@link
|
|
81
|
-
* @throws {@link
|
|
82
|
-
* @throws {@link
|
|
83
|
-
* @throws {@link
|
|
84
|
-
* @throws {@link
|
|
85
|
-
* @throws {@link
|
|
80
|
+
* @throws {@link SarvamAI.BadRequestError}
|
|
81
|
+
* @throws {@link SarvamAI.ForbiddenError}
|
|
82
|
+
* @throws {@link SarvamAI.UnprocessableEntityError}
|
|
83
|
+
* @throws {@link SarvamAI.TooManyRequestsError}
|
|
84
|
+
* @throws {@link SarvamAI.InternalServerError}
|
|
85
|
+
* @throws {@link SarvamAI.ServiceUnavailableError}
|
|
86
86
|
*
|
|
87
87
|
* @example
|
|
88
88
|
* await client.speechToText.transcribe(fs.createReadStream("/path/to/your/file"), {})
|
|
@@ -109,11 +109,11 @@ class SpeechToText {
|
|
|
109
109
|
}
|
|
110
110
|
const _maybeEncodedRequest = yield _request.getRequest();
|
|
111
111
|
const _response = yield core.fetcher({
|
|
112
|
-
url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.
|
|
112
|
+
url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.SarvamAIEnvironment.Production, "speech-to-text"),
|
|
113
113
|
method: "POST",
|
|
114
114
|
headers: Object.assign(Object.assign({ "api-subscription-key": (yield core.Supplier.get(this._options.apiSubscriptionKey)) != null
|
|
115
115
|
? yield core.Supplier.get(this._options.apiSubscriptionKey)
|
|
116
|
-
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.0.
|
|
116
|
+
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.0.3", "User-Agent": "sarvamai/0.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
117
117
|
requestType: "file",
|
|
118
118
|
duplex: _maybeEncodedRequest.duplex,
|
|
119
119
|
body: _maybeEncodedRequest.body,
|
|
@@ -127,19 +127,19 @@ class SpeechToText {
|
|
|
127
127
|
if (_response.error.reason === "status-code") {
|
|
128
128
|
switch (_response.error.statusCode) {
|
|
129
129
|
case 400:
|
|
130
|
-
throw new
|
|
130
|
+
throw new SarvamAI.BadRequestError(_response.error.body);
|
|
131
131
|
case 403:
|
|
132
|
-
throw new
|
|
132
|
+
throw new SarvamAI.ForbiddenError(_response.error.body);
|
|
133
133
|
case 422:
|
|
134
|
-
throw new
|
|
134
|
+
throw new SarvamAI.UnprocessableEntityError(_response.error.body);
|
|
135
135
|
case 429:
|
|
136
|
-
throw new
|
|
136
|
+
throw new SarvamAI.TooManyRequestsError(_response.error.body);
|
|
137
137
|
case 500:
|
|
138
|
-
throw new
|
|
138
|
+
throw new SarvamAI.InternalServerError(_response.error.body);
|
|
139
139
|
case 503:
|
|
140
|
-
throw new
|
|
140
|
+
throw new SarvamAI.ServiceUnavailableError(_response.error.body);
|
|
141
141
|
default:
|
|
142
|
-
throw new errors.
|
|
142
|
+
throw new errors.SarvamAIError({
|
|
143
143
|
statusCode: _response.error.statusCode,
|
|
144
144
|
body: _response.error.body,
|
|
145
145
|
});
|
|
@@ -147,14 +147,14 @@ class SpeechToText {
|
|
|
147
147
|
}
|
|
148
148
|
switch (_response.error.reason) {
|
|
149
149
|
case "non-json":
|
|
150
|
-
throw new errors.
|
|
150
|
+
throw new errors.SarvamAIError({
|
|
151
151
|
statusCode: _response.error.statusCode,
|
|
152
152
|
body: _response.error.rawBody,
|
|
153
153
|
});
|
|
154
154
|
case "timeout":
|
|
155
|
-
throw new errors.
|
|
155
|
+
throw new errors.SarvamAITimeoutError("Timeout exceeded when calling POST /speech-to-text.");
|
|
156
156
|
case "unknown":
|
|
157
|
-
throw new errors.
|
|
157
|
+
throw new errors.SarvamAIError({
|
|
158
158
|
message: _response.error.errorMessage,
|
|
159
159
|
});
|
|
160
160
|
}
|
|
@@ -176,15 +176,15 @@ class SpeechToText {
|
|
|
176
176
|
* - Please refer to [dashboard.sarvam.ai](https://dashboard.sarvam.ai) for detailed pricing information
|
|
177
177
|
*
|
|
178
178
|
* @param {File | fs.ReadStream | Blob} file
|
|
179
|
-
* @param {
|
|
179
|
+
* @param {SarvamAI.SpeechToTextTranslationRequest} request
|
|
180
180
|
* @param {SpeechToText.RequestOptions} requestOptions - Request-specific configuration.
|
|
181
181
|
*
|
|
182
|
-
* @throws {@link
|
|
183
|
-
* @throws {@link
|
|
184
|
-
* @throws {@link
|
|
185
|
-
* @throws {@link
|
|
186
|
-
* @throws {@link
|
|
187
|
-
* @throws {@link
|
|
182
|
+
* @throws {@link SarvamAI.BadRequestError}
|
|
183
|
+
* @throws {@link SarvamAI.ForbiddenError}
|
|
184
|
+
* @throws {@link SarvamAI.UnprocessableEntityError}
|
|
185
|
+
* @throws {@link SarvamAI.TooManyRequestsError}
|
|
186
|
+
* @throws {@link SarvamAI.InternalServerError}
|
|
187
|
+
* @throws {@link SarvamAI.ServiceUnavailableError}
|
|
188
188
|
*
|
|
189
189
|
* @example
|
|
190
190
|
* await client.speechToText.translate(fs.createReadStream("/path/to/your/file"), {})
|
|
@@ -208,11 +208,11 @@ class SpeechToText {
|
|
|
208
208
|
}
|
|
209
209
|
const _maybeEncodedRequest = yield _request.getRequest();
|
|
210
210
|
const _response = yield core.fetcher({
|
|
211
|
-
url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.
|
|
211
|
+
url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.SarvamAIEnvironment.Production, "speech-to-text-translate"),
|
|
212
212
|
method: "POST",
|
|
213
213
|
headers: Object.assign(Object.assign({ "api-subscription-key": (yield core.Supplier.get(this._options.apiSubscriptionKey)) != null
|
|
214
214
|
? yield core.Supplier.get(this._options.apiSubscriptionKey)
|
|
215
|
-
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.0.
|
|
215
|
+
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.0.3", "User-Agent": "sarvamai/0.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
216
216
|
requestType: "file",
|
|
217
217
|
duplex: _maybeEncodedRequest.duplex,
|
|
218
218
|
body: _maybeEncodedRequest.body,
|
|
@@ -226,19 +226,19 @@ class SpeechToText {
|
|
|
226
226
|
if (_response.error.reason === "status-code") {
|
|
227
227
|
switch (_response.error.statusCode) {
|
|
228
228
|
case 400:
|
|
229
|
-
throw new
|
|
229
|
+
throw new SarvamAI.BadRequestError(_response.error.body);
|
|
230
230
|
case 403:
|
|
231
|
-
throw new
|
|
231
|
+
throw new SarvamAI.ForbiddenError(_response.error.body);
|
|
232
232
|
case 422:
|
|
233
|
-
throw new
|
|
233
|
+
throw new SarvamAI.UnprocessableEntityError(_response.error.body);
|
|
234
234
|
case 429:
|
|
235
|
-
throw new
|
|
235
|
+
throw new SarvamAI.TooManyRequestsError(_response.error.body);
|
|
236
236
|
case 500:
|
|
237
|
-
throw new
|
|
237
|
+
throw new SarvamAI.InternalServerError(_response.error.body);
|
|
238
238
|
case 503:
|
|
239
|
-
throw new
|
|
239
|
+
throw new SarvamAI.ServiceUnavailableError(_response.error.body);
|
|
240
240
|
default:
|
|
241
|
-
throw new errors.
|
|
241
|
+
throw new errors.SarvamAIError({
|
|
242
242
|
statusCode: _response.error.statusCode,
|
|
243
243
|
body: _response.error.body,
|
|
244
244
|
});
|
|
@@ -246,14 +246,14 @@ class SpeechToText {
|
|
|
246
246
|
}
|
|
247
247
|
switch (_response.error.reason) {
|
|
248
248
|
case "non-json":
|
|
249
|
-
throw new errors.
|
|
249
|
+
throw new errors.SarvamAIError({
|
|
250
250
|
statusCode: _response.error.statusCode,
|
|
251
251
|
body: _response.error.rawBody,
|
|
252
252
|
});
|
|
253
253
|
case "timeout":
|
|
254
|
-
throw new errors.
|
|
254
|
+
throw new errors.SarvamAITimeoutError("Timeout exceeded when calling POST /speech-to-text-translate.");
|
|
255
255
|
case "unknown":
|
|
256
|
-
throw new errors.
|
|
256
|
+
throw new errors.SarvamAIError({
|
|
257
257
|
message: _response.error.errorMessage,
|
|
258
258
|
});
|
|
259
259
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
3
|
*/
|
|
4
|
-
import * as
|
|
4
|
+
import * as SarvamAI from "../../../../index";
|
|
5
5
|
/**
|
|
6
6
|
* @example
|
|
7
7
|
* {}
|
|
@@ -11,7 +11,7 @@ export interface SpeechToTextTranscriptionRequest {
|
|
|
11
11
|
* Specifies the model to use for speech-to-text conversion.
|
|
12
12
|
* Note:- Default model is `saarika:v2`
|
|
13
13
|
*/
|
|
14
|
-
model?:
|
|
14
|
+
model?: SarvamAI.SpeechToTextModel;
|
|
15
15
|
/**
|
|
16
16
|
* Specifies the language of the input audio. This parameter is required to ensure accurate transcription.
|
|
17
17
|
* For the `saarika:v1` model, this parameter is mandatory.
|
|
@@ -19,7 +19,7 @@ export interface SpeechToTextTranscriptionRequest {
|
|
|
19
19
|
* `unknown`: Use this when the language is not known; the API will detect it automatically.
|
|
20
20
|
* Note:- that the `saarika:v1` model does not support `unknown` language code.
|
|
21
21
|
*/
|
|
22
|
-
language_code?:
|
|
22
|
+
language_code?: SarvamAI.SpeechToTextLanguage;
|
|
23
23
|
/** Enables timestamps in the response. If set to `true`, the response will include timestamps in the transcript. */
|
|
24
24
|
with_timestamps?: boolean;
|
|
25
25
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
3
|
*/
|
|
4
|
-
import * as
|
|
4
|
+
import * as SarvamAI from "../../../../index";
|
|
5
5
|
/**
|
|
6
6
|
* @example
|
|
7
7
|
* {}
|
|
@@ -10,7 +10,7 @@ export interface SpeechToTextTranslationRequest {
|
|
|
10
10
|
/** Conversation context can be passed as a prompt to boost model accuracy. However, the current system is at an experimentation stage and doesn’t match the prompt performance of large language models. */
|
|
11
11
|
prompt?: string;
|
|
12
12
|
/** Model to be used for converting speech to text in target language */
|
|
13
|
-
model?:
|
|
13
|
+
model?: SarvamAI.SpeechToTextTranslateModel;
|
|
14
14
|
/**
|
|
15
15
|
* Enables speaker diarization, which identifies and separates different speakers in the audio.
|
|
16
16
|
* When set to true, the API will provide speaker-specific segments in the response.
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as environments from "../../../../environments";
|
|
5
5
|
import * as core from "../../../../core";
|
|
6
|
-
import * as
|
|
6
|
+
import * as SarvamAI from "../../../index";
|
|
7
7
|
export declare namespace Text {
|
|
8
8
|
interface Options {
|
|
9
|
-
environment?: core.Supplier<environments.
|
|
9
|
+
environment?: core.Supplier<environments.SarvamAIEnvironment | string>;
|
|
10
10
|
/** Specify a custom URL to connect the client to. */
|
|
11
11
|
baseUrl?: core.Supplier<string>;
|
|
12
12
|
/** Override the api-subscription-key header */
|
|
@@ -47,14 +47,14 @@ export declare class Text {
|
|
|
47
47
|
*
|
|
48
48
|
* For hands-on practice, you can explore the notebook tutorial on [Translate API Tutorial](https://github.com/sarvamai/sarvam-ai-cookbook/blob/main/notebooks/translate/Translate_API_Tutorial.ipynb).
|
|
49
49
|
*
|
|
50
|
-
* @param {
|
|
50
|
+
* @param {SarvamAI.TranslationRequest} request
|
|
51
51
|
* @param {Text.RequestOptions} requestOptions - Request-specific configuration.
|
|
52
52
|
*
|
|
53
|
-
* @throws {@link
|
|
54
|
-
* @throws {@link
|
|
55
|
-
* @throws {@link
|
|
56
|
-
* @throws {@link
|
|
57
|
-
* @throws {@link
|
|
53
|
+
* @throws {@link SarvamAI.BadRequestError}
|
|
54
|
+
* @throws {@link SarvamAI.ForbiddenError}
|
|
55
|
+
* @throws {@link SarvamAI.UnprocessableEntityError}
|
|
56
|
+
* @throws {@link SarvamAI.TooManyRequestsError}
|
|
57
|
+
* @throws {@link SarvamAI.InternalServerError}
|
|
58
58
|
*
|
|
59
59
|
* @example
|
|
60
60
|
* await client.text.translate({
|
|
@@ -63,25 +63,25 @@ export declare class Text {
|
|
|
63
63
|
* target_language_code: "en-IN"
|
|
64
64
|
* })
|
|
65
65
|
*/
|
|
66
|
-
translate(request:
|
|
66
|
+
translate(request: SarvamAI.TranslationRequest, requestOptions?: Text.RequestOptions): Promise<SarvamAI.TranslationResponse>;
|
|
67
67
|
/**
|
|
68
68
|
* Identifies the language (e.g., en-IN, hi-IN) and script (e.g., Latin, Devanagari) of the input text, supporting multiple languages.
|
|
69
69
|
*
|
|
70
|
-
* @param {
|
|
70
|
+
* @param {SarvamAI.LanguageIdentificationRequest} request
|
|
71
71
|
* @param {Text.RequestOptions} requestOptions - Request-specific configuration.
|
|
72
72
|
*
|
|
73
|
-
* @throws {@link
|
|
74
|
-
* @throws {@link
|
|
75
|
-
* @throws {@link
|
|
76
|
-
* @throws {@link
|
|
77
|
-
* @throws {@link
|
|
73
|
+
* @throws {@link SarvamAI.BadRequestError}
|
|
74
|
+
* @throws {@link SarvamAI.ForbiddenError}
|
|
75
|
+
* @throws {@link SarvamAI.UnprocessableEntityError}
|
|
76
|
+
* @throws {@link SarvamAI.TooManyRequestsError}
|
|
77
|
+
* @throws {@link SarvamAI.InternalServerError}
|
|
78
78
|
*
|
|
79
79
|
* @example
|
|
80
80
|
* await client.text.identifyLanguage({
|
|
81
81
|
* input: "input"
|
|
82
82
|
* })
|
|
83
83
|
*/
|
|
84
|
-
identifyLanguage(request:
|
|
84
|
+
identifyLanguage(request: SarvamAI.LanguageIdentificationRequest, requestOptions?: Text.RequestOptions): Promise<SarvamAI.LanguageIdentificationResponse>;
|
|
85
85
|
/**
|
|
86
86
|
* **Transliteration** converts text from one script to another while preserving the original pronunciation. For example, **'नमस्ते'** becomes **'namaste'** in English, and **'how are you'** can be written as **'हाउ आर यू'** in Devanagari. This process ensures that the sound of the original text remains intact, even when written in a different script.
|
|
87
87
|
*
|
|
@@ -107,14 +107,14 @@ export declare class Text {
|
|
|
107
107
|
*
|
|
108
108
|
* For hands-on practice, you can explore the notebook tutorial on [Transliterate API Tutorial](https://github.com/sarvamai/sarvam-ai-cookbook/blob/main/notebooks/transliterate/Transliterate_API_Tutorial.ipynb).
|
|
109
109
|
*
|
|
110
|
-
* @param {
|
|
110
|
+
* @param {SarvamAI.TransliterationRequest} request
|
|
111
111
|
* @param {Text.RequestOptions} requestOptions - Request-specific configuration.
|
|
112
112
|
*
|
|
113
|
-
* @throws {@link
|
|
114
|
-
* @throws {@link
|
|
115
|
-
* @throws {@link
|
|
116
|
-
* @throws {@link
|
|
117
|
-
* @throws {@link
|
|
113
|
+
* @throws {@link SarvamAI.BadRequestError}
|
|
114
|
+
* @throws {@link SarvamAI.ForbiddenError}
|
|
115
|
+
* @throws {@link SarvamAI.UnprocessableEntityError}
|
|
116
|
+
* @throws {@link SarvamAI.TooManyRequestsError}
|
|
117
|
+
* @throws {@link SarvamAI.InternalServerError}
|
|
118
118
|
*
|
|
119
119
|
* @example
|
|
120
120
|
* await client.text.transliterate({
|
|
@@ -123,5 +123,5 @@ export declare class Text {
|
|
|
123
123
|
* target_language_code: "en-IN"
|
|
124
124
|
* })
|
|
125
125
|
*/
|
|
126
|
-
transliterate(request:
|
|
126
|
+
transliterate(request: SarvamAI.TransliterationRequest, requestOptions?: Text.RequestOptions): Promise<SarvamAI.TransliterationResponse>;
|
|
127
127
|
}
|