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