sarvamai 0.1.7a0__py3-none-any.whl → 0.1.8__py3-none-any.whl

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 (57) hide show
  1. sarvamai/__init__.py +48 -52
  2. sarvamai/client.py +3 -3
  3. sarvamai/core/client_wrapper.py +2 -2
  4. sarvamai/errors/service_unavailable_error.py +2 -1
  5. sarvamai/requests/__init__.py +20 -22
  6. sarvamai/requests/audio_output.py +11 -0
  7. sarvamai/requests/audio_output_data.py +15 -0
  8. sarvamai/requests/configure_connection.py +18 -0
  9. sarvamai/requests/configure_connection_data.py +83 -0
  10. sarvamai/requests/error_response.py +11 -0
  11. sarvamai/requests/error_response_data.py +18 -0
  12. sarvamai/requests/flush_signal.py +14 -0
  13. sarvamai/requests/ping_signal.py +14 -0
  14. sarvamai/requests/send_text.py +11 -0
  15. sarvamai/requests/{base_job_parameters.py → send_text_data.py} +2 -2
  16. sarvamai/speech_to_text/raw_client.py +9 -8
  17. sarvamai/text_to_speech_streaming/client.py +153 -0
  18. sarvamai/text_to_speech_streaming/raw_client.py +130 -0
  19. sarvamai/text_to_speech_streaming/socket_client.py +309 -0
  20. sarvamai/types/__init__.py +26 -28
  21. sarvamai/types/{files_request.py → audio_output.py} +4 -3
  22. sarvamai/types/{bulk_job_callback.py → audio_output_data.py} +5 -5
  23. sarvamai/types/configure_connection.py +28 -0
  24. sarvamai/types/configure_connection_data.py +93 -0
  25. sarvamai/types/configure_connection_data_output_audio_bitrate.py +7 -0
  26. sarvamai/types/configure_connection_data_speaker.py +7 -0
  27. sarvamai/types/configure_connection_data_target_language_code.py +8 -0
  28. sarvamai/types/{file_signed_url_details.py → error_response.py} +4 -3
  29. sarvamai/types/{files_download_response.py → error_response_data.py} +11 -8
  30. sarvamai/types/flush_signal.py +24 -0
  31. sarvamai/types/ping_signal.py +24 -0
  32. sarvamai/types/{task_file_details.py → send_text.py} +4 -3
  33. sarvamai/types/{base_job_parameters.py → send_text_data.py} +3 -1
  34. {sarvamai-0.1.7a0.dist-info → sarvamai-0.1.8.dist-info}/METADATA +1 -1
  35. {sarvamai-0.1.7a0.dist-info → sarvamai-0.1.8.dist-info}/RECORD +37 -38
  36. sarvamai/requests/bulk_job_callback.py +0 -15
  37. sarvamai/requests/bulk_job_init_response_v_1.py +0 -27
  38. sarvamai/requests/file_signed_url_details.py +0 -10
  39. sarvamai/requests/files_download_response.py +0 -15
  40. sarvamai/requests/files_request.py +0 -10
  41. sarvamai/requests/files_upload_response.py +0 -15
  42. sarvamai/requests/job_status_v_1.py +0 -70
  43. sarvamai/requests/speech_to_text_job_parameters.py +0 -32
  44. sarvamai/requests/task_detail_v_1.py +0 -15
  45. sarvamai/requests/task_file_details.py +0 -8
  46. sarvamai/speech_to_text_job/client.py +0 -454
  47. sarvamai/speech_to_text_job/raw_client.py +0 -1189
  48. sarvamai/types/bulk_job_init_response_v_1.py +0 -39
  49. sarvamai/types/files_upload_response.py +0 -25
  50. sarvamai/types/job_state.py +0 -5
  51. sarvamai/types/job_status_v_1.py +0 -80
  52. sarvamai/types/speech_to_text_job_parameters.py +0 -44
  53. sarvamai/types/storage_container_type.py +0 -5
  54. sarvamai/types/task_detail_v_1.py +0 -25
  55. sarvamai/types/task_state.py +0 -5
  56. /sarvamai/{speech_to_text_job → text_to_speech_streaming}/__init__.py +0 -0
  57. {sarvamai-0.1.7a0.dist-info → sarvamai-0.1.8.dist-info}/WHEEL +0 -0
@@ -1,27 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- import typing_extensions
4
- from ..types.job_state import JobState
5
- from ..types.storage_container_type import StorageContainerType
6
- from .base_job_parameters import BaseJobParametersParams
7
- from .bulk_job_callback import BulkJobCallbackParams
8
-
9
-
10
- class BulkJobInitResponseV1Params(typing_extensions.TypedDict):
11
- job_id: str
12
- """
13
- Job UUID.
14
- """
15
-
16
- storage_container_type: StorageContainerType
17
- """
18
- Storage Container Type
19
- """
20
-
21
- job_parameters: BaseJobParametersParams
22
- job_state: JobState
23
- owner_id: str
24
- callback: typing_extensions.NotRequired[BulkJobCallbackParams]
25
- """
26
- Parameters for callback URL
27
- """
@@ -1,10 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- import typing
4
-
5
- import typing_extensions
6
-
7
-
8
- class FileSignedUrlDetailsParams(typing_extensions.TypedDict):
9
- file_url: str
10
- file_metadata: typing_extensions.NotRequired[typing.Dict[str, typing.Optional[typing.Any]]]
@@ -1,15 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- import typing
4
-
5
- import typing_extensions
6
- from ..types.job_state import JobState
7
- from ..types.storage_container_type import StorageContainerType
8
- from .file_signed_url_details import FileSignedUrlDetailsParams
9
-
10
-
11
- class FilesDownloadResponseParams(typing_extensions.TypedDict):
12
- job_id: str
13
- job_state: JobState
14
- download_urls: typing.Dict[str, FileSignedUrlDetailsParams]
15
- storage_container_type: StorageContainerType
@@ -1,10 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- import typing
4
-
5
- import typing_extensions
6
-
7
-
8
- class FilesRequestParams(typing_extensions.TypedDict):
9
- job_id: str
10
- files: typing.Sequence[str]
@@ -1,15 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- import typing
4
-
5
- import typing_extensions
6
- from ..types.job_state import JobState
7
- from ..types.storage_container_type import StorageContainerType
8
- from .file_signed_url_details import FileSignedUrlDetailsParams
9
-
10
-
11
- class FilesUploadResponseParams(typing_extensions.TypedDict):
12
- job_id: str
13
- job_state: JobState
14
- upload_urls: typing.Dict[str, FileSignedUrlDetailsParams]
15
- storage_container_type: StorageContainerType
@@ -1,70 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- import typing
4
-
5
- import typing_extensions
6
- from ..types.job_state import JobState
7
- from ..types.storage_container_type import StorageContainerType
8
- from .task_detail_v_1 import TaskDetailV1Params
9
-
10
-
11
- class JobStatusV1Params(typing_extensions.TypedDict):
12
- job_state: JobState
13
- """
14
- Job State
15
- """
16
-
17
- created_at: str
18
- """
19
- Created At
20
- """
21
-
22
- updated_at: str
23
- """
24
- Updated At
25
- """
26
-
27
- job_id: str
28
- """
29
- Job Id
30
- """
31
-
32
- total_files: typing_extensions.NotRequired[int]
33
- """
34
- Total Files
35
- """
36
-
37
- successful_files_count: typing_extensions.NotRequired[int]
38
- """
39
- Success Count
40
- """
41
-
42
- failed_files_count: typing_extensions.NotRequired[int]
43
- """
44
- Failed Count
45
- """
46
-
47
- owner_id: str
48
- """
49
- Owner of the job
50
- """
51
-
52
- storage_container_type: StorageContainerType
53
- """
54
- Storage Container Type
55
- """
56
-
57
- error_message: typing_extensions.NotRequired[str]
58
- """
59
- Error Message
60
- """
61
-
62
- job_details: typing_extensions.NotRequired[typing.Sequence[TaskDetailV1Params]]
63
- """
64
- Job details at file level.
65
- """
66
-
67
- num_internal_retries: typing_extensions.NotRequired[int]
68
- """
69
- Number of internal retries
70
- """
@@ -1,32 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- import typing_extensions
4
- from ..types.speech_to_text_model import SpeechToTextModel
5
- from ..types.speech_to_text_translate_language import SpeechToTextTranslateLanguage
6
-
7
-
8
- class SpeechToTextJobParametersParams(typing_extensions.TypedDict):
9
- language_code: typing_extensions.NotRequired[SpeechToTextTranslateLanguage]
10
- """
11
- Language code
12
- """
13
-
14
- model: typing_extensions.NotRequired[SpeechToTextModel]
15
- """
16
- Model to be used for speech to text
17
- """
18
-
19
- with_timestamps: typing_extensions.NotRequired[bool]
20
- """
21
- Whether to include timestamps in the response
22
- """
23
-
24
- with_diarization: typing_extensions.NotRequired[bool]
25
- """
26
- Enables speaker diarization, which identifies and separates different speakers in the audio. In beta mode
27
- """
28
-
29
- num_speakers: typing_extensions.NotRequired[int]
30
- """
31
- Number of speakers to be detected in the audio. This is used when with_diarization is true.
32
- """
@@ -1,15 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- import typing
4
-
5
- import typing_extensions
6
- from ..types.task_state import TaskState
7
- from .task_file_details import TaskFileDetailsParams
8
-
9
-
10
- class TaskDetailV1Params(typing_extensions.TypedDict):
11
- inputs: typing_extensions.NotRequired[typing.Sequence[TaskFileDetailsParams]]
12
- outputs: typing_extensions.NotRequired[typing.Sequence[TaskFileDetailsParams]]
13
- state: typing_extensions.NotRequired[TaskState]
14
- error_message: typing_extensions.NotRequired[str]
15
- exception_name: typing_extensions.NotRequired[str]
@@ -1,8 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- import typing_extensions
4
-
5
-
6
- class TaskFileDetailsParams(typing_extensions.TypedDict):
7
- file_name: str
8
- file_id: str
@@ -1,454 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- import typing
4
-
5
- from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6
- from ..core.request_options import RequestOptions
7
- from ..requests.bulk_job_callback import BulkJobCallbackParams
8
- from ..requests.speech_to_text_job_parameters import SpeechToTextJobParametersParams
9
- from ..types.bulk_job_init_response_v_1 import BulkJobInitResponseV1
10
- from ..types.files_download_response import FilesDownloadResponse
11
- from ..types.files_upload_response import FilesUploadResponse
12
- from ..types.job_status_v_1 import JobStatusV1
13
- from .raw_client import AsyncRawSpeechToTextJobClient, RawSpeechToTextJobClient
14
-
15
- # this is used as the default value for optional parameters
16
- OMIT = typing.cast(typing.Any, ...)
17
-
18
-
19
- class SpeechToTextJobClient:
20
- def __init__(self, *, client_wrapper: SyncClientWrapper):
21
- self._raw_client = RawSpeechToTextJobClient(client_wrapper=client_wrapper)
22
-
23
- @property
24
- def with_raw_response(self) -> RawSpeechToTextJobClient:
25
- """
26
- Retrieves a raw implementation of this client that returns raw responses.
27
-
28
- Returns
29
- -------
30
- RawSpeechToTextJobClient
31
- """
32
- return self._raw_client
33
-
34
- def initialise(
35
- self,
36
- *,
37
- job_parameters: SpeechToTextJobParametersParams,
38
- callback: typing.Optional[BulkJobCallbackParams] = OMIT,
39
- request_options: typing.Optional[RequestOptions] = None,
40
- ) -> BulkJobInitResponseV1:
41
- """
42
- Get a job uuid, and storage folder details for speech to text bulk job v1
43
-
44
- Parameters
45
- ----------
46
- job_parameters : SpeechToTextJobParametersParams
47
- Job Parameters for the bulk job
48
-
49
- callback : typing.Optional[BulkJobCallbackParams]
50
- Parameters for callback URL
51
-
52
- request_options : typing.Optional[RequestOptions]
53
- Request-specific configuration.
54
-
55
- Returns
56
- -------
57
- BulkJobInitResponseV1
58
- Successful Response
59
-
60
- Examples
61
- --------
62
- from sarvamai import SarvamAI
63
-
64
- client = SarvamAI(
65
- api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
66
- )
67
- client.speech_to_text_job.initialise(
68
- job_parameters={},
69
- )
70
- """
71
- _response = self._raw_client.initialise(
72
- job_parameters=job_parameters, callback=callback, request_options=request_options
73
- )
74
- return _response.data
75
-
76
- def get_status(self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> JobStatusV1:
77
- """
78
- Get the status of a speech to text bulk job V1
79
-
80
- Parameters
81
- ----------
82
- job_id : str
83
- The unique identifier of the job
84
-
85
- request_options : typing.Optional[RequestOptions]
86
- Request-specific configuration.
87
-
88
- Returns
89
- -------
90
- JobStatusV1
91
- Successful Response
92
-
93
- Examples
94
- --------
95
- from sarvamai import SarvamAI
96
-
97
- client = SarvamAI(
98
- api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
99
- )
100
- client.speech_to_text_job.get_status(
101
- job_id="job_id",
102
- )
103
- """
104
- _response = self._raw_client.get_status(job_id, request_options=request_options)
105
- return _response.data
106
-
107
- def start(
108
- self,
109
- job_id: str,
110
- *,
111
- ptu_id: typing.Optional[int] = None,
112
- request_options: typing.Optional[RequestOptions] = None,
113
- ) -> JobStatusV1:
114
- """
115
- Start a speech to text bulk job V1
116
-
117
- Parameters
118
- ----------
119
- job_id : str
120
- The unique identifier of the job
121
-
122
- ptu_id : typing.Optional[int]
123
-
124
- request_options : typing.Optional[RequestOptions]
125
- Request-specific configuration.
126
-
127
- Returns
128
- -------
129
- JobStatusV1
130
- Successful Response
131
-
132
- Examples
133
- --------
134
- from sarvamai import SarvamAI
135
-
136
- client = SarvamAI(
137
- api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
138
- )
139
- client.speech_to_text_job.start(
140
- job_id="job_id",
141
- )
142
- """
143
- _response = self._raw_client.start(job_id, ptu_id=ptu_id, request_options=request_options)
144
- return _response.data
145
-
146
- def get_upload_links(
147
- self, *, job_id: str, files: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
148
- ) -> FilesUploadResponse:
149
- """
150
- Start a speech to text bulk job V1
151
-
152
- Parameters
153
- ----------
154
- job_id : str
155
-
156
- files : typing.Sequence[str]
157
-
158
- request_options : typing.Optional[RequestOptions]
159
- Request-specific configuration.
160
-
161
- Returns
162
- -------
163
- FilesUploadResponse
164
- Successful Response
165
-
166
- Examples
167
- --------
168
- from sarvamai import SarvamAI
169
-
170
- client = SarvamAI(
171
- api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
172
- )
173
- client.speech_to_text_job.get_upload_links(
174
- job_id="job_id",
175
- files=["files"],
176
- )
177
- """
178
- _response = self._raw_client.get_upload_links(job_id=job_id, files=files, request_options=request_options)
179
- return _response.data
180
-
181
- def get_download_links(
182
- self, *, job_id: str, files: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
183
- ) -> FilesDownloadResponse:
184
- """
185
- Start a speech to text bulk job V1
186
-
187
- Parameters
188
- ----------
189
- job_id : str
190
-
191
- files : typing.Sequence[str]
192
-
193
- request_options : typing.Optional[RequestOptions]
194
- Request-specific configuration.
195
-
196
- Returns
197
- -------
198
- FilesDownloadResponse
199
- Successful Response
200
-
201
- Examples
202
- --------
203
- from sarvamai import SarvamAI
204
-
205
- client = SarvamAI(
206
- api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
207
- )
208
- client.speech_to_text_job.get_download_links(
209
- job_id="job_id",
210
- files=["files"],
211
- )
212
- """
213
- _response = self._raw_client.get_download_links(job_id=job_id, files=files, request_options=request_options)
214
- return _response.data
215
-
216
-
217
- class AsyncSpeechToTextJobClient:
218
- def __init__(self, *, client_wrapper: AsyncClientWrapper):
219
- self._raw_client = AsyncRawSpeechToTextJobClient(client_wrapper=client_wrapper)
220
-
221
- @property
222
- def with_raw_response(self) -> AsyncRawSpeechToTextJobClient:
223
- """
224
- Retrieves a raw implementation of this client that returns raw responses.
225
-
226
- Returns
227
- -------
228
- AsyncRawSpeechToTextJobClient
229
- """
230
- return self._raw_client
231
-
232
- async def initialise(
233
- self,
234
- *,
235
- job_parameters: SpeechToTextJobParametersParams,
236
- callback: typing.Optional[BulkJobCallbackParams] = OMIT,
237
- request_options: typing.Optional[RequestOptions] = None,
238
- ) -> BulkJobInitResponseV1:
239
- """
240
- Get a job uuid, and storage folder details for speech to text bulk job v1
241
-
242
- Parameters
243
- ----------
244
- job_parameters : SpeechToTextJobParametersParams
245
- Job Parameters for the bulk job
246
-
247
- callback : typing.Optional[BulkJobCallbackParams]
248
- Parameters for callback URL
249
-
250
- request_options : typing.Optional[RequestOptions]
251
- Request-specific configuration.
252
-
253
- Returns
254
- -------
255
- BulkJobInitResponseV1
256
- Successful Response
257
-
258
- Examples
259
- --------
260
- import asyncio
261
-
262
- from sarvamai import AsyncSarvamAI
263
-
264
- client = AsyncSarvamAI(
265
- api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
266
- )
267
-
268
-
269
- async def main() -> None:
270
- await client.speech_to_text_job.initialise(
271
- job_parameters={},
272
- )
273
-
274
-
275
- asyncio.run(main())
276
- """
277
- _response = await self._raw_client.initialise(
278
- job_parameters=job_parameters, callback=callback, request_options=request_options
279
- )
280
- return _response.data
281
-
282
- async def get_status(self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> JobStatusV1:
283
- """
284
- Get the status of a speech to text bulk job V1
285
-
286
- Parameters
287
- ----------
288
- job_id : str
289
- The unique identifier of the job
290
-
291
- request_options : typing.Optional[RequestOptions]
292
- Request-specific configuration.
293
-
294
- Returns
295
- -------
296
- JobStatusV1
297
- Successful Response
298
-
299
- Examples
300
- --------
301
- import asyncio
302
-
303
- from sarvamai import AsyncSarvamAI
304
-
305
- client = AsyncSarvamAI(
306
- api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
307
- )
308
-
309
-
310
- async def main() -> None:
311
- await client.speech_to_text_job.get_status(
312
- job_id="job_id",
313
- )
314
-
315
-
316
- asyncio.run(main())
317
- """
318
- _response = await self._raw_client.get_status(job_id, request_options=request_options)
319
- return _response.data
320
-
321
- async def start(
322
- self,
323
- job_id: str,
324
- *,
325
- ptu_id: typing.Optional[int] = None,
326
- request_options: typing.Optional[RequestOptions] = None,
327
- ) -> JobStatusV1:
328
- """
329
- Start a speech to text bulk job V1
330
-
331
- Parameters
332
- ----------
333
- job_id : str
334
- The unique identifier of the job
335
-
336
- ptu_id : typing.Optional[int]
337
-
338
- request_options : typing.Optional[RequestOptions]
339
- Request-specific configuration.
340
-
341
- Returns
342
- -------
343
- JobStatusV1
344
- Successful Response
345
-
346
- Examples
347
- --------
348
- import asyncio
349
-
350
- from sarvamai import AsyncSarvamAI
351
-
352
- client = AsyncSarvamAI(
353
- api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
354
- )
355
-
356
-
357
- async def main() -> None:
358
- await client.speech_to_text_job.start(
359
- job_id="job_id",
360
- )
361
-
362
-
363
- asyncio.run(main())
364
- """
365
- _response = await self._raw_client.start(job_id, ptu_id=ptu_id, request_options=request_options)
366
- return _response.data
367
-
368
- async def get_upload_links(
369
- self, *, job_id: str, files: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
370
- ) -> FilesUploadResponse:
371
- """
372
- Start a speech to text bulk job V1
373
-
374
- Parameters
375
- ----------
376
- job_id : str
377
-
378
- files : typing.Sequence[str]
379
-
380
- request_options : typing.Optional[RequestOptions]
381
- Request-specific configuration.
382
-
383
- Returns
384
- -------
385
- FilesUploadResponse
386
- Successful Response
387
-
388
- Examples
389
- --------
390
- import asyncio
391
-
392
- from sarvamai import AsyncSarvamAI
393
-
394
- client = AsyncSarvamAI(
395
- api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
396
- )
397
-
398
-
399
- async def main() -> None:
400
- await client.speech_to_text_job.get_upload_links(
401
- job_id="job_id",
402
- files=["files"],
403
- )
404
-
405
-
406
- asyncio.run(main())
407
- """
408
- _response = await self._raw_client.get_upload_links(job_id=job_id, files=files, request_options=request_options)
409
- return _response.data
410
-
411
- async def get_download_links(
412
- self, *, job_id: str, files: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
413
- ) -> FilesDownloadResponse:
414
- """
415
- Start a speech to text bulk job V1
416
-
417
- Parameters
418
- ----------
419
- job_id : str
420
-
421
- files : typing.Sequence[str]
422
-
423
- request_options : typing.Optional[RequestOptions]
424
- Request-specific configuration.
425
-
426
- Returns
427
- -------
428
- FilesDownloadResponse
429
- Successful Response
430
-
431
- Examples
432
- --------
433
- import asyncio
434
-
435
- from sarvamai import AsyncSarvamAI
436
-
437
- client = AsyncSarvamAI(
438
- api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
439
- )
440
-
441
-
442
- async def main() -> None:
443
- await client.speech_to_text_job.get_download_links(
444
- job_id="job_id",
445
- files=["files"],
446
- )
447
-
448
-
449
- asyncio.run(main())
450
- """
451
- _response = await self._raw_client.get_download_links(
452
- job_id=job_id, files=files, request_options=request_options
453
- )
454
- return _response.data