@@ -26,14 +26,34 @@ pip install salad-cloud-transcription
26
26
27
27
``` python
28
28
from salad_cloud_transcription import SaladCloudTranscriptionSdk
29
+ from salad_cloud_transcription_sdk.models.transcription_engine import TranscriptionEngine
30
+ from salad_cloud_transcription_sdk.models.transcription_request import TranscriptionRequest
31
+ from salad_cloud_transcription_sdk.models.transcription_job_input import TranscriptionJobInput
29
32
30
33
# Initialize the SDK
31
34
sdk = SaladCloudTranscriptionSdk(api_key = " your_api_key" )
32
35
33
- # Transcribe an audio file
36
+ # Setup the request
37
+ request_object = TranscriptionRequest(
38
+ options = TranscriptionJobInput(
39
+ language_code = " en" ,
40
+ return_as_file = False ,
41
+ sentence_level_timestamps = True ,
42
+ word_level_timestamps = True ,
43
+ diarization = True ,
44
+ srt = True
45
+ ),
46
+ metadata = {" project" : " example_project" }
47
+ )
48
+
49
+ # Transcribe a video file using the Full Transcription engine
34
50
result = sdk.transcription_client.transcribe(
35
- " path/to/audio.mp3" ,
36
- auto_poll = True )
51
+ " path/to/video.mp4" ,
52
+ organization_name = " your_organization_name" ,
53
+ request = request_object,
54
+ engine = TranscriptionEngine.Full,
55
+ auto_poll = True
56
+ )
37
57
38
58
# Print the transcription
39
59
print (result.text)
@@ -59,6 +79,33 @@ If you need to set or update the API key after initializing the SDK, you can use
59
79
sdk.set_api_key(" YOUR_API_KEY" )
60
80
```
61
81
82
+ ## Transcription Engines
83
+ The SDK supports two transcription modes: ` Full ` and ` Lite ` . The desired mode can be specified via the ` engine ` parameter of the ` transcribe ` method. When omitted it defaults to ` Full ` .
84
+
85
+ When using the ` Lite ` engine, the request object has to specify explicit defaults for a few of the properties:
86
+
87
+ ``` python
88
+ request = TranscriptionRequest(
89
+ options = TranscriptionJobInput(
90
+ language_code = " en" ,
91
+ return_as_file = True ,
92
+ translate = " to_eng" ,
93
+ sentence_level_timestamps = True ,
94
+ word_level_timestamps = True ,
95
+ diarization = True ,
96
+ sentence_diarization = True ,
97
+ srt = True ,
98
+
99
+ # Adding required parameters with null/empty values
100
+ summarize = 0 ,
101
+ custom_vocabulary = " " ,
102
+ llm_translation = [],
103
+ srt_translation = [],
104
+ ),
105
+ metadata = {" test_id" : " integration_test" , " environment" : " testing" },
106
+ )
107
+ ```
108
+
62
109
## Sample Usage
63
110
64
111
### The * source* parameter
@@ -74,18 +121,35 @@ When a remote file is specified, that URL is passed as-is to the transcription e
74
121
75
122
``` python
76
123
from salad_cloud_transcription import SaladCloudTranscriptionSdk
124
+ from salad_cloud_transcription_sdk.models.transcription_engine import TranscriptionEngine
125
+ from salad_cloud_transcription_sdk.models.transcription_request import TranscriptionRequest
126
+ from salad_cloud_transcription_sdk.models.transcription_job_input import TranscriptionJobInput
77
127
78
128
# Initialize the SDK
79
129
sdk = SaladCloudTranscriptionSdk(api_key = " your_api_key" )
80
130
131
+ # Setup the request
132
+ request_object = TranscriptionRequest(
133
+ options = TranscriptionJobInput(
134
+ language_code = " en" ,
135
+ return_as_file = False ,
136
+ sentence_level_timestamps = True ,
137
+ word_level_timestamps = True ,
138
+ diarization = True ,
139
+ srt = True
140
+ ),
141
+ metadata = {" project" : " example_project" }
142
+ )
143
+
81
144
# Start a transcription job and wait for the result
82
- # When the job is processed, this function returns a InferenceEndpointJob
83
145
result = sdk.transcription_client.transcribe(
84
- source = " path/to/audio.mp3" ,
85
- auto_poll = True )
146
+ source = " path/to/audio.mp3" ,
147
+ organization_name = " your_organization_name" ,
148
+ request = request_object,
149
+ auto_poll = True
150
+ )
86
151
87
- # The output property of the InferenceEndpointJob is a either a TranscriptionJobFileOutput
88
- # or a TranscriptionJobOutput. You can print it to examine job results.
152
+ # Print the transcription job output
89
153
print (result.output)
90
154
```
91
155
@@ -97,13 +161,28 @@ from salad_cloud_transcription import SaladCloudTranscriptionSdk
97
161
# Initialize the SDK
98
162
sdk = SaladCloudTranscriptionSdk(api_key = " your_api_key" )
99
163
164
+ # Setup the request
165
+ request_object = TranscriptionRequest(
166
+ options = TranscriptionJobInput(
167
+ language_code = " en" ,
168
+ return_as_file = False ,
169
+ sentence_level_timestamps = True ,
170
+ word_level_timestamps = True ,
171
+ diarization = True ,
172
+ srt = True
173
+ ),
174
+ metadata = {" project" : " example_project" }
175
+ )
176
+
100
177
# Start a transcription job. auto_poll = False
101
- job = sdk.transcription_client.start_transcription_job(
102
- source = " path/to/audio.mp3" )
178
+ job = sdk.transcription_client.transcribe(
179
+ source = " path/to/audio.mp3" ,
180
+ request = request_object,
181
+ auto_poll = False )
103
182
104
183
# Poll for the job status
105
184
while True :
106
- job = self ._get_transcription_job_internal (organization_name, job.id_)
185
+ job = self .get_transcription_job (organization_name, job.id_)
107
186
if job.status in [
108
187
Status.SUCCEEDED .value,
109
188
Status.FAILED .value,
@@ -118,17 +197,31 @@ if job.status == Status.SUCCEEDED.value:
118
197
119
198
### Start a Transcription Job and Get Updates via a Webhook
120
199
121
- First, initialize a transcription job.
122
-
123
200
``` python
124
201
from salad_cloud_transcription import SaladCloudTranscriptionSdk
202
+ from salad_cloud_transcription_sdk.models.transcription_request import TranscriptionRequest
203
+ from salad_cloud_transcription_sdk.models.transcription_job_input import TranscriptionJobInput
125
204
126
205
# Initialize the SDK
127
206
sdk = SaladCloudTranscriptionSdk(api_key = " your_api_key" )
128
207
208
+ # Setup the request
209
+ request_object = TranscriptionRequest(
210
+ options = TranscriptionJobInput(
211
+ language_code = " en" ,
212
+ return_as_file = False ,
213
+ sentence_level_timestamps = True ,
214
+ word_level_timestamps = True ,
215
+ diarization = True ,
216
+ srt = True
217
+ ),
218
+ metadata = {" project" : " example_project" }
219
+ )
220
+
129
221
# Start a transcription job with a webhook URL
130
- job = sdk.transcription_client.start_transcription_job(
131
- source = " path/to/audio.mp3" ,
222
+ job = sdk.transcription_client.transcribe(
223
+ source = " path/to/audio.mp3" ,
224
+ request = request_object,
132
225
webhook_url = " https://your-webhook-endpoint.com"
133
226
)
134
227
0 commit comments