sarvamai 0.1.10__py3-none-any.whl → 0.1.11__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 (53) hide show
  1. sarvamai/__init__.py +62 -4
  2. sarvamai/client.py +6 -0
  3. sarvamai/core/client_wrapper.py +2 -2
  4. sarvamai/errors/service_unavailable_error.py +1 -2
  5. sarvamai/requests/__init__.py +24 -0
  6. sarvamai/requests/base_job_parameters.py +7 -0
  7. sarvamai/requests/bulk_job_callback.py +15 -0
  8. sarvamai/requests/bulk_job_init_response_v_1.py +27 -0
  9. sarvamai/requests/configure_connection_data.py +2 -3
  10. sarvamai/requests/file_signed_url_details.py +10 -0
  11. sarvamai/requests/files_download_response.py +15 -0
  12. sarvamai/requests/files_request.py +10 -0
  13. sarvamai/requests/files_upload_response.py +15 -0
  14. sarvamai/requests/job_status_v_1.py +70 -0
  15. sarvamai/requests/speech_to_text_job_parameters.py +32 -0
  16. sarvamai/requests/speech_to_text_translate_job_parameters.py +28 -0
  17. sarvamai/requests/task_detail_v_1.py +15 -0
  18. sarvamai/requests/task_file_details.py +8 -0
  19. sarvamai/speech_to_text/raw_client.py +8 -9
  20. sarvamai/speech_to_text_job/__init__.py +4 -0
  21. sarvamai/speech_to_text_job/client.py +633 -0
  22. sarvamai/speech_to_text_job/job.py +472 -0
  23. sarvamai/speech_to_text_job/raw_client.py +1189 -0
  24. sarvamai/speech_to_text_translate_job/__init__.py +4 -0
  25. sarvamai/speech_to_text_translate_job/client.py +651 -0
  26. sarvamai/speech_to_text_translate_job/job.py +479 -0
  27. sarvamai/speech_to_text_translate_job/raw_client.py +1241 -0
  28. sarvamai/text_to_speech/client.py +7 -7
  29. sarvamai/text_to_speech/raw_client.py +7 -7
  30. sarvamai/types/__init__.py +34 -4
  31. sarvamai/types/base_job_parameters.py +17 -0
  32. sarvamai/types/bulk_job_callback.py +27 -0
  33. sarvamai/types/bulk_job_init_response_v_1.py +39 -0
  34. sarvamai/types/configure_connection_data.py +2 -1
  35. sarvamai/types/configure_connection_data_output_audio_codec.py +7 -0
  36. sarvamai/types/file_signed_url_details.py +20 -0
  37. sarvamai/types/files_download_response.py +25 -0
  38. sarvamai/types/files_request.py +20 -0
  39. sarvamai/types/files_upload_response.py +25 -0
  40. sarvamai/types/job_state.py +5 -0
  41. sarvamai/types/job_status_v_1.py +80 -0
  42. sarvamai/types/speech_to_text_job_parameters.py +44 -0
  43. sarvamai/types/speech_to_text_translate_job_parameters.py +40 -0
  44. sarvamai/types/storage_container_type.py +5 -0
  45. sarvamai/types/task_detail_v_1.py +25 -0
  46. sarvamai/types/task_file_details.py +20 -0
  47. sarvamai/types/task_state.py +5 -0
  48. sarvamai/types/text_to_speech_output_audio_codec.py +7 -0
  49. {sarvamai-0.1.10.dist-info → sarvamai-0.1.11.dist-info}/METADATA +1 -1
  50. {sarvamai-0.1.10.dist-info → sarvamai-0.1.11.dist-info}/RECORD +51 -16
  51. sarvamai/types/audio_codec.py +0 -5
  52. sarvamai/types/format.py +0 -5
  53. {sarvamai-0.1.10.dist-info → sarvamai-0.1.11.dist-info}/WHEEL +0 -0
@@ -0,0 +1,1241 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from json.decoder import JSONDecodeError
5
+
6
+ from ..core.api_error import ApiError
7
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8
+ from ..core.http_response import AsyncHttpResponse, HttpResponse
9
+ from ..core.jsonable_encoder import jsonable_encoder
10
+ from ..core.pydantic_utilities import parse_obj_as
11
+ from ..core.request_options import RequestOptions
12
+ from ..core.serialization import convert_and_respect_annotation_metadata
13
+ from ..errors.bad_request_error import BadRequestError
14
+ from ..errors.forbidden_error import ForbiddenError
15
+ from ..errors.internal_server_error import InternalServerError
16
+ from ..errors.service_unavailable_error import ServiceUnavailableError
17
+ from ..errors.too_many_requests_error import TooManyRequestsError
18
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
19
+ from ..requests.bulk_job_callback import BulkJobCallbackParams
20
+ from ..requests.speech_to_text_translate_job_parameters import SpeechToTextTranslateJobParametersParams
21
+ from ..types.bulk_job_init_response_v_1 import BulkJobInitResponseV1
22
+ from ..types.files_download_response import FilesDownloadResponse
23
+ from ..types.files_upload_response import FilesUploadResponse
24
+ from ..types.job_status_v_1 import JobStatusV1
25
+
26
+ # this is used as the default value for optional parameters
27
+ OMIT = typing.cast(typing.Any, ...)
28
+
29
+
30
+ class RawSpeechToTextTranslateJobClient:
31
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
32
+ self._client_wrapper = client_wrapper
33
+
34
+ def initialise(
35
+ self,
36
+ *,
37
+ job_parameters: SpeechToTextTranslateJobParametersParams,
38
+ ptu_id: typing.Optional[int] = None,
39
+ callback: typing.Optional[BulkJobCallbackParams] = OMIT,
40
+ request_options: typing.Optional[RequestOptions] = None,
41
+ ) -> HttpResponse[BulkJobInitResponseV1]:
42
+ """
43
+ Get a job uuid, and storage folder details for speech to text tranlsate bulk job v1
44
+
45
+ Parameters
46
+ ----------
47
+ job_parameters : SpeechToTextTranslateJobParametersParams
48
+ Job Parameters for the bulk job
49
+
50
+ ptu_id : typing.Optional[int]
51
+
52
+ callback : typing.Optional[BulkJobCallbackParams]
53
+ Parameters for callback URL
54
+
55
+ request_options : typing.Optional[RequestOptions]
56
+ Request-specific configuration.
57
+
58
+ Returns
59
+ -------
60
+ HttpResponse[BulkJobInitResponseV1]
61
+ Successful Response
62
+ """
63
+ _response = self._client_wrapper.httpx_client.request(
64
+ "speech-to-text-translate/job/v1",
65
+ base_url=self._client_wrapper.get_environment().base,
66
+ method="POST",
67
+ params={
68
+ "ptu_id": ptu_id,
69
+ },
70
+ json={
71
+ "job_parameters": convert_and_respect_annotation_metadata(
72
+ object_=job_parameters, annotation=SpeechToTextTranslateJobParametersParams, direction="write"
73
+ ),
74
+ "callback": convert_and_respect_annotation_metadata(
75
+ object_=callback, annotation=BulkJobCallbackParams, direction="write"
76
+ ),
77
+ },
78
+ headers={
79
+ "content-type": "application/json",
80
+ },
81
+ request_options=request_options,
82
+ omit=OMIT,
83
+ )
84
+ try:
85
+ if 200 <= _response.status_code < 300:
86
+ _data = typing.cast(
87
+ BulkJobInitResponseV1,
88
+ parse_obj_as(
89
+ type_=BulkJobInitResponseV1, # type: ignore
90
+ object_=_response.json(),
91
+ ),
92
+ )
93
+ return HttpResponse(response=_response, data=_data)
94
+ if _response.status_code == 400:
95
+ raise BadRequestError(
96
+ headers=dict(_response.headers),
97
+ body=typing.cast(
98
+ typing.Optional[typing.Any],
99
+ parse_obj_as(
100
+ type_=typing.Optional[typing.Any], # type: ignore
101
+ object_=_response.json(),
102
+ ),
103
+ ),
104
+ )
105
+ if _response.status_code == 403:
106
+ raise ForbiddenError(
107
+ headers=dict(_response.headers),
108
+ body=typing.cast(
109
+ typing.Optional[typing.Any],
110
+ parse_obj_as(
111
+ type_=typing.Optional[typing.Any], # type: ignore
112
+ object_=_response.json(),
113
+ ),
114
+ ),
115
+ )
116
+ if _response.status_code == 422:
117
+ raise UnprocessableEntityError(
118
+ headers=dict(_response.headers),
119
+ body=typing.cast(
120
+ typing.Optional[typing.Any],
121
+ parse_obj_as(
122
+ type_=typing.Optional[typing.Any], # type: ignore
123
+ object_=_response.json(),
124
+ ),
125
+ ),
126
+ )
127
+ if _response.status_code == 429:
128
+ raise TooManyRequestsError(
129
+ headers=dict(_response.headers),
130
+ body=typing.cast(
131
+ typing.Optional[typing.Any],
132
+ parse_obj_as(
133
+ type_=typing.Optional[typing.Any], # type: ignore
134
+ object_=_response.json(),
135
+ ),
136
+ ),
137
+ )
138
+ if _response.status_code == 500:
139
+ raise InternalServerError(
140
+ headers=dict(_response.headers),
141
+ body=typing.cast(
142
+ typing.Optional[typing.Any],
143
+ parse_obj_as(
144
+ type_=typing.Optional[typing.Any], # type: ignore
145
+ object_=_response.json(),
146
+ ),
147
+ ),
148
+ )
149
+ if _response.status_code == 503:
150
+ raise ServiceUnavailableError(
151
+ headers=dict(_response.headers),
152
+ body=typing.cast(
153
+ typing.Optional[typing.Any],
154
+ parse_obj_as(
155
+ type_=typing.Optional[typing.Any], # type: ignore
156
+ object_=_response.json(),
157
+ ),
158
+ ),
159
+ )
160
+ _response_json = _response.json()
161
+ except JSONDecodeError:
162
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
163
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
164
+
165
+ def get_status(
166
+ self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
167
+ ) -> HttpResponse[JobStatusV1]:
168
+ """
169
+ Get the status of a speech to text translate bulk job V1
170
+
171
+ Parameters
172
+ ----------
173
+ job_id : str
174
+ The unique identifier of the job
175
+
176
+ request_options : typing.Optional[RequestOptions]
177
+ Request-specific configuration.
178
+
179
+ Returns
180
+ -------
181
+ HttpResponse[JobStatusV1]
182
+ Successful Response
183
+ """
184
+ _response = self._client_wrapper.httpx_client.request(
185
+ f"speech-to-text-translate/job/v1/{jsonable_encoder(job_id)}/status",
186
+ base_url=self._client_wrapper.get_environment().base,
187
+ method="GET",
188
+ request_options=request_options,
189
+ )
190
+ try:
191
+ if 200 <= _response.status_code < 300:
192
+ _data = typing.cast(
193
+ JobStatusV1,
194
+ parse_obj_as(
195
+ type_=JobStatusV1, # type: ignore
196
+ object_=_response.json(),
197
+ ),
198
+ )
199
+ return HttpResponse(response=_response, data=_data)
200
+ if _response.status_code == 400:
201
+ raise BadRequestError(
202
+ headers=dict(_response.headers),
203
+ body=typing.cast(
204
+ typing.Optional[typing.Any],
205
+ parse_obj_as(
206
+ type_=typing.Optional[typing.Any], # type: ignore
207
+ object_=_response.json(),
208
+ ),
209
+ ),
210
+ )
211
+ if _response.status_code == 403:
212
+ raise ForbiddenError(
213
+ headers=dict(_response.headers),
214
+ body=typing.cast(
215
+ typing.Optional[typing.Any],
216
+ parse_obj_as(
217
+ type_=typing.Optional[typing.Any], # type: ignore
218
+ object_=_response.json(),
219
+ ),
220
+ ),
221
+ )
222
+ if _response.status_code == 422:
223
+ raise UnprocessableEntityError(
224
+ headers=dict(_response.headers),
225
+ body=typing.cast(
226
+ typing.Optional[typing.Any],
227
+ parse_obj_as(
228
+ type_=typing.Optional[typing.Any], # type: ignore
229
+ object_=_response.json(),
230
+ ),
231
+ ),
232
+ )
233
+ if _response.status_code == 429:
234
+ raise TooManyRequestsError(
235
+ headers=dict(_response.headers),
236
+ body=typing.cast(
237
+ typing.Optional[typing.Any],
238
+ parse_obj_as(
239
+ type_=typing.Optional[typing.Any], # type: ignore
240
+ object_=_response.json(),
241
+ ),
242
+ ),
243
+ )
244
+ if _response.status_code == 500:
245
+ raise InternalServerError(
246
+ headers=dict(_response.headers),
247
+ body=typing.cast(
248
+ typing.Optional[typing.Any],
249
+ parse_obj_as(
250
+ type_=typing.Optional[typing.Any], # type: ignore
251
+ object_=_response.json(),
252
+ ),
253
+ ),
254
+ )
255
+ if _response.status_code == 503:
256
+ raise ServiceUnavailableError(
257
+ headers=dict(_response.headers),
258
+ body=typing.cast(
259
+ typing.Optional[typing.Any],
260
+ parse_obj_as(
261
+ type_=typing.Optional[typing.Any], # type: ignore
262
+ object_=_response.json(),
263
+ ),
264
+ ),
265
+ )
266
+ _response_json = _response.json()
267
+ except JSONDecodeError:
268
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
269
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
270
+
271
+ def start(
272
+ self,
273
+ job_id: str,
274
+ *,
275
+ ptu_id: typing.Optional[int] = None,
276
+ request_options: typing.Optional[RequestOptions] = None,
277
+ ) -> HttpResponse[JobStatusV1]:
278
+ """
279
+ Start a speech to text translate bulk job V1
280
+
281
+ Parameters
282
+ ----------
283
+ job_id : str
284
+ The unique identifier of the job
285
+
286
+ ptu_id : typing.Optional[int]
287
+
288
+ request_options : typing.Optional[RequestOptions]
289
+ Request-specific configuration.
290
+
291
+ Returns
292
+ -------
293
+ HttpResponse[JobStatusV1]
294
+ Successful Response
295
+ """
296
+ _response = self._client_wrapper.httpx_client.request(
297
+ f"speech-to-text-translate/job/v1/{jsonable_encoder(job_id)}/start",
298
+ base_url=self._client_wrapper.get_environment().base,
299
+ method="POST",
300
+ params={
301
+ "ptu_id": ptu_id,
302
+ },
303
+ request_options=request_options,
304
+ )
305
+ try:
306
+ if 200 <= _response.status_code < 300:
307
+ _data = typing.cast(
308
+ JobStatusV1,
309
+ parse_obj_as(
310
+ type_=JobStatusV1, # type: ignore
311
+ object_=_response.json(),
312
+ ),
313
+ )
314
+ return HttpResponse(response=_response, data=_data)
315
+ if _response.status_code == 400:
316
+ raise BadRequestError(
317
+ headers=dict(_response.headers),
318
+ body=typing.cast(
319
+ typing.Optional[typing.Any],
320
+ parse_obj_as(
321
+ type_=typing.Optional[typing.Any], # type: ignore
322
+ object_=_response.json(),
323
+ ),
324
+ ),
325
+ )
326
+ if _response.status_code == 403:
327
+ raise ForbiddenError(
328
+ headers=dict(_response.headers),
329
+ body=typing.cast(
330
+ typing.Optional[typing.Any],
331
+ parse_obj_as(
332
+ type_=typing.Optional[typing.Any], # type: ignore
333
+ object_=_response.json(),
334
+ ),
335
+ ),
336
+ )
337
+ if _response.status_code == 422:
338
+ raise UnprocessableEntityError(
339
+ headers=dict(_response.headers),
340
+ body=typing.cast(
341
+ typing.Optional[typing.Any],
342
+ parse_obj_as(
343
+ type_=typing.Optional[typing.Any], # type: ignore
344
+ object_=_response.json(),
345
+ ),
346
+ ),
347
+ )
348
+ if _response.status_code == 429:
349
+ raise TooManyRequestsError(
350
+ headers=dict(_response.headers),
351
+ body=typing.cast(
352
+ typing.Optional[typing.Any],
353
+ parse_obj_as(
354
+ type_=typing.Optional[typing.Any], # type: ignore
355
+ object_=_response.json(),
356
+ ),
357
+ ),
358
+ )
359
+ if _response.status_code == 500:
360
+ raise InternalServerError(
361
+ headers=dict(_response.headers),
362
+ body=typing.cast(
363
+ typing.Optional[typing.Any],
364
+ parse_obj_as(
365
+ type_=typing.Optional[typing.Any], # type: ignore
366
+ object_=_response.json(),
367
+ ),
368
+ ),
369
+ )
370
+ if _response.status_code == 503:
371
+ raise ServiceUnavailableError(
372
+ headers=dict(_response.headers),
373
+ body=typing.cast(
374
+ typing.Optional[typing.Any],
375
+ parse_obj_as(
376
+ type_=typing.Optional[typing.Any], # type: ignore
377
+ object_=_response.json(),
378
+ ),
379
+ ),
380
+ )
381
+ _response_json = _response.json()
382
+ except JSONDecodeError:
383
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
384
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
385
+
386
+ def get_upload_links(
387
+ self,
388
+ *,
389
+ job_id: str,
390
+ files: typing.Sequence[str],
391
+ ptu_id: typing.Optional[int] = None,
392
+ request_options: typing.Optional[RequestOptions] = None,
393
+ ) -> HttpResponse[FilesUploadResponse]:
394
+ """
395
+ Start a speech to text bulk job V1
396
+
397
+ Parameters
398
+ ----------
399
+ job_id : str
400
+
401
+ files : typing.Sequence[str]
402
+
403
+ ptu_id : typing.Optional[int]
404
+
405
+ request_options : typing.Optional[RequestOptions]
406
+ Request-specific configuration.
407
+
408
+ Returns
409
+ -------
410
+ HttpResponse[FilesUploadResponse]
411
+ Successful Response
412
+ """
413
+ _response = self._client_wrapper.httpx_client.request(
414
+ "speech-to-text-translate/job/v1/upload-files",
415
+ base_url=self._client_wrapper.get_environment().base,
416
+ method="POST",
417
+ params={
418
+ "ptu_id": ptu_id,
419
+ },
420
+ json={
421
+ "job_id": job_id,
422
+ "files": files,
423
+ },
424
+ headers={
425
+ "content-type": "application/json",
426
+ },
427
+ request_options=request_options,
428
+ omit=OMIT,
429
+ )
430
+ try:
431
+ if 200 <= _response.status_code < 300:
432
+ _data = typing.cast(
433
+ FilesUploadResponse,
434
+ parse_obj_as(
435
+ type_=FilesUploadResponse, # type: ignore
436
+ object_=_response.json(),
437
+ ),
438
+ )
439
+ return HttpResponse(response=_response, data=_data)
440
+ if _response.status_code == 400:
441
+ raise BadRequestError(
442
+ headers=dict(_response.headers),
443
+ body=typing.cast(
444
+ typing.Optional[typing.Any],
445
+ parse_obj_as(
446
+ type_=typing.Optional[typing.Any], # type: ignore
447
+ object_=_response.json(),
448
+ ),
449
+ ),
450
+ )
451
+ if _response.status_code == 403:
452
+ raise ForbiddenError(
453
+ headers=dict(_response.headers),
454
+ body=typing.cast(
455
+ typing.Optional[typing.Any],
456
+ parse_obj_as(
457
+ type_=typing.Optional[typing.Any], # type: ignore
458
+ object_=_response.json(),
459
+ ),
460
+ ),
461
+ )
462
+ if _response.status_code == 422:
463
+ raise UnprocessableEntityError(
464
+ headers=dict(_response.headers),
465
+ body=typing.cast(
466
+ typing.Optional[typing.Any],
467
+ parse_obj_as(
468
+ type_=typing.Optional[typing.Any], # type: ignore
469
+ object_=_response.json(),
470
+ ),
471
+ ),
472
+ )
473
+ if _response.status_code == 429:
474
+ raise TooManyRequestsError(
475
+ headers=dict(_response.headers),
476
+ body=typing.cast(
477
+ typing.Optional[typing.Any],
478
+ parse_obj_as(
479
+ type_=typing.Optional[typing.Any], # type: ignore
480
+ object_=_response.json(),
481
+ ),
482
+ ),
483
+ )
484
+ if _response.status_code == 500:
485
+ raise InternalServerError(
486
+ headers=dict(_response.headers),
487
+ body=typing.cast(
488
+ typing.Optional[typing.Any],
489
+ parse_obj_as(
490
+ type_=typing.Optional[typing.Any], # type: ignore
491
+ object_=_response.json(),
492
+ ),
493
+ ),
494
+ )
495
+ if _response.status_code == 503:
496
+ raise ServiceUnavailableError(
497
+ headers=dict(_response.headers),
498
+ body=typing.cast(
499
+ typing.Optional[typing.Any],
500
+ parse_obj_as(
501
+ type_=typing.Optional[typing.Any], # type: ignore
502
+ object_=_response.json(),
503
+ ),
504
+ ),
505
+ )
506
+ _response_json = _response.json()
507
+ except JSONDecodeError:
508
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
509
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
510
+
511
+ def get_download_links(
512
+ self,
513
+ *,
514
+ job_id: str,
515
+ files: typing.Sequence[str],
516
+ ptu_id: typing.Optional[int] = None,
517
+ request_options: typing.Optional[RequestOptions] = None,
518
+ ) -> HttpResponse[FilesDownloadResponse]:
519
+ """
520
+ Start a speech to text bulk job V1
521
+
522
+ Parameters
523
+ ----------
524
+ job_id : str
525
+
526
+ files : typing.Sequence[str]
527
+
528
+ ptu_id : typing.Optional[int]
529
+
530
+ request_options : typing.Optional[RequestOptions]
531
+ Request-specific configuration.
532
+
533
+ Returns
534
+ -------
535
+ HttpResponse[FilesDownloadResponse]
536
+ Successful Response
537
+ """
538
+ _response = self._client_wrapper.httpx_client.request(
539
+ "speech-to-text-translate/job/v1/download-files",
540
+ base_url=self._client_wrapper.get_environment().base,
541
+ method="POST",
542
+ params={
543
+ "ptu_id": ptu_id,
544
+ },
545
+ json={
546
+ "job_id": job_id,
547
+ "files": files,
548
+ },
549
+ headers={
550
+ "content-type": "application/json",
551
+ },
552
+ request_options=request_options,
553
+ omit=OMIT,
554
+ )
555
+ try:
556
+ if 200 <= _response.status_code < 300:
557
+ _data = typing.cast(
558
+ FilesDownloadResponse,
559
+ parse_obj_as(
560
+ type_=FilesDownloadResponse, # type: ignore
561
+ object_=_response.json(),
562
+ ),
563
+ )
564
+ return HttpResponse(response=_response, data=_data)
565
+ if _response.status_code == 400:
566
+ raise BadRequestError(
567
+ headers=dict(_response.headers),
568
+ body=typing.cast(
569
+ typing.Optional[typing.Any],
570
+ parse_obj_as(
571
+ type_=typing.Optional[typing.Any], # type: ignore
572
+ object_=_response.json(),
573
+ ),
574
+ ),
575
+ )
576
+ if _response.status_code == 403:
577
+ raise ForbiddenError(
578
+ headers=dict(_response.headers),
579
+ body=typing.cast(
580
+ typing.Optional[typing.Any],
581
+ parse_obj_as(
582
+ type_=typing.Optional[typing.Any], # type: ignore
583
+ object_=_response.json(),
584
+ ),
585
+ ),
586
+ )
587
+ if _response.status_code == 422:
588
+ raise UnprocessableEntityError(
589
+ headers=dict(_response.headers),
590
+ body=typing.cast(
591
+ typing.Optional[typing.Any],
592
+ parse_obj_as(
593
+ type_=typing.Optional[typing.Any], # type: ignore
594
+ object_=_response.json(),
595
+ ),
596
+ ),
597
+ )
598
+ if _response.status_code == 429:
599
+ raise TooManyRequestsError(
600
+ headers=dict(_response.headers),
601
+ body=typing.cast(
602
+ typing.Optional[typing.Any],
603
+ parse_obj_as(
604
+ type_=typing.Optional[typing.Any], # type: ignore
605
+ object_=_response.json(),
606
+ ),
607
+ ),
608
+ )
609
+ if _response.status_code == 500:
610
+ raise InternalServerError(
611
+ headers=dict(_response.headers),
612
+ body=typing.cast(
613
+ typing.Optional[typing.Any],
614
+ parse_obj_as(
615
+ type_=typing.Optional[typing.Any], # type: ignore
616
+ object_=_response.json(),
617
+ ),
618
+ ),
619
+ )
620
+ if _response.status_code == 503:
621
+ raise ServiceUnavailableError(
622
+ headers=dict(_response.headers),
623
+ body=typing.cast(
624
+ typing.Optional[typing.Any],
625
+ parse_obj_as(
626
+ type_=typing.Optional[typing.Any], # type: ignore
627
+ object_=_response.json(),
628
+ ),
629
+ ),
630
+ )
631
+ _response_json = _response.json()
632
+ except JSONDecodeError:
633
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
634
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
635
+
636
+
637
+ class AsyncRawSpeechToTextTranslateJobClient:
638
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
639
+ self._client_wrapper = client_wrapper
640
+
641
+ async def initialise(
642
+ self,
643
+ *,
644
+ job_parameters: SpeechToTextTranslateJobParametersParams,
645
+ ptu_id: typing.Optional[int] = None,
646
+ callback: typing.Optional[BulkJobCallbackParams] = OMIT,
647
+ request_options: typing.Optional[RequestOptions] = None,
648
+ ) -> AsyncHttpResponse[BulkJobInitResponseV1]:
649
+ """
650
+ Get a job uuid, and storage folder details for speech to text tranlsate bulk job v1
651
+
652
+ Parameters
653
+ ----------
654
+ job_parameters : SpeechToTextTranslateJobParametersParams
655
+ Job Parameters for the bulk job
656
+
657
+ ptu_id : typing.Optional[int]
658
+
659
+ callback : typing.Optional[BulkJobCallbackParams]
660
+ Parameters for callback URL
661
+
662
+ request_options : typing.Optional[RequestOptions]
663
+ Request-specific configuration.
664
+
665
+ Returns
666
+ -------
667
+ AsyncHttpResponse[BulkJobInitResponseV1]
668
+ Successful Response
669
+ """
670
+ _response = await self._client_wrapper.httpx_client.request(
671
+ "speech-to-text-translate/job/v1",
672
+ base_url=self._client_wrapper.get_environment().base,
673
+ method="POST",
674
+ params={
675
+ "ptu_id": ptu_id,
676
+ },
677
+ json={
678
+ "job_parameters": convert_and_respect_annotation_metadata(
679
+ object_=job_parameters, annotation=SpeechToTextTranslateJobParametersParams, direction="write"
680
+ ),
681
+ "callback": convert_and_respect_annotation_metadata(
682
+ object_=callback, annotation=BulkJobCallbackParams, direction="write"
683
+ ),
684
+ },
685
+ headers={
686
+ "content-type": "application/json",
687
+ },
688
+ request_options=request_options,
689
+ omit=OMIT,
690
+ )
691
+ try:
692
+ if 200 <= _response.status_code < 300:
693
+ _data = typing.cast(
694
+ BulkJobInitResponseV1,
695
+ parse_obj_as(
696
+ type_=BulkJobInitResponseV1, # type: ignore
697
+ object_=_response.json(),
698
+ ),
699
+ )
700
+ return AsyncHttpResponse(response=_response, data=_data)
701
+ if _response.status_code == 400:
702
+ raise BadRequestError(
703
+ headers=dict(_response.headers),
704
+ body=typing.cast(
705
+ typing.Optional[typing.Any],
706
+ parse_obj_as(
707
+ type_=typing.Optional[typing.Any], # type: ignore
708
+ object_=_response.json(),
709
+ ),
710
+ ),
711
+ )
712
+ if _response.status_code == 403:
713
+ raise ForbiddenError(
714
+ headers=dict(_response.headers),
715
+ body=typing.cast(
716
+ typing.Optional[typing.Any],
717
+ parse_obj_as(
718
+ type_=typing.Optional[typing.Any], # type: ignore
719
+ object_=_response.json(),
720
+ ),
721
+ ),
722
+ )
723
+ if _response.status_code == 422:
724
+ raise UnprocessableEntityError(
725
+ headers=dict(_response.headers),
726
+ body=typing.cast(
727
+ typing.Optional[typing.Any],
728
+ parse_obj_as(
729
+ type_=typing.Optional[typing.Any], # type: ignore
730
+ object_=_response.json(),
731
+ ),
732
+ ),
733
+ )
734
+ if _response.status_code == 429:
735
+ raise TooManyRequestsError(
736
+ headers=dict(_response.headers),
737
+ body=typing.cast(
738
+ typing.Optional[typing.Any],
739
+ parse_obj_as(
740
+ type_=typing.Optional[typing.Any], # type: ignore
741
+ object_=_response.json(),
742
+ ),
743
+ ),
744
+ )
745
+ if _response.status_code == 500:
746
+ raise InternalServerError(
747
+ headers=dict(_response.headers),
748
+ body=typing.cast(
749
+ typing.Optional[typing.Any],
750
+ parse_obj_as(
751
+ type_=typing.Optional[typing.Any], # type: ignore
752
+ object_=_response.json(),
753
+ ),
754
+ ),
755
+ )
756
+ if _response.status_code == 503:
757
+ raise ServiceUnavailableError(
758
+ headers=dict(_response.headers),
759
+ body=typing.cast(
760
+ typing.Optional[typing.Any],
761
+ parse_obj_as(
762
+ type_=typing.Optional[typing.Any], # type: ignore
763
+ object_=_response.json(),
764
+ ),
765
+ ),
766
+ )
767
+ _response_json = _response.json()
768
+ except JSONDecodeError:
769
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
770
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
771
+
772
+ async def get_status(
773
+ self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
774
+ ) -> AsyncHttpResponse[JobStatusV1]:
775
+ """
776
+ Get the status of a speech to text translate bulk job V1
777
+
778
+ Parameters
779
+ ----------
780
+ job_id : str
781
+ The unique identifier of the job
782
+
783
+ request_options : typing.Optional[RequestOptions]
784
+ Request-specific configuration.
785
+
786
+ Returns
787
+ -------
788
+ AsyncHttpResponse[JobStatusV1]
789
+ Successful Response
790
+ """
791
+ _response = await self._client_wrapper.httpx_client.request(
792
+ f"speech-to-text-translate/job/v1/{jsonable_encoder(job_id)}/status",
793
+ base_url=self._client_wrapper.get_environment().base,
794
+ method="GET",
795
+ request_options=request_options,
796
+ )
797
+ try:
798
+ if 200 <= _response.status_code < 300:
799
+ _data = typing.cast(
800
+ JobStatusV1,
801
+ parse_obj_as(
802
+ type_=JobStatusV1, # type: ignore
803
+ object_=_response.json(),
804
+ ),
805
+ )
806
+ return AsyncHttpResponse(response=_response, data=_data)
807
+ if _response.status_code == 400:
808
+ raise BadRequestError(
809
+ headers=dict(_response.headers),
810
+ body=typing.cast(
811
+ typing.Optional[typing.Any],
812
+ parse_obj_as(
813
+ type_=typing.Optional[typing.Any], # type: ignore
814
+ object_=_response.json(),
815
+ ),
816
+ ),
817
+ )
818
+ if _response.status_code == 403:
819
+ raise ForbiddenError(
820
+ headers=dict(_response.headers),
821
+ body=typing.cast(
822
+ typing.Optional[typing.Any],
823
+ parse_obj_as(
824
+ type_=typing.Optional[typing.Any], # type: ignore
825
+ object_=_response.json(),
826
+ ),
827
+ ),
828
+ )
829
+ if _response.status_code == 422:
830
+ raise UnprocessableEntityError(
831
+ headers=dict(_response.headers),
832
+ body=typing.cast(
833
+ typing.Optional[typing.Any],
834
+ parse_obj_as(
835
+ type_=typing.Optional[typing.Any], # type: ignore
836
+ object_=_response.json(),
837
+ ),
838
+ ),
839
+ )
840
+ if _response.status_code == 429:
841
+ raise TooManyRequestsError(
842
+ headers=dict(_response.headers),
843
+ body=typing.cast(
844
+ typing.Optional[typing.Any],
845
+ parse_obj_as(
846
+ type_=typing.Optional[typing.Any], # type: ignore
847
+ object_=_response.json(),
848
+ ),
849
+ ),
850
+ )
851
+ if _response.status_code == 500:
852
+ raise InternalServerError(
853
+ headers=dict(_response.headers),
854
+ body=typing.cast(
855
+ typing.Optional[typing.Any],
856
+ parse_obj_as(
857
+ type_=typing.Optional[typing.Any], # type: ignore
858
+ object_=_response.json(),
859
+ ),
860
+ ),
861
+ )
862
+ if _response.status_code == 503:
863
+ raise ServiceUnavailableError(
864
+ headers=dict(_response.headers),
865
+ body=typing.cast(
866
+ typing.Optional[typing.Any],
867
+ parse_obj_as(
868
+ type_=typing.Optional[typing.Any], # type: ignore
869
+ object_=_response.json(),
870
+ ),
871
+ ),
872
+ )
873
+ _response_json = _response.json()
874
+ except JSONDecodeError:
875
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
876
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
877
+
878
+ async def start(
879
+ self,
880
+ job_id: str,
881
+ *,
882
+ ptu_id: typing.Optional[int] = None,
883
+ request_options: typing.Optional[RequestOptions] = None,
884
+ ) -> AsyncHttpResponse[JobStatusV1]:
885
+ """
886
+ Start a speech to text translate bulk job V1
887
+
888
+ Parameters
889
+ ----------
890
+ job_id : str
891
+ The unique identifier of the job
892
+
893
+ ptu_id : typing.Optional[int]
894
+
895
+ request_options : typing.Optional[RequestOptions]
896
+ Request-specific configuration.
897
+
898
+ Returns
899
+ -------
900
+ AsyncHttpResponse[JobStatusV1]
901
+ Successful Response
902
+ """
903
+ _response = await self._client_wrapper.httpx_client.request(
904
+ f"speech-to-text-translate/job/v1/{jsonable_encoder(job_id)}/start",
905
+ base_url=self._client_wrapper.get_environment().base,
906
+ method="POST",
907
+ params={
908
+ "ptu_id": ptu_id,
909
+ },
910
+ request_options=request_options,
911
+ )
912
+ try:
913
+ if 200 <= _response.status_code < 300:
914
+ _data = typing.cast(
915
+ JobStatusV1,
916
+ parse_obj_as(
917
+ type_=JobStatusV1, # type: ignore
918
+ object_=_response.json(),
919
+ ),
920
+ )
921
+ return AsyncHttpResponse(response=_response, data=_data)
922
+ if _response.status_code == 400:
923
+ raise BadRequestError(
924
+ headers=dict(_response.headers),
925
+ body=typing.cast(
926
+ typing.Optional[typing.Any],
927
+ parse_obj_as(
928
+ type_=typing.Optional[typing.Any], # type: ignore
929
+ object_=_response.json(),
930
+ ),
931
+ ),
932
+ )
933
+ if _response.status_code == 403:
934
+ raise ForbiddenError(
935
+ headers=dict(_response.headers),
936
+ body=typing.cast(
937
+ typing.Optional[typing.Any],
938
+ parse_obj_as(
939
+ type_=typing.Optional[typing.Any], # type: ignore
940
+ object_=_response.json(),
941
+ ),
942
+ ),
943
+ )
944
+ if _response.status_code == 422:
945
+ raise UnprocessableEntityError(
946
+ headers=dict(_response.headers),
947
+ body=typing.cast(
948
+ typing.Optional[typing.Any],
949
+ parse_obj_as(
950
+ type_=typing.Optional[typing.Any], # type: ignore
951
+ object_=_response.json(),
952
+ ),
953
+ ),
954
+ )
955
+ if _response.status_code == 429:
956
+ raise TooManyRequestsError(
957
+ headers=dict(_response.headers),
958
+ body=typing.cast(
959
+ typing.Optional[typing.Any],
960
+ parse_obj_as(
961
+ type_=typing.Optional[typing.Any], # type: ignore
962
+ object_=_response.json(),
963
+ ),
964
+ ),
965
+ )
966
+ if _response.status_code == 500:
967
+ raise InternalServerError(
968
+ headers=dict(_response.headers),
969
+ body=typing.cast(
970
+ typing.Optional[typing.Any],
971
+ parse_obj_as(
972
+ type_=typing.Optional[typing.Any], # type: ignore
973
+ object_=_response.json(),
974
+ ),
975
+ ),
976
+ )
977
+ if _response.status_code == 503:
978
+ raise ServiceUnavailableError(
979
+ headers=dict(_response.headers),
980
+ body=typing.cast(
981
+ typing.Optional[typing.Any],
982
+ parse_obj_as(
983
+ type_=typing.Optional[typing.Any], # type: ignore
984
+ object_=_response.json(),
985
+ ),
986
+ ),
987
+ )
988
+ _response_json = _response.json()
989
+ except JSONDecodeError:
990
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
991
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
992
+
993
+ async def get_upload_links(
994
+ self,
995
+ *,
996
+ job_id: str,
997
+ files: typing.Sequence[str],
998
+ ptu_id: typing.Optional[int] = None,
999
+ request_options: typing.Optional[RequestOptions] = None,
1000
+ ) -> AsyncHttpResponse[FilesUploadResponse]:
1001
+ """
1002
+ Start a speech to text bulk job V1
1003
+
1004
+ Parameters
1005
+ ----------
1006
+ job_id : str
1007
+
1008
+ files : typing.Sequence[str]
1009
+
1010
+ ptu_id : typing.Optional[int]
1011
+
1012
+ request_options : typing.Optional[RequestOptions]
1013
+ Request-specific configuration.
1014
+
1015
+ Returns
1016
+ -------
1017
+ AsyncHttpResponse[FilesUploadResponse]
1018
+ Successful Response
1019
+ """
1020
+ _response = await self._client_wrapper.httpx_client.request(
1021
+ "speech-to-text-translate/job/v1/upload-files",
1022
+ base_url=self._client_wrapper.get_environment().base,
1023
+ method="POST",
1024
+ params={
1025
+ "ptu_id": ptu_id,
1026
+ },
1027
+ json={
1028
+ "job_id": job_id,
1029
+ "files": files,
1030
+ },
1031
+ headers={
1032
+ "content-type": "application/json",
1033
+ },
1034
+ request_options=request_options,
1035
+ omit=OMIT,
1036
+ )
1037
+ try:
1038
+ if 200 <= _response.status_code < 300:
1039
+ _data = typing.cast(
1040
+ FilesUploadResponse,
1041
+ parse_obj_as(
1042
+ type_=FilesUploadResponse, # type: ignore
1043
+ object_=_response.json(),
1044
+ ),
1045
+ )
1046
+ return AsyncHttpResponse(response=_response, data=_data)
1047
+ if _response.status_code == 400:
1048
+ raise BadRequestError(
1049
+ headers=dict(_response.headers),
1050
+ body=typing.cast(
1051
+ typing.Optional[typing.Any],
1052
+ parse_obj_as(
1053
+ type_=typing.Optional[typing.Any], # type: ignore
1054
+ object_=_response.json(),
1055
+ ),
1056
+ ),
1057
+ )
1058
+ if _response.status_code == 403:
1059
+ raise ForbiddenError(
1060
+ headers=dict(_response.headers),
1061
+ body=typing.cast(
1062
+ typing.Optional[typing.Any],
1063
+ parse_obj_as(
1064
+ type_=typing.Optional[typing.Any], # type: ignore
1065
+ object_=_response.json(),
1066
+ ),
1067
+ ),
1068
+ )
1069
+ if _response.status_code == 422:
1070
+ raise UnprocessableEntityError(
1071
+ headers=dict(_response.headers),
1072
+ body=typing.cast(
1073
+ typing.Optional[typing.Any],
1074
+ parse_obj_as(
1075
+ type_=typing.Optional[typing.Any], # type: ignore
1076
+ object_=_response.json(),
1077
+ ),
1078
+ ),
1079
+ )
1080
+ if _response.status_code == 429:
1081
+ raise TooManyRequestsError(
1082
+ headers=dict(_response.headers),
1083
+ body=typing.cast(
1084
+ typing.Optional[typing.Any],
1085
+ parse_obj_as(
1086
+ type_=typing.Optional[typing.Any], # type: ignore
1087
+ object_=_response.json(),
1088
+ ),
1089
+ ),
1090
+ )
1091
+ if _response.status_code == 500:
1092
+ raise InternalServerError(
1093
+ headers=dict(_response.headers),
1094
+ body=typing.cast(
1095
+ typing.Optional[typing.Any],
1096
+ parse_obj_as(
1097
+ type_=typing.Optional[typing.Any], # type: ignore
1098
+ object_=_response.json(),
1099
+ ),
1100
+ ),
1101
+ )
1102
+ if _response.status_code == 503:
1103
+ raise ServiceUnavailableError(
1104
+ headers=dict(_response.headers),
1105
+ body=typing.cast(
1106
+ typing.Optional[typing.Any],
1107
+ parse_obj_as(
1108
+ type_=typing.Optional[typing.Any], # type: ignore
1109
+ object_=_response.json(),
1110
+ ),
1111
+ ),
1112
+ )
1113
+ _response_json = _response.json()
1114
+ except JSONDecodeError:
1115
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1116
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1117
+
1118
+ async def get_download_links(
1119
+ self,
1120
+ *,
1121
+ job_id: str,
1122
+ files: typing.Sequence[str],
1123
+ ptu_id: typing.Optional[int] = None,
1124
+ request_options: typing.Optional[RequestOptions] = None,
1125
+ ) -> AsyncHttpResponse[FilesDownloadResponse]:
1126
+ """
1127
+ Start a speech to text bulk job V1
1128
+
1129
+ Parameters
1130
+ ----------
1131
+ job_id : str
1132
+
1133
+ files : typing.Sequence[str]
1134
+
1135
+ ptu_id : typing.Optional[int]
1136
+
1137
+ request_options : typing.Optional[RequestOptions]
1138
+ Request-specific configuration.
1139
+
1140
+ Returns
1141
+ -------
1142
+ AsyncHttpResponse[FilesDownloadResponse]
1143
+ Successful Response
1144
+ """
1145
+ _response = await self._client_wrapper.httpx_client.request(
1146
+ "speech-to-text-translate/job/v1/download-files",
1147
+ base_url=self._client_wrapper.get_environment().base,
1148
+ method="POST",
1149
+ params={
1150
+ "ptu_id": ptu_id,
1151
+ },
1152
+ json={
1153
+ "job_id": job_id,
1154
+ "files": files,
1155
+ },
1156
+ headers={
1157
+ "content-type": "application/json",
1158
+ },
1159
+ request_options=request_options,
1160
+ omit=OMIT,
1161
+ )
1162
+ try:
1163
+ if 200 <= _response.status_code < 300:
1164
+ _data = typing.cast(
1165
+ FilesDownloadResponse,
1166
+ parse_obj_as(
1167
+ type_=FilesDownloadResponse, # type: ignore
1168
+ object_=_response.json(),
1169
+ ),
1170
+ )
1171
+ return AsyncHttpResponse(response=_response, data=_data)
1172
+ if _response.status_code == 400:
1173
+ raise BadRequestError(
1174
+ headers=dict(_response.headers),
1175
+ body=typing.cast(
1176
+ typing.Optional[typing.Any],
1177
+ parse_obj_as(
1178
+ type_=typing.Optional[typing.Any], # type: ignore
1179
+ object_=_response.json(),
1180
+ ),
1181
+ ),
1182
+ )
1183
+ if _response.status_code == 403:
1184
+ raise ForbiddenError(
1185
+ headers=dict(_response.headers),
1186
+ body=typing.cast(
1187
+ typing.Optional[typing.Any],
1188
+ parse_obj_as(
1189
+ type_=typing.Optional[typing.Any], # type: ignore
1190
+ object_=_response.json(),
1191
+ ),
1192
+ ),
1193
+ )
1194
+ if _response.status_code == 422:
1195
+ raise UnprocessableEntityError(
1196
+ headers=dict(_response.headers),
1197
+ body=typing.cast(
1198
+ typing.Optional[typing.Any],
1199
+ parse_obj_as(
1200
+ type_=typing.Optional[typing.Any], # type: ignore
1201
+ object_=_response.json(),
1202
+ ),
1203
+ ),
1204
+ )
1205
+ if _response.status_code == 429:
1206
+ raise TooManyRequestsError(
1207
+ headers=dict(_response.headers),
1208
+ body=typing.cast(
1209
+ typing.Optional[typing.Any],
1210
+ parse_obj_as(
1211
+ type_=typing.Optional[typing.Any], # type: ignore
1212
+ object_=_response.json(),
1213
+ ),
1214
+ ),
1215
+ )
1216
+ if _response.status_code == 500:
1217
+ raise InternalServerError(
1218
+ headers=dict(_response.headers),
1219
+ body=typing.cast(
1220
+ typing.Optional[typing.Any],
1221
+ parse_obj_as(
1222
+ type_=typing.Optional[typing.Any], # type: ignore
1223
+ object_=_response.json(),
1224
+ ),
1225
+ ),
1226
+ )
1227
+ if _response.status_code == 503:
1228
+ raise ServiceUnavailableError(
1229
+ headers=dict(_response.headers),
1230
+ body=typing.cast(
1231
+ typing.Optional[typing.Any],
1232
+ parse_obj_as(
1233
+ type_=typing.Optional[typing.Any], # type: ignore
1234
+ object_=_response.json(),
1235
+ ),
1236
+ ),
1237
+ )
1238
+ _response_json = _response.json()
1239
+ except JSONDecodeError:
1240
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1241
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)