sarvamai 1.1.6-alpha.1 → 1.1.6

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/README.md CHANGED
@@ -5,6 +5,28 @@
5
5
 
6
6
  The Sarvam TypeScript library provides convenient access to the Sarvam APIs from TypeScript.
7
7
 
8
+ ## Table of Contents
9
+
10
+ - [Documentation](#documentation)
11
+ - [Installation](#installation)
12
+ - [Reference](#reference)
13
+ - [Usage](#usage)
14
+ - [Request and Response Types](#request-and-response-types)
15
+ - [Exception Handling](#exception-handling)
16
+ - [File Uploads](#file-uploads)
17
+ - [Binary Response](#binary-response)
18
+ - [Advanced](#advanced)
19
+ - [Subpackage Exports](#subpackage-exports)
20
+ - [Additional Headers](#additional-headers)
21
+ - [Additional Query String Parameters](#additional-query-string-parameters)
22
+ - [Retries](#retries)
23
+ - [Timeouts](#timeouts)
24
+ - [Aborting Requests](#aborting-requests)
25
+ - [Access Raw Response Data](#access-raw-response-data)
26
+ - [Logging](#logging)
27
+ - [Runtime Compatibility](#runtime-compatibility)
28
+ - [Contributing](#contributing)
29
+
8
30
  ## Documentation
9
31
 
10
32
  API reference documentation is available [here](https://www.sarvam.ai/).
@@ -34,7 +56,7 @@ await client.text.translate({
34
56
  });
35
57
  ```
36
58
 
37
- ## Request And Response Types
59
+ ## Request and Response Types
38
60
 
39
61
  The SDK exports all request and response types as TypeScript interfaces. Simply import them with the
40
62
  following namespace:
@@ -73,8 +95,8 @@ You can upload files using the client:
73
95
 
74
96
  ```typescript
75
97
  import { createReadStream } from "fs";
76
- import { SarvamAIClient } from "sarvamai";
77
98
  import * as fs from "fs";
99
+ import { SarvamAIClient } from "sarvamai";
78
100
 
79
101
  const client = new SarvamAIClient({ apiSubscriptionKey: "YOUR_API_SUBSCRIPTION_KEY" });
80
102
  await client.speechToText.transcribe({
@@ -111,13 +133,421 @@ The metadata is used to set the `Content-Length`, `Content-Type`, and `Content-D
111
133
  For example, `fs.ReadStream` has a `path` property which the SDK uses to retrieve the file size from the filesystem without loading it into memory.
112
134
 
113
135
 
136
+ ## Binary Response
137
+
138
+ You can consume binary data from endpoints using the `BinaryResponse` type which lets you choose how to consume the data:
139
+
140
+ ```typescript
141
+ const response = await client.textToSpeech.convertStream(...);
142
+ const stream: ReadableStream<Uint8Array> = response.stream();
143
+ // const arrayBuffer: ArrayBuffer = await response.arrayBuffer();
144
+ // const blob: Blob = response.blob();
145
+ // const bytes: Uint8Array = response.bytes();
146
+ // You can only use the response body once, so you must choose one of the above methods.
147
+ // If you want to check if the response body has been used, you can use the following property.
148
+ const bodyUsed = response.bodyUsed;
149
+ ```
150
+ <details>
151
+ <summary>Save binary response to a file</summary>
152
+
153
+ <blockquote>
154
+ <details>
155
+ <summary>Node.js</summary>
156
+
157
+ <blockquote>
158
+ <details>
159
+ <summary>ReadableStream (most-efficient)</summary>
160
+
161
+ ```ts
162
+ import { createWriteStream } from 'fs';
163
+ import { Readable } from 'stream';
164
+ import { pipeline } from 'stream/promises';
165
+
166
+ const response = await client.textToSpeech.convertStream(...);
167
+
168
+ const stream = response.stream();
169
+ const nodeStream = Readable.fromWeb(stream);
170
+ const writeStream = createWriteStream('path/to/file');
171
+
172
+ await pipeline(nodeStream, writeStream);
173
+ ```
174
+
175
+ </details>
176
+ </blockquote>
177
+
178
+ <blockquote>
179
+ <details>
180
+ <summary>ArrayBuffer</summary>
181
+
182
+ ```ts
183
+ import { writeFile } from 'fs/promises';
184
+
185
+ const response = await client.textToSpeech.convertStream(...);
186
+
187
+ const arrayBuffer = await response.arrayBuffer();
188
+ await writeFile('path/to/file', Buffer.from(arrayBuffer));
189
+ ```
190
+
191
+ </details>
192
+ </blockquote>
193
+
194
+ <blockquote>
195
+ <details>
196
+ <summary>Blob</summary>
197
+
198
+ ```ts
199
+ import { writeFile } from 'fs/promises';
200
+
201
+ const response = await client.textToSpeech.convertStream(...);
202
+
203
+ const blob = await response.blob();
204
+ const arrayBuffer = await blob.arrayBuffer();
205
+ await writeFile('output.bin', Buffer.from(arrayBuffer));
206
+ ```
207
+
208
+ </details>
209
+ </blockquote>
210
+
211
+ <blockquote>
212
+ <details>
213
+ <summary>Bytes (UIntArray8)</summary>
214
+
215
+ ```ts
216
+ import { writeFile } from 'fs/promises';
217
+
218
+ const response = await client.textToSpeech.convertStream(...);
219
+
220
+ const bytes = await response.bytes();
221
+ await writeFile('path/to/file', bytes);
222
+ ```
223
+
224
+ </details>
225
+ </blockquote>
226
+
227
+ </details>
228
+ </blockquote>
229
+
230
+ <blockquote>
231
+ <details>
232
+ <summary>Bun</summary>
233
+
234
+ <blockquote>
235
+ <details>
236
+ <summary>ReadableStream (most-efficient)</summary>
237
+
238
+ ```ts
239
+ const response = await client.textToSpeech.convertStream(...);
240
+
241
+ const stream = response.stream();
242
+ await Bun.write('path/to/file', stream);
243
+ ```
244
+
245
+ </details>
246
+ </blockquote>
247
+
248
+ <blockquote>
249
+ <details>
250
+ <summary>ArrayBuffer</summary>
251
+
252
+ ```ts
253
+ const response = await client.textToSpeech.convertStream(...);
254
+
255
+ const arrayBuffer = await response.arrayBuffer();
256
+ await Bun.write('path/to/file', arrayBuffer);
257
+ ```
258
+
259
+ </details>
260
+ </blockquote>
261
+
262
+ <blockquote>
263
+ <details>
264
+ <summary>Blob</summary>
265
+
266
+ ```ts
267
+ const response = await client.textToSpeech.convertStream(...);
268
+
269
+ const blob = await response.blob();
270
+ await Bun.write('path/to/file', blob);
271
+ ```
272
+
273
+ </details>
274
+ </blockquote>
275
+
276
+ <blockquote>
277
+ <details>
278
+ <summary>Bytes (UIntArray8)</summary>
279
+
280
+ ```ts
281
+ const response = await client.textToSpeech.convertStream(...);
282
+
283
+ const bytes = await response.bytes();
284
+ await Bun.write('path/to/file', bytes);
285
+ ```
286
+
287
+ </details>
288
+ </blockquote>
289
+
290
+ </details>
291
+ </blockquote>
292
+
293
+ <blockquote>
294
+ <details>
295
+ <summary>Deno</summary>
296
+
297
+ <blockquote>
298
+ <details>
299
+ <summary>ReadableStream (most-efficient)</summary>
300
+
301
+ ```ts
302
+ const response = await client.textToSpeech.convertStream(...);
303
+
304
+ const stream = response.stream();
305
+ const file = await Deno.open('path/to/file', { write: true, create: true });
306
+ await stream.pipeTo(file.writable);
307
+ ```
308
+
309
+ </details>
310
+ </blockquote>
311
+
312
+ <blockquote>
313
+ <details>
314
+ <summary>ArrayBuffer</summary>
315
+
316
+ ```ts
317
+ const response = await client.textToSpeech.convertStream(...);
318
+
319
+ const arrayBuffer = await response.arrayBuffer();
320
+ await Deno.writeFile('path/to/file', new Uint8Array(arrayBuffer));
321
+ ```
322
+
323
+ </details>
324
+ </blockquote>
325
+
326
+ <blockquote>
327
+ <details>
328
+ <summary>Blob</summary>
329
+
330
+ ```ts
331
+ const response = await client.textToSpeech.convertStream(...);
332
+
333
+ const blob = await response.blob();
334
+ const arrayBuffer = await blob.arrayBuffer();
335
+ await Deno.writeFile('path/to/file', new Uint8Array(arrayBuffer));
336
+ ```
337
+
338
+ </details>
339
+ </blockquote>
340
+
341
+ <blockquote>
342
+ <details>
343
+ <summary>Bytes (UIntArray8)</summary>
344
+
345
+ ```ts
346
+ const response = await client.textToSpeech.convertStream(...);
347
+
348
+ const bytes = await response.bytes();
349
+ await Deno.writeFile('path/to/file', bytes);
350
+ ```
351
+
352
+ </details>
353
+ </blockquote>
354
+
355
+ </details>
356
+ </blockquote>
357
+
358
+ <blockquote>
359
+ <details>
360
+ <summary>Browser</summary>
361
+
362
+ <blockquote>
363
+ <details>
364
+ <summary>Blob (most-efficient)</summary>
365
+
366
+ ```ts
367
+ const response = await client.textToSpeech.convertStream(...);
368
+
369
+ const blob = await response.blob();
370
+ const url = URL.createObjectURL(blob);
371
+
372
+ // trigger download
373
+ const a = document.createElement('a');
374
+ a.href = url;
375
+ a.download = 'filename';
376
+ a.click();
377
+ URL.revokeObjectURL(url);
378
+ ```
379
+
380
+ </details>
381
+ </blockquote>
382
+
383
+ <blockquote>
384
+ <details>
385
+ <summary>ReadableStream</summary>
386
+
387
+ ```ts
388
+ const response = await client.textToSpeech.convertStream(...);
389
+
390
+ const stream = response.stream();
391
+ const reader = stream.getReader();
392
+ const chunks = [];
393
+
394
+ while (true) {
395
+ const { done, value } = await reader.read();
396
+ if (done) break;
397
+ chunks.push(value);
398
+ }
399
+
400
+ const blob = new Blob(chunks);
401
+ const url = URL.createObjectURL(blob);
402
+
403
+ // trigger download
404
+ const a = document.createElement('a');
405
+ a.href = url;
406
+ a.download = 'filename';
407
+ a.click();
408
+ URL.revokeObjectURL(url);
409
+ ```
410
+
411
+ </details>
412
+ </blockquote>
413
+
414
+ <blockquote>
415
+ <details>
416
+ <summary>ArrayBuffer</summary>
417
+
418
+ ```ts
419
+ const response = await client.textToSpeech.convertStream(...);
420
+
421
+ const arrayBuffer = await response.arrayBuffer();
422
+ const blob = new Blob([arrayBuffer]);
423
+ const url = URL.createObjectURL(blob);
424
+
425
+ // trigger download
426
+ const a = document.createElement('a');
427
+ a.href = url;
428
+ a.download = 'filename';
429
+ a.click();
430
+ URL.revokeObjectURL(url);
431
+ ```
432
+
433
+ </details>
434
+ </blockquote>
435
+
436
+ <blockquote>
437
+ <details>
438
+ <summary>Bytes (UIntArray8)</summary>
439
+
440
+ ```ts
441
+ const response = await client.textToSpeech.convertStream(...);
442
+
443
+ const bytes = await response.bytes();
444
+ const blob = new Blob([bytes]);
445
+ const url = URL.createObjectURL(blob);
446
+
447
+ // trigger download
448
+ const a = document.createElement('a');
449
+ a.href = url;
450
+ a.download = 'filename';
451
+ a.click();
452
+ URL.revokeObjectURL(url);
453
+ ```
454
+
455
+ </details>
456
+ </blockquote>
457
+
458
+ </details>
459
+ </blockquote>
460
+
461
+ </details>
462
+ </blockquote>
463
+
464
+ <details>
465
+ <summary>Convert binary response to text</summary>
466
+
467
+ <blockquote>
468
+ <details>
469
+ <summary>ReadableStream</summary>
470
+
471
+ ```ts
472
+ const response = await client.textToSpeech.convertStream(...);
473
+
474
+ const stream = response.stream();
475
+ const text = await new Response(stream).text();
476
+ ```
477
+
478
+ </details>
479
+ </blockquote>
480
+
481
+ <blockquote>
482
+ <details>
483
+ <summary>ArrayBuffer</summary>
484
+
485
+ ```ts
486
+ const response = await client.textToSpeech.convertStream(...);
487
+
488
+ const arrayBuffer = await response.arrayBuffer();
489
+ const text = new TextDecoder().decode(arrayBuffer);
490
+ ```
491
+
492
+ </details>
493
+ </blockquote>
494
+
495
+ <blockquote>
496
+ <details>
497
+ <summary>Blob</summary>
498
+
499
+ ```ts
500
+ const response = await client.textToSpeech.convertStream(...);
501
+
502
+ const blob = await response.blob();
503
+ const text = await blob.text();
504
+ ```
505
+
506
+ </details>
507
+ </blockquote>
508
+
509
+ <blockquote>
510
+ <details>
511
+ <summary>Bytes (UIntArray8)</summary>
512
+
513
+ ```ts
514
+ const response = await client.textToSpeech.convertStream(...);
515
+
516
+ const bytes = await response.bytes();
517
+ const text = new TextDecoder().decode(bytes);
518
+ ```
519
+
520
+ </details>
521
+ </blockquote>
522
+
523
+ </details>
524
+
114
525
  ## Advanced
115
526
 
527
+ ### Subpackage Exports
528
+
529
+ This SDK supports direct imports of subpackage clients, which allows JavaScript bundlers to tree-shake and include only the imported subpackage code. This results in much smaller bundle sizes.
530
+
531
+ ```typescript
532
+ import { TextClient } from 'sarvamai/text';
533
+
534
+ const client = new TextClient({...});
535
+ ```
536
+
116
537
  ### Additional Headers
117
538
 
118
539
  If you would like to send additional headers as part of the request, use the `headers` request option.
119
540
 
120
541
  ```typescript
542
+ import { SarvamAIClient } from "sarvamai";
543
+
544
+ const client = new SarvamAIClient({
545
+ ...
546
+ headers: {
547
+ 'X-Custom-Header': 'custom value'
548
+ }
549
+ });
550
+
121
551
  const response = await client.text.translate(..., {
122
552
  headers: {
123
553
  'X-Custom-Header': 'custom value'
@@ -290,4 +720,4 @@ otherwise they would be overwritten upon the next generated release. Feel free t
290
720
  a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
291
721
  an issue first to discuss with us!
292
722
 
293
- On the other hand, contributions to the README are always very welcome!
723
+ On the other hand, contributions to the README are always very welcome!
@@ -27,31 +27,13 @@ export declare class PronunciationDictionaryClient {
27
27
  list(requestOptions?: PronunciationDictionaryClient.RequestOptions): core.HttpResponsePromise<SarvamAI.PronunciationDictionaryGetResponse>;
28
28
  private __list;
29
29
  /**
30
- * Upload a JSON file to create a new pronunciation dictionary. Only supported by **bulbul:v3**.
31
- *
32
- * The pronunciation dictionary lets you define custom word-to-pronunciation mappings per language. When attached to a TTS request via the `dict_id` parameter, the service replaces matching words with their specified pronunciations before synthesis.
33
- *
34
- * **Limits:**
35
- * - Max 10 dictionaries per user
36
- * - Max 100 words per dictionary
37
- * - Max 1 MB file size
38
- *
39
- * **JSON file format:**
40
- * ```json
41
- * {
42
- * "pronunciations": {
43
- * "hi-IN": {
44
- * "B2B": "B to B",
45
- * "my name": "mera naam"
46
- * },
47
- * "en-IN": {
48
- * "teting": "testing"
49
- * }
50
- * }
51
- * }
52
- * ```
53
- *
54
- * Save this as a `.json` file and upload it via the `file` field. The returned `dictionary_id` can then be passed as `dict_id` in text-to-speech requests (REST, streaming, and WebSocket).
30
+ * Upload a `.json` file to create a new pronunciation dictionary. Only supported by **bulbul:v3**.
31
+ *
32
+ * The file should contain a JSON object with a `pronunciations` key mapping language codes to word-pronunciation pairs. See the [Pronunciation Dictionary guide](/api-reference-docs/api-guides-tutorials/text-to-speech/pronunciation-dictionary) for format details and examples.
33
+ *
34
+ * The returned `dictionary_id` can be passed as `dict_id` in text-to-speech requests (REST, HTTP Stream, and WebSocket).
35
+ *
36
+ * **Limits:** Max 10 dictionaries per user, 100 words per dictionary, 1 MB file size.
55
37
  *
56
38
  * @param {SarvamAI.CreatePronunciationDictionaryRequest} request
57
39
  * @param {PronunciationDictionaryClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -72,11 +54,9 @@ export declare class PronunciationDictionaryClient {
72
54
  create(request: SarvamAI.CreatePronunciationDictionaryRequest, requestOptions?: PronunciationDictionaryClient.RequestOptions): core.HttpResponsePromise<SarvamAI.PronunciationDictionaryResponse>;
73
55
  private __create;
74
56
  /**
75
- * Replace an existing pronunciation dictionary by uploading a new JSON file. The old dictionary contents will be fully replaced with the new data.
57
+ * Update an existing pronunciation dictionary by uploading a JSON file. You can add new words, change existing pronunciations, or both — entries not included in the uploaded file remain unchanged.
76
58
  *
77
- * **Limits:**
78
- * - Max 100 words per dictionary
79
- * - Max 1 MB file size
59
+ * **Limits:** Max 100 words per dictionary, 1 MB file size.
80
60
  *
81
61
  * The response includes the `dictionary_id` and the updated pronunciation mappings for verification.
82
62
  *
@@ -118,31 +118,13 @@ class PronunciationDictionaryClient {
118
118
  });
119
119
  }
120
120
  /**
121
- * Upload a JSON file to create a new pronunciation dictionary. Only supported by **bulbul:v3**.
121
+ * Upload a `.json` file to create a new pronunciation dictionary. Only supported by **bulbul:v3**.
122
122
  *
123
- * The pronunciation dictionary lets you define custom word-to-pronunciation mappings per language. When attached to a TTS request via the `dict_id` parameter, the service replaces matching words with their specified pronunciations before synthesis.
123
+ * The file should contain a JSON object with a `pronunciations` key mapping language codes to word-pronunciation pairs. See the [Pronunciation Dictionary guide](/api-reference-docs/api-guides-tutorials/text-to-speech/pronunciation-dictionary) for format details and examples.
124
124
  *
125
- * **Limits:**
126
- * - Max 10 dictionaries per user
127
- * - Max 100 words per dictionary
128
- * - Max 1 MB file size
125
+ * The returned `dictionary_id` can be passed as `dict_id` in text-to-speech requests (REST, HTTP Stream, and WebSocket).
129
126
  *
130
- * **JSON file format:**
131
- * ```json
132
- * {
133
- * "pronunciations": {
134
- * "hi-IN": {
135
- * "B2B": "B to B",
136
- * "my name": "mera naam"
137
- * },
138
- * "en-IN": {
139
- * "teting": "testing"
140
- * }
141
- * }
142
- * }
143
- * ```
144
- *
145
- * Save this as a `.json` file and upload it via the `file` field. The returned `dictionary_id` can then be passed as `dict_id` in text-to-speech requests (REST, streaming, and WebSocket).
127
+ * **Limits:** Max 10 dictionaries per user, 100 words per dictionary, 1 MB file size.
146
128
  *
147
129
  * @param {SarvamAI.CreatePronunciationDictionaryRequest} request
148
130
  * @param {PronunciationDictionaryClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -217,11 +199,9 @@ class PronunciationDictionaryClient {
217
199
  });
218
200
  }
219
201
  /**
220
- * Replace an existing pronunciation dictionary by uploading a new JSON file. The old dictionary contents will be fully replaced with the new data.
202
+ * Update an existing pronunciation dictionary by uploading a JSON file. You can add new words, change existing pronunciations, or both — entries not included in the uploaded file remain unchanged.
221
203
  *
222
- * **Limits:**
223
- * - Max 100 words per dictionary
224
- * - Max 1 MB file size
204
+ * **Limits:** Max 100 words per dictionary, 1 MB file size.
225
205
  *
226
206
  * The response includes the `dictionary_id` and the updated pronunciation mappings for verification.
227
207
  *
@@ -46,7 +46,7 @@ export declare class TextToSpeechClient {
46
46
  *
47
47
  * This endpoint supports streaming audio using the specified output codec (e.g., `audio/mpeg` for MP3). The response is returned as a binary audio stream, which can be played or saved directly by the client.
48
48
  *
49
- * Supports the `dict_id` parameter to apply a pronunciation dictionary during synthesis.
49
+ * Supports the `dict_id` parameter to apply a [pronunciation dictionary](/api-reference-docs/text-to-speech/pronunciation-dictionary/create) during synthesis.
50
50
  * @throws {@link SarvamAI.BadRequestError}
51
51
  * @throws {@link SarvamAI.ForbiddenError}
52
52
  * @throws {@link SarvamAI.UnprocessableEntityError}
@@ -137,7 +137,7 @@ class TextToSpeechClient {
137
137
  *
138
138
  * This endpoint supports streaming audio using the specified output codec (e.g., `audio/mpeg` for MP3). The response is returned as a binary audio stream, which can be played or saved directly by the client.
139
139
  *
140
- * Supports the `dict_id` parameter to apply a pronunciation dictionary during synthesis.
140
+ * Supports the `dict_id` parameter to apply a [pronunciation dictionary](/api-reference-docs/text-to-speech/pronunciation-dictionary/create) during synthesis.
141
141
  * @throws {@link SarvamAI.BadRequestError}
142
142
  * @throws {@link SarvamAI.ForbiddenError}
143
143
  * @throws {@link SarvamAI.UnprocessableEntityError}
@@ -96,9 +96,7 @@ export interface TextToSpeechRequest {
96
96
  /**
97
97
  * The ID of a pronunciation dictionary to apply during synthesis. When provided, matching words in the input text will be replaced with their custom pronunciations before generating speech.
98
98
  *
99
- * Create and manage dictionaries via the `/text-to-speech/pronunciation-dictionary` endpoints.
100
- *
101
- * **Note:** Only supported by **bulbul:v3**.
99
+ * Create and manage dictionaries via the [Pronunciation Dictionary API](/api-reference-docs/text-to-speech/pronunciation-dictionary/create). Only supported by **bulbul:v3**.
102
100
  */
103
101
  dict_id?: string;
104
102
  /**
@@ -67,9 +67,9 @@ export interface TextToSpeechStreamRequest {
67
67
  /** Enable caching for the request. Default is false. Currently in beta. */
68
68
  enable_cached_responses?: boolean;
69
69
  /**
70
- * The ID of a pronunciation dictionary to apply during synthesis.
70
+ * The ID of a pronunciation dictionary to apply during synthesis. When provided, matching words in the input text will be replaced with their custom pronunciations before generating speech.
71
71
  *
72
- * **Note:** Only supported by **bulbul:v3**.
72
+ * Create and manage dictionaries via the [Pronunciation Dictionary API](/api-reference-docs/text-to-speech/pronunciation-dictionary/create). Only supported by **bulbul:v3**.
73
73
  */
74
74
  dict_id?: string;
75
75
  /** Specifies the codec for the streamed output audio (e.g., 'mp3'). */
@@ -27,31 +27,13 @@ export declare class PronunciationDictionaryClient {
27
27
  list(requestOptions?: PronunciationDictionaryClient.RequestOptions): core.HttpResponsePromise<SarvamAI.PronunciationDictionaryGetResponse>;
28
28
  private __list;
29
29
  /**
30
- * Upload a JSON file to create a new pronunciation dictionary. Only supported by **bulbul:v3**.
31
- *
32
- * The pronunciation dictionary lets you define custom word-to-pronunciation mappings per language. When attached to a TTS request via the `dict_id` parameter, the service replaces matching words with their specified pronunciations before synthesis.
33
- *
34
- * **Limits:**
35
- * - Max 10 dictionaries per user
36
- * - Max 100 words per dictionary
37
- * - Max 1 MB file size
38
- *
39
- * **JSON file format:**
40
- * ```json
41
- * {
42
- * "pronunciations": {
43
- * "hi-IN": {
44
- * "B2B": "B to B",
45
- * "my name": "mera naam"
46
- * },
47
- * "en-IN": {
48
- * "teting": "testing"
49
- * }
50
- * }
51
- * }
52
- * ```
53
- *
54
- * Save this as a `.json` file and upload it via the `file` field. The returned `dictionary_id` can then be passed as `dict_id` in text-to-speech requests (REST, streaming, and WebSocket).
30
+ * Upload a `.json` file to create a new pronunciation dictionary. Only supported by **bulbul:v3**.
31
+ *
32
+ * The file should contain a JSON object with a `pronunciations` key mapping language codes to word-pronunciation pairs. See the [Pronunciation Dictionary guide](/api-reference-docs/api-guides-tutorials/text-to-speech/pronunciation-dictionary) for format details and examples.
33
+ *
34
+ * The returned `dictionary_id` can be passed as `dict_id` in text-to-speech requests (REST, HTTP Stream, and WebSocket).
35
+ *
36
+ * **Limits:** Max 10 dictionaries per user, 100 words per dictionary, 1 MB file size.
55
37
  *
56
38
  * @param {SarvamAI.CreatePronunciationDictionaryRequest} request
57
39
  * @param {PronunciationDictionaryClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -72,11 +54,9 @@ export declare class PronunciationDictionaryClient {
72
54
  create(request: SarvamAI.CreatePronunciationDictionaryRequest, requestOptions?: PronunciationDictionaryClient.RequestOptions): core.HttpResponsePromise<SarvamAI.PronunciationDictionaryResponse>;
73
55
  private __create;
74
56
  /**
75
- * Replace an existing pronunciation dictionary by uploading a new JSON file. The old dictionary contents will be fully replaced with the new data.
57
+ * Update an existing pronunciation dictionary by uploading a JSON file. You can add new words, change existing pronunciations, or both — entries not included in the uploaded file remain unchanged.
76
58
  *
77
- * **Limits:**
78
- * - Max 100 words per dictionary
79
- * - Max 1 MB file size
59
+ * **Limits:** Max 100 words per dictionary, 1 MB file size.
80
60
  *
81
61
  * The response includes the `dictionary_id` and the updated pronunciation mappings for verification.
82
62
  *
@@ -82,31 +82,13 @@ export class PronunciationDictionaryClient {
82
82
  });
83
83
  }
84
84
  /**
85
- * Upload a JSON file to create a new pronunciation dictionary. Only supported by **bulbul:v3**.
85
+ * Upload a `.json` file to create a new pronunciation dictionary. Only supported by **bulbul:v3**.
86
86
  *
87
- * The pronunciation dictionary lets you define custom word-to-pronunciation mappings per language. When attached to a TTS request via the `dict_id` parameter, the service replaces matching words with their specified pronunciations before synthesis.
87
+ * The file should contain a JSON object with a `pronunciations` key mapping language codes to word-pronunciation pairs. See the [Pronunciation Dictionary guide](/api-reference-docs/api-guides-tutorials/text-to-speech/pronunciation-dictionary) for format details and examples.
88
88
  *
89
- * **Limits:**
90
- * - Max 10 dictionaries per user
91
- * - Max 100 words per dictionary
92
- * - Max 1 MB file size
89
+ * The returned `dictionary_id` can be passed as `dict_id` in text-to-speech requests (REST, HTTP Stream, and WebSocket).
93
90
  *
94
- * **JSON file format:**
95
- * ```json
96
- * {
97
- * "pronunciations": {
98
- * "hi-IN": {
99
- * "B2B": "B to B",
100
- * "my name": "mera naam"
101
- * },
102
- * "en-IN": {
103
- * "teting": "testing"
104
- * }
105
- * }
106
- * }
107
- * ```
108
- *
109
- * Save this as a `.json` file and upload it via the `file` field. The returned `dictionary_id` can then be passed as `dict_id` in text-to-speech requests (REST, streaming, and WebSocket).
91
+ * **Limits:** Max 10 dictionaries per user, 100 words per dictionary, 1 MB file size.
110
92
  *
111
93
  * @param {SarvamAI.CreatePronunciationDictionaryRequest} request
112
94
  * @param {PronunciationDictionaryClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -181,11 +163,9 @@ export class PronunciationDictionaryClient {
181
163
  });
182
164
  }
183
165
  /**
184
- * Replace an existing pronunciation dictionary by uploading a new JSON file. The old dictionary contents will be fully replaced with the new data.
166
+ * Update an existing pronunciation dictionary by uploading a JSON file. You can add new words, change existing pronunciations, or both — entries not included in the uploaded file remain unchanged.
185
167
  *
186
- * **Limits:**
187
- * - Max 100 words per dictionary
188
- * - Max 1 MB file size
168
+ * **Limits:** Max 100 words per dictionary, 1 MB file size.
189
169
  *
190
170
  * The response includes the `dictionary_id` and the updated pronunciation mappings for verification.
191
171
  *
@@ -46,7 +46,7 @@ export declare class TextToSpeechClient {
46
46
  *
47
47
  * This endpoint supports streaming audio using the specified output codec (e.g., `audio/mpeg` for MP3). The response is returned as a binary audio stream, which can be played or saved directly by the client.
48
48
  *
49
- * Supports the `dict_id` parameter to apply a pronunciation dictionary during synthesis.
49
+ * Supports the `dict_id` parameter to apply a [pronunciation dictionary](/api-reference-docs/text-to-speech/pronunciation-dictionary/create) during synthesis.
50
50
  * @throws {@link SarvamAI.BadRequestError}
51
51
  * @throws {@link SarvamAI.ForbiddenError}
52
52
  * @throws {@link SarvamAI.UnprocessableEntityError}
@@ -101,7 +101,7 @@ export class TextToSpeechClient {
101
101
  *
102
102
  * This endpoint supports streaming audio using the specified output codec (e.g., `audio/mpeg` for MP3). The response is returned as a binary audio stream, which can be played or saved directly by the client.
103
103
  *
104
- * Supports the `dict_id` parameter to apply a pronunciation dictionary during synthesis.
104
+ * Supports the `dict_id` parameter to apply a [pronunciation dictionary](/api-reference-docs/text-to-speech/pronunciation-dictionary/create) during synthesis.
105
105
  * @throws {@link SarvamAI.BadRequestError}
106
106
  * @throws {@link SarvamAI.ForbiddenError}
107
107
  * @throws {@link SarvamAI.UnprocessableEntityError}
@@ -96,9 +96,7 @@ export interface TextToSpeechRequest {
96
96
  /**
97
97
  * The ID of a pronunciation dictionary to apply during synthesis. When provided, matching words in the input text will be replaced with their custom pronunciations before generating speech.
98
98
  *
99
- * Create and manage dictionaries via the `/text-to-speech/pronunciation-dictionary` endpoints.
100
- *
101
- * **Note:** Only supported by **bulbul:v3**.
99
+ * Create and manage dictionaries via the [Pronunciation Dictionary API](/api-reference-docs/text-to-speech/pronunciation-dictionary/create). Only supported by **bulbul:v3**.
102
100
  */
103
101
  dict_id?: string;
104
102
  /**
@@ -67,9 +67,9 @@ export interface TextToSpeechStreamRequest {
67
67
  /** Enable caching for the request. Default is false. Currently in beta. */
68
68
  enable_cached_responses?: boolean;
69
69
  /**
70
- * The ID of a pronunciation dictionary to apply during synthesis.
70
+ * The ID of a pronunciation dictionary to apply during synthesis. When provided, matching words in the input text will be replaced with their custom pronunciations before generating speech.
71
71
  *
72
- * **Note:** Only supported by **bulbul:v3**.
72
+ * Create and manage dictionaries via the [Pronunciation Dictionary API](/api-reference-docs/text-to-speech/pronunciation-dictionary/create). Only supported by **bulbul:v3**.
73
73
  */
74
74
  dict_id?: string;
75
75
  /** Specifies the codec for the streamed output audio (e.g., 'mp3'). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sarvamai",
3
- "version": "1.1.6-alpha.1",
3
+ "version": "1.1.6",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
package/reference.md CHANGED
@@ -500,7 +500,7 @@ Converts the input text into a streamed spoken audio response.
500
500
 
501
501
  This endpoint supports streaming audio using the specified output codec (e.g., `audio/mpeg` for MP3). The response is returned as a binary audio stream, which can be played or saved directly by the client.
502
502
 
503
- Supports the `dict_id` parameter to apply a pronunciation dictionary during synthesis.
503
+ Supports the `dict_id` parameter to apply a [pronunciation dictionary](/api-reference-docs/text-to-speech/pronunciation-dictionary/create) during synthesis.
504
504
  </dd>
505
505
  </dl>
506
506
  </dd>
@@ -621,31 +621,13 @@ await client.pronunciationDictionary.list();
621
621
  <dl>
622
622
  <dd>
623
623
 
624
- Upload a JSON file to create a new pronunciation dictionary. Only supported by **bulbul:v3**.
624
+ Upload a `.json` file to create a new pronunciation dictionary. Only supported by **bulbul:v3**.
625
625
 
626
- The pronunciation dictionary lets you define custom word-to-pronunciation mappings per language. When attached to a TTS request via the `dict_id` parameter, the service replaces matching words with their specified pronunciations before synthesis.
626
+ The file should contain a JSON object with a `pronunciations` key mapping language codes to word-pronunciation pairs. See the [Pronunciation Dictionary guide](/api-reference-docs/api-guides-tutorials/text-to-speech/pronunciation-dictionary) for format details and examples.
627
627
 
628
- **Limits:**
629
- - Max 10 dictionaries per user
630
- - Max 100 words per dictionary
631
- - Max 1 MB file size
628
+ The returned `dictionary_id` can be passed as `dict_id` in text-to-speech requests (REST, HTTP Stream, and WebSocket).
632
629
 
633
- **JSON file format:**
634
- ```json
635
- {
636
- "pronunciations": {
637
- "hi-IN": {
638
- "B2B": "B to B",
639
- "my name": "mera naam"
640
- },
641
- "en-IN": {
642
- "teting": "testing"
643
- }
644
- }
645
- }
646
- ```
647
-
648
- Save this as a `.json` file and upload it via the `file` field. The returned `dictionary_id` can then be passed as `dict_id` in text-to-speech requests (REST, streaming, and WebSocket).
630
+ **Limits:** Max 10 dictionaries per user, 100 words per dictionary, 1 MB file size.
649
631
  </dd>
650
632
  </dl>
651
633
  </dd>
@@ -710,11 +692,9 @@ await client.pronunciationDictionary.create({
710
692
  <dl>
711
693
  <dd>
712
694
 
713
- Replace an existing pronunciation dictionary by uploading a new JSON file. The old dictionary contents will be fully replaced with the new data.
695
+ Update an existing pronunciation dictionary by uploading a JSON file. You can add new words, change existing pronunciations, or both — entries not included in the uploaded file remain unchanged.
714
696
 
715
- **Limits:**
716
- - Max 100 words per dictionary
717
- - Max 1 MB file size
697
+ **Limits:** Max 100 words per dictionary, 1 MB file size.
718
698
 
719
699
  The response includes the `dictionary_id` and the updated pronunciation mappings for verification.
720
700
  </dd>