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.
- sarvamai/__init__.py +62 -4
- sarvamai/client.py +6 -0
- sarvamai/core/client_wrapper.py +2 -2
- sarvamai/errors/service_unavailable_error.py +1 -2
- sarvamai/requests/__init__.py +24 -0
- sarvamai/requests/base_job_parameters.py +7 -0
- sarvamai/requests/bulk_job_callback.py +15 -0
- sarvamai/requests/bulk_job_init_response_v_1.py +27 -0
- sarvamai/requests/configure_connection_data.py +2 -3
- sarvamai/requests/file_signed_url_details.py +10 -0
- sarvamai/requests/files_download_response.py +15 -0
- sarvamai/requests/files_request.py +10 -0
- sarvamai/requests/files_upload_response.py +15 -0
- sarvamai/requests/job_status_v_1.py +70 -0
- sarvamai/requests/speech_to_text_job_parameters.py +32 -0
- sarvamai/requests/speech_to_text_translate_job_parameters.py +28 -0
- sarvamai/requests/task_detail_v_1.py +15 -0
- sarvamai/requests/task_file_details.py +8 -0
- sarvamai/speech_to_text/raw_client.py +8 -9
- sarvamai/speech_to_text_job/__init__.py +4 -0
- sarvamai/speech_to_text_job/client.py +633 -0
- sarvamai/speech_to_text_job/job.py +472 -0
- sarvamai/speech_to_text_job/raw_client.py +1189 -0
- sarvamai/speech_to_text_translate_job/__init__.py +4 -0
- sarvamai/speech_to_text_translate_job/client.py +651 -0
- sarvamai/speech_to_text_translate_job/job.py +479 -0
- sarvamai/speech_to_text_translate_job/raw_client.py +1241 -0
- sarvamai/text_to_speech/client.py +7 -7
- sarvamai/text_to_speech/raw_client.py +7 -7
- sarvamai/types/__init__.py +34 -4
- sarvamai/types/base_job_parameters.py +17 -0
- sarvamai/types/bulk_job_callback.py +27 -0
- sarvamai/types/bulk_job_init_response_v_1.py +39 -0
- sarvamai/types/configure_connection_data.py +2 -1
- sarvamai/types/configure_connection_data_output_audio_codec.py +7 -0
- sarvamai/types/file_signed_url_details.py +20 -0
- sarvamai/types/files_download_response.py +25 -0
- sarvamai/types/files_request.py +20 -0
- sarvamai/types/files_upload_response.py +25 -0
- sarvamai/types/job_state.py +5 -0
- sarvamai/types/job_status_v_1.py +80 -0
- sarvamai/types/speech_to_text_job_parameters.py +44 -0
- sarvamai/types/speech_to_text_translate_job_parameters.py +40 -0
- sarvamai/types/storage_container_type.py +5 -0
- sarvamai/types/task_detail_v_1.py +25 -0
- sarvamai/types/task_file_details.py +20 -0
- sarvamai/types/task_state.py +5 -0
- sarvamai/types/text_to_speech_output_audio_codec.py +7 -0
- {sarvamai-0.1.10.dist-info → sarvamai-0.1.11.dist-info}/METADATA +1 -1
- {sarvamai-0.1.10.dist-info → sarvamai-0.1.11.dist-info}/RECORD +51 -16
- sarvamai/types/audio_codec.py +0 -5
- sarvamai/types/format.py +0 -5
- {sarvamai-0.1.10.dist-info → sarvamai-0.1.11.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,651 @@
|
|
|
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_translate_job_parameters import (
|
|
9
|
+
SpeechToTextTranslateJobParametersParams,
|
|
10
|
+
)
|
|
11
|
+
from ..types.bulk_job_init_response_v_1 import BulkJobInitResponseV1
|
|
12
|
+
from ..types.files_download_response import FilesDownloadResponse
|
|
13
|
+
from ..types.files_upload_response import FilesUploadResponse
|
|
14
|
+
from ..types.job_status_v_1 import JobStatusV1
|
|
15
|
+
from ..types.speech_to_text_translate_model import SpeechToTextTranslateModel
|
|
16
|
+
from .job import AsyncSpeechToTextTranslateJob, SpeechToTextTranslateJob
|
|
17
|
+
from .raw_client import (
|
|
18
|
+
AsyncRawSpeechToTextTranslateJobClient,
|
|
19
|
+
RawSpeechToTextTranslateJobClient,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
# this is used as the default value for optional parameters
|
|
23
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class SpeechToTextTranslateJobClient:
|
|
27
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
28
|
+
self._raw_client = RawSpeechToTextTranslateJobClient(
|
|
29
|
+
client_wrapper=client_wrapper
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def with_raw_response(self) -> RawSpeechToTextTranslateJobClient:
|
|
34
|
+
"""
|
|
35
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
36
|
+
|
|
37
|
+
Returns
|
|
38
|
+
-------
|
|
39
|
+
RawSpeechToTextTranslateJobClient
|
|
40
|
+
"""
|
|
41
|
+
return self._raw_client
|
|
42
|
+
|
|
43
|
+
def initialise(
|
|
44
|
+
self,
|
|
45
|
+
*,
|
|
46
|
+
job_parameters: SpeechToTextTranslateJobParametersParams,
|
|
47
|
+
ptu_id: typing.Optional[int] = None,
|
|
48
|
+
callback: typing.Optional[BulkJobCallbackParams] = OMIT,
|
|
49
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
50
|
+
) -> BulkJobInitResponseV1:
|
|
51
|
+
"""
|
|
52
|
+
Get a job uuid, and storage folder details for speech to text tranlsate bulk job v1
|
|
53
|
+
|
|
54
|
+
Parameters
|
|
55
|
+
----------
|
|
56
|
+
job_parameters : SpeechToTextTranslateJobParametersParams
|
|
57
|
+
Job Parameters for the bulk job
|
|
58
|
+
|
|
59
|
+
ptu_id : typing.Optional[int]
|
|
60
|
+
|
|
61
|
+
callback : typing.Optional[BulkJobCallbackParams]
|
|
62
|
+
Parameters for callback URL
|
|
63
|
+
|
|
64
|
+
request_options : typing.Optional[RequestOptions]
|
|
65
|
+
Request-specific configuration.
|
|
66
|
+
|
|
67
|
+
Returns
|
|
68
|
+
-------
|
|
69
|
+
BulkJobInitResponseV1
|
|
70
|
+
Successful Response
|
|
71
|
+
|
|
72
|
+
Examples
|
|
73
|
+
--------
|
|
74
|
+
from sarvamai import SarvamAI
|
|
75
|
+
|
|
76
|
+
client = SarvamAI(
|
|
77
|
+
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
|
|
78
|
+
)
|
|
79
|
+
client.speech_to_text_translate_job.initialise(
|
|
80
|
+
job_parameters={},
|
|
81
|
+
)
|
|
82
|
+
"""
|
|
83
|
+
_response = self._raw_client.initialise(
|
|
84
|
+
job_parameters=job_parameters,
|
|
85
|
+
ptu_id=ptu_id,
|
|
86
|
+
callback=callback,
|
|
87
|
+
request_options=request_options,
|
|
88
|
+
)
|
|
89
|
+
return _response.data
|
|
90
|
+
|
|
91
|
+
def get_status(
|
|
92
|
+
self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
93
|
+
) -> JobStatusV1:
|
|
94
|
+
"""
|
|
95
|
+
Get the status of a speech to text translate bulk job V1
|
|
96
|
+
|
|
97
|
+
Parameters
|
|
98
|
+
----------
|
|
99
|
+
job_id : str
|
|
100
|
+
The unique identifier of the job
|
|
101
|
+
|
|
102
|
+
request_options : typing.Optional[RequestOptions]
|
|
103
|
+
Request-specific configuration.
|
|
104
|
+
|
|
105
|
+
Returns
|
|
106
|
+
-------
|
|
107
|
+
JobStatusV1
|
|
108
|
+
Successful Response
|
|
109
|
+
|
|
110
|
+
Examples
|
|
111
|
+
--------
|
|
112
|
+
from sarvamai import SarvamAI
|
|
113
|
+
|
|
114
|
+
client = SarvamAI(
|
|
115
|
+
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
|
|
116
|
+
)
|
|
117
|
+
client.speech_to_text_translate_job.get_status(
|
|
118
|
+
job_id="job_id",
|
|
119
|
+
)
|
|
120
|
+
"""
|
|
121
|
+
_response = self._raw_client.get_status(job_id, request_options=request_options)
|
|
122
|
+
return _response.data
|
|
123
|
+
|
|
124
|
+
def start(
|
|
125
|
+
self,
|
|
126
|
+
job_id: str,
|
|
127
|
+
*,
|
|
128
|
+
ptu_id: typing.Optional[int] = None,
|
|
129
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
130
|
+
) -> JobStatusV1:
|
|
131
|
+
"""
|
|
132
|
+
Start a speech to text translate bulk job V1
|
|
133
|
+
|
|
134
|
+
Parameters
|
|
135
|
+
----------
|
|
136
|
+
job_id : str
|
|
137
|
+
The unique identifier of the job
|
|
138
|
+
|
|
139
|
+
ptu_id : typing.Optional[int]
|
|
140
|
+
|
|
141
|
+
request_options : typing.Optional[RequestOptions]
|
|
142
|
+
Request-specific configuration.
|
|
143
|
+
|
|
144
|
+
Returns
|
|
145
|
+
-------
|
|
146
|
+
JobStatusV1
|
|
147
|
+
Successful Response
|
|
148
|
+
|
|
149
|
+
Examples
|
|
150
|
+
--------
|
|
151
|
+
from sarvamai import SarvamAI
|
|
152
|
+
|
|
153
|
+
client = SarvamAI(
|
|
154
|
+
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
|
|
155
|
+
)
|
|
156
|
+
client.speech_to_text_translate_job.start(
|
|
157
|
+
job_id="job_id",
|
|
158
|
+
)
|
|
159
|
+
"""
|
|
160
|
+
_response = self._raw_client.start(
|
|
161
|
+
job_id, ptu_id=ptu_id, request_options=request_options
|
|
162
|
+
)
|
|
163
|
+
return _response.data
|
|
164
|
+
|
|
165
|
+
def get_upload_links(
|
|
166
|
+
self,
|
|
167
|
+
*,
|
|
168
|
+
job_id: str,
|
|
169
|
+
files: typing.Sequence[str],
|
|
170
|
+
ptu_id: typing.Optional[int] = None,
|
|
171
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
172
|
+
) -> FilesUploadResponse:
|
|
173
|
+
"""
|
|
174
|
+
Start a speech to text bulk job V1
|
|
175
|
+
|
|
176
|
+
Parameters
|
|
177
|
+
----------
|
|
178
|
+
job_id : str
|
|
179
|
+
|
|
180
|
+
files : typing.Sequence[str]
|
|
181
|
+
|
|
182
|
+
ptu_id : typing.Optional[int]
|
|
183
|
+
|
|
184
|
+
request_options : typing.Optional[RequestOptions]
|
|
185
|
+
Request-specific configuration.
|
|
186
|
+
|
|
187
|
+
Returns
|
|
188
|
+
-------
|
|
189
|
+
FilesUploadResponse
|
|
190
|
+
Successful Response
|
|
191
|
+
|
|
192
|
+
Examples
|
|
193
|
+
--------
|
|
194
|
+
from sarvamai import SarvamAI
|
|
195
|
+
|
|
196
|
+
client = SarvamAI(
|
|
197
|
+
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
|
|
198
|
+
)
|
|
199
|
+
client.speech_to_text_translate_job.get_upload_links(
|
|
200
|
+
job_id="job_id",
|
|
201
|
+
files=["files"],
|
|
202
|
+
)
|
|
203
|
+
"""
|
|
204
|
+
_response = self._raw_client.get_upload_links(
|
|
205
|
+
job_id=job_id, files=files, ptu_id=ptu_id, request_options=request_options
|
|
206
|
+
)
|
|
207
|
+
return _response.data
|
|
208
|
+
|
|
209
|
+
def get_download_links(
|
|
210
|
+
self,
|
|
211
|
+
*,
|
|
212
|
+
job_id: str,
|
|
213
|
+
files: typing.Sequence[str],
|
|
214
|
+
ptu_id: typing.Optional[int] = None,
|
|
215
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
216
|
+
) -> FilesDownloadResponse:
|
|
217
|
+
"""
|
|
218
|
+
Start a speech to text bulk job V1
|
|
219
|
+
|
|
220
|
+
Parameters
|
|
221
|
+
----------
|
|
222
|
+
job_id : str
|
|
223
|
+
|
|
224
|
+
files : typing.Sequence[str]
|
|
225
|
+
|
|
226
|
+
ptu_id : typing.Optional[int]
|
|
227
|
+
|
|
228
|
+
request_options : typing.Optional[RequestOptions]
|
|
229
|
+
Request-specific configuration.
|
|
230
|
+
|
|
231
|
+
Returns
|
|
232
|
+
-------
|
|
233
|
+
FilesDownloadResponse
|
|
234
|
+
Successful Response
|
|
235
|
+
|
|
236
|
+
Examples
|
|
237
|
+
--------
|
|
238
|
+
from sarvamai import SarvamAI
|
|
239
|
+
|
|
240
|
+
client = SarvamAI(
|
|
241
|
+
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
|
|
242
|
+
)
|
|
243
|
+
client.speech_to_text_translate_job.get_download_links(
|
|
244
|
+
job_id="job_id",
|
|
245
|
+
files=["files"],
|
|
246
|
+
)
|
|
247
|
+
"""
|
|
248
|
+
_response = self._raw_client.get_download_links(
|
|
249
|
+
job_id=job_id, files=files, ptu_id=ptu_id, request_options=request_options
|
|
250
|
+
)
|
|
251
|
+
return _response.data
|
|
252
|
+
|
|
253
|
+
def create_job(
|
|
254
|
+
self,
|
|
255
|
+
model: SpeechToTextTranslateModel = "saaras:v2.5",
|
|
256
|
+
with_diarization: bool = False,
|
|
257
|
+
prompt: typing.Optional[str] = None,
|
|
258
|
+
num_speakers: typing.Optional[int] = None,
|
|
259
|
+
callback: typing.Optional[BulkJobCallbackParams] = OMIT,
|
|
260
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
261
|
+
) -> SpeechToTextTranslateJob:
|
|
262
|
+
"""
|
|
263
|
+
Create a new Speech-to-Text-Translate bulk job.
|
|
264
|
+
|
|
265
|
+
Parameters
|
|
266
|
+
----------
|
|
267
|
+
model : typing.Optional[SpeechToTextTranslateModel], default="saaras:v2.5"
|
|
268
|
+
The model to use for speech-to-text translation.
|
|
269
|
+
|
|
270
|
+
with_diarization : typing.Optional[bool], default=False
|
|
271
|
+
Whether to enable speaker diarization (i.e., distinguishing who is speaking).
|
|
272
|
+
|
|
273
|
+
prompt : typing.Optional[str], default=None
|
|
274
|
+
An optional prompt to guide the transcription and translation model.
|
|
275
|
+
|
|
276
|
+
num_speakers : typing.Optional[int], default=None
|
|
277
|
+
The number of distinct speakers in the input audio, if known.
|
|
278
|
+
|
|
279
|
+
callback : typing.Optional[BulkJobCallbackParams], default=OMIT
|
|
280
|
+
Optional callback configuration to receive job completion events via webhook.
|
|
281
|
+
|
|
282
|
+
request_options : typing.Optional[RequestOptions], default=None
|
|
283
|
+
Optional configuration for request timeout, retries, etc.
|
|
284
|
+
|
|
285
|
+
Returns
|
|
286
|
+
-------
|
|
287
|
+
SpeechToTextTranslateJob
|
|
288
|
+
A handle to the newly created Speech-to-Text-Translate job.
|
|
289
|
+
"""
|
|
290
|
+
response = self.initialise(
|
|
291
|
+
job_parameters=SpeechToTextTranslateJobParametersParams(
|
|
292
|
+
prompt=prompt, # type: ignore[typeddict-item]
|
|
293
|
+
model=model,
|
|
294
|
+
with_diarization=with_diarization,
|
|
295
|
+
num_speakers=num_speakers, # type: ignore[typeddict-item]
|
|
296
|
+
),
|
|
297
|
+
callback=callback,
|
|
298
|
+
request_options=request_options,
|
|
299
|
+
)
|
|
300
|
+
return SpeechToTextTranslateJob(job_id=response.job_id, client=self)
|
|
301
|
+
|
|
302
|
+
def get_job(self, job_id: str) -> SpeechToTextTranslateJob:
|
|
303
|
+
"""
|
|
304
|
+
Get an existing Speech-to-Text-Translate job handle by job ID.
|
|
305
|
+
|
|
306
|
+
Parameters
|
|
307
|
+
----------
|
|
308
|
+
job_id : str
|
|
309
|
+
The job ID of the previously created Speech-to-Text-Translate job.
|
|
310
|
+
|
|
311
|
+
Returns
|
|
312
|
+
-------
|
|
313
|
+
SpeechToTextTranslateJob
|
|
314
|
+
A job handle which can be used to check status or retrieve results.
|
|
315
|
+
"""
|
|
316
|
+
return SpeechToTextTranslateJob(job_id=job_id, client=self)
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
class AsyncSpeechToTextTranslateJobClient:
|
|
320
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
321
|
+
self._raw_client = AsyncRawSpeechToTextTranslateJobClient(
|
|
322
|
+
client_wrapper=client_wrapper
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
@property
|
|
326
|
+
def with_raw_response(self) -> AsyncRawSpeechToTextTranslateJobClient:
|
|
327
|
+
"""
|
|
328
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
329
|
+
|
|
330
|
+
Returns
|
|
331
|
+
-------
|
|
332
|
+
AsyncRawSpeechToTextTranslateJobClient
|
|
333
|
+
"""
|
|
334
|
+
return self._raw_client
|
|
335
|
+
|
|
336
|
+
async def initialise(
|
|
337
|
+
self,
|
|
338
|
+
*,
|
|
339
|
+
job_parameters: SpeechToTextTranslateJobParametersParams,
|
|
340
|
+
ptu_id: typing.Optional[int] = None,
|
|
341
|
+
callback: typing.Optional[BulkJobCallbackParams] = OMIT,
|
|
342
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
343
|
+
) -> BulkJobInitResponseV1:
|
|
344
|
+
"""
|
|
345
|
+
Get a job uuid, and storage folder details for speech to text tranlsate bulk job v1
|
|
346
|
+
|
|
347
|
+
Parameters
|
|
348
|
+
----------
|
|
349
|
+
job_parameters : SpeechToTextTranslateJobParametersParams
|
|
350
|
+
Job Parameters for the bulk job
|
|
351
|
+
|
|
352
|
+
ptu_id : typing.Optional[int]
|
|
353
|
+
|
|
354
|
+
callback : typing.Optional[BulkJobCallbackParams]
|
|
355
|
+
Parameters for callback URL
|
|
356
|
+
|
|
357
|
+
request_options : typing.Optional[RequestOptions]
|
|
358
|
+
Request-specific configuration.
|
|
359
|
+
|
|
360
|
+
Returns
|
|
361
|
+
-------
|
|
362
|
+
BulkJobInitResponseV1
|
|
363
|
+
Successful Response
|
|
364
|
+
|
|
365
|
+
Examples
|
|
366
|
+
--------
|
|
367
|
+
import asyncio
|
|
368
|
+
|
|
369
|
+
from sarvamai import AsyncSarvamAI
|
|
370
|
+
|
|
371
|
+
client = AsyncSarvamAI(
|
|
372
|
+
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
async def main() -> None:
|
|
377
|
+
await client.speech_to_text_translate_job.initialise(
|
|
378
|
+
job_parameters={},
|
|
379
|
+
)
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
asyncio.run(main())
|
|
383
|
+
"""
|
|
384
|
+
_response = await self._raw_client.initialise(
|
|
385
|
+
job_parameters=job_parameters,
|
|
386
|
+
ptu_id=ptu_id,
|
|
387
|
+
callback=callback,
|
|
388
|
+
request_options=request_options,
|
|
389
|
+
)
|
|
390
|
+
return _response.data
|
|
391
|
+
|
|
392
|
+
async def get_status(
|
|
393
|
+
self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
394
|
+
) -> JobStatusV1:
|
|
395
|
+
"""
|
|
396
|
+
Get the status of a speech to text translate bulk job V1
|
|
397
|
+
|
|
398
|
+
Parameters
|
|
399
|
+
----------
|
|
400
|
+
job_id : str
|
|
401
|
+
The unique identifier of the job
|
|
402
|
+
|
|
403
|
+
request_options : typing.Optional[RequestOptions]
|
|
404
|
+
Request-specific configuration.
|
|
405
|
+
|
|
406
|
+
Returns
|
|
407
|
+
-------
|
|
408
|
+
JobStatusV1
|
|
409
|
+
Successful Response
|
|
410
|
+
|
|
411
|
+
Examples
|
|
412
|
+
--------
|
|
413
|
+
import asyncio
|
|
414
|
+
|
|
415
|
+
from sarvamai import AsyncSarvamAI
|
|
416
|
+
|
|
417
|
+
client = AsyncSarvamAI(
|
|
418
|
+
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
|
|
419
|
+
)
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
async def main() -> None:
|
|
423
|
+
await client.speech_to_text_translate_job.get_status(
|
|
424
|
+
job_id="job_id",
|
|
425
|
+
)
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
asyncio.run(main())
|
|
429
|
+
"""
|
|
430
|
+
_response = await self._raw_client.get_status(
|
|
431
|
+
job_id, request_options=request_options
|
|
432
|
+
)
|
|
433
|
+
return _response.data
|
|
434
|
+
|
|
435
|
+
async def start(
|
|
436
|
+
self,
|
|
437
|
+
job_id: str,
|
|
438
|
+
*,
|
|
439
|
+
ptu_id: typing.Optional[int] = None,
|
|
440
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
441
|
+
) -> JobStatusV1:
|
|
442
|
+
"""
|
|
443
|
+
Start a speech to text translate bulk job V1
|
|
444
|
+
|
|
445
|
+
Parameters
|
|
446
|
+
----------
|
|
447
|
+
job_id : str
|
|
448
|
+
The unique identifier of the job
|
|
449
|
+
|
|
450
|
+
ptu_id : typing.Optional[int]
|
|
451
|
+
|
|
452
|
+
request_options : typing.Optional[RequestOptions]
|
|
453
|
+
Request-specific configuration.
|
|
454
|
+
|
|
455
|
+
Returns
|
|
456
|
+
-------
|
|
457
|
+
JobStatusV1
|
|
458
|
+
Successful Response
|
|
459
|
+
|
|
460
|
+
Examples
|
|
461
|
+
--------
|
|
462
|
+
import asyncio
|
|
463
|
+
|
|
464
|
+
from sarvamai import AsyncSarvamAI
|
|
465
|
+
|
|
466
|
+
client = AsyncSarvamAI(
|
|
467
|
+
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
|
|
468
|
+
)
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
async def main() -> None:
|
|
472
|
+
await client.speech_to_text_translate_job.start(
|
|
473
|
+
job_id="job_id",
|
|
474
|
+
)
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
asyncio.run(main())
|
|
478
|
+
"""
|
|
479
|
+
_response = await self._raw_client.start(
|
|
480
|
+
job_id, ptu_id=ptu_id, request_options=request_options
|
|
481
|
+
)
|
|
482
|
+
return _response.data
|
|
483
|
+
|
|
484
|
+
async def get_upload_links(
|
|
485
|
+
self,
|
|
486
|
+
*,
|
|
487
|
+
job_id: str,
|
|
488
|
+
files: typing.Sequence[str],
|
|
489
|
+
ptu_id: typing.Optional[int] = None,
|
|
490
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
491
|
+
) -> FilesUploadResponse:
|
|
492
|
+
"""
|
|
493
|
+
Start a speech to text bulk job V1
|
|
494
|
+
|
|
495
|
+
Parameters
|
|
496
|
+
----------
|
|
497
|
+
job_id : str
|
|
498
|
+
|
|
499
|
+
files : typing.Sequence[str]
|
|
500
|
+
|
|
501
|
+
ptu_id : typing.Optional[int]
|
|
502
|
+
|
|
503
|
+
request_options : typing.Optional[RequestOptions]
|
|
504
|
+
Request-specific configuration.
|
|
505
|
+
|
|
506
|
+
Returns
|
|
507
|
+
-------
|
|
508
|
+
FilesUploadResponse
|
|
509
|
+
Successful Response
|
|
510
|
+
|
|
511
|
+
Examples
|
|
512
|
+
--------
|
|
513
|
+
import asyncio
|
|
514
|
+
|
|
515
|
+
from sarvamai import AsyncSarvamAI
|
|
516
|
+
|
|
517
|
+
client = AsyncSarvamAI(
|
|
518
|
+
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
|
|
519
|
+
)
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
async def main() -> None:
|
|
523
|
+
await client.speech_to_text_translate_job.get_upload_links(
|
|
524
|
+
job_id="job_id",
|
|
525
|
+
files=["files"],
|
|
526
|
+
)
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
asyncio.run(main())
|
|
530
|
+
"""
|
|
531
|
+
_response = await self._raw_client.get_upload_links(
|
|
532
|
+
job_id=job_id, files=files, ptu_id=ptu_id, request_options=request_options
|
|
533
|
+
)
|
|
534
|
+
return _response.data
|
|
535
|
+
|
|
536
|
+
async def get_download_links(
|
|
537
|
+
self,
|
|
538
|
+
*,
|
|
539
|
+
job_id: str,
|
|
540
|
+
files: typing.Sequence[str],
|
|
541
|
+
ptu_id: typing.Optional[int] = None,
|
|
542
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
543
|
+
) -> FilesDownloadResponse:
|
|
544
|
+
"""
|
|
545
|
+
Start a speech to text bulk job V1
|
|
546
|
+
|
|
547
|
+
Parameters
|
|
548
|
+
----------
|
|
549
|
+
job_id : str
|
|
550
|
+
|
|
551
|
+
files : typing.Sequence[str]
|
|
552
|
+
|
|
553
|
+
ptu_id : typing.Optional[int]
|
|
554
|
+
|
|
555
|
+
request_options : typing.Optional[RequestOptions]
|
|
556
|
+
Request-specific configuration.
|
|
557
|
+
|
|
558
|
+
Returns
|
|
559
|
+
-------
|
|
560
|
+
FilesDownloadResponse
|
|
561
|
+
Successful Response
|
|
562
|
+
|
|
563
|
+
Examples
|
|
564
|
+
--------
|
|
565
|
+
import asyncio
|
|
566
|
+
|
|
567
|
+
from sarvamai import AsyncSarvamAI
|
|
568
|
+
|
|
569
|
+
client = AsyncSarvamAI(
|
|
570
|
+
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
|
|
571
|
+
)
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
async def main() -> None:
|
|
575
|
+
await client.speech_to_text_translate_job.get_download_links(
|
|
576
|
+
job_id="job_id",
|
|
577
|
+
files=["files"],
|
|
578
|
+
)
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
asyncio.run(main())
|
|
582
|
+
"""
|
|
583
|
+
_response = await self._raw_client.get_download_links(
|
|
584
|
+
job_id=job_id, files=files, ptu_id=ptu_id, request_options=request_options
|
|
585
|
+
)
|
|
586
|
+
return _response.data
|
|
587
|
+
|
|
588
|
+
async def create_job(
|
|
589
|
+
self,
|
|
590
|
+
model: SpeechToTextTranslateModel = "saaras:v2.5",
|
|
591
|
+
with_diarization: bool = False,
|
|
592
|
+
prompt: typing.Optional[str] = None,
|
|
593
|
+
num_speakers: typing.Optional[int] = None,
|
|
594
|
+
callback: typing.Optional[BulkJobCallbackParams] = OMIT,
|
|
595
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
596
|
+
) -> "AsyncSpeechToTextTranslateJob":
|
|
597
|
+
"""
|
|
598
|
+
Create a new Speech-to-Text-Translate bulk job.
|
|
599
|
+
|
|
600
|
+
Parameters
|
|
601
|
+
----------
|
|
602
|
+
model : typing.Optional[SpeechToTextTranslateModel], default="saaras:v2.5"
|
|
603
|
+
The model to use for speech-to-text translation.
|
|
604
|
+
|
|
605
|
+
with_diarization : typing.Optional[bool], default=False
|
|
606
|
+
Whether to enable speaker diarization (i.e., distinguishing who is speaking).
|
|
607
|
+
|
|
608
|
+
prompt : typing.Optional[str], default=None
|
|
609
|
+
An optional prompt to guide the transcription and translation model.
|
|
610
|
+
|
|
611
|
+
num_speakers : typing.Optional[int], default=None
|
|
612
|
+
The number of distinct speakers in the input audio, if known.
|
|
613
|
+
|
|
614
|
+
callback : typing.Optional[BulkJobCallbackParams], default=OMIT
|
|
615
|
+
Optional callback configuration to receive job completion events via webhook.
|
|
616
|
+
|
|
617
|
+
request_options : typing.Optional[RequestOptions], default=None
|
|
618
|
+
Optional configuration for request timeout, retries, etc.
|
|
619
|
+
|
|
620
|
+
Returns
|
|
621
|
+
-------
|
|
622
|
+
AsyncSpeechToTextTranslateJob
|
|
623
|
+
A handle to the newly created job.
|
|
624
|
+
"""
|
|
625
|
+
response = await self.initialise(
|
|
626
|
+
job_parameters=SpeechToTextTranslateJobParametersParams(
|
|
627
|
+
prompt=prompt, # type: ignore[typeddict-item]
|
|
628
|
+
model=model,
|
|
629
|
+
with_diarization=with_diarization, # type: ignore[typeddict-item]
|
|
630
|
+
num_speakers=num_speakers, # type: ignore[typeddict-item]
|
|
631
|
+
),
|
|
632
|
+
callback=callback,
|
|
633
|
+
request_options=request_options,
|
|
634
|
+
)
|
|
635
|
+
return AsyncSpeechToTextTranslateJob(job_id=response.job_id, client=self)
|
|
636
|
+
|
|
637
|
+
async def get_job(self, job_id: str) -> "AsyncSpeechToTextTranslateJob":
|
|
638
|
+
"""
|
|
639
|
+
Get an existing Speech-to-Text-Translate job handle by job ID.
|
|
640
|
+
|
|
641
|
+
Parameters
|
|
642
|
+
----------
|
|
643
|
+
job_id : str
|
|
644
|
+
The job ID of the previously created speech-to-text-translate job.
|
|
645
|
+
|
|
646
|
+
Returns
|
|
647
|
+
-------
|
|
648
|
+
AsyncSpeechToTextTranslateJob
|
|
649
|
+
A job handle which can be used to check status or retrieve results.
|
|
650
|
+
"""
|
|
651
|
+
return AsyncSpeechToTextTranslateJob(job_id=job_id, client=self)
|