@@ -4,12 +4,11 @@ Welcome to the SaladCloud Transcription SDK documentation. This guide will help
4
4
5
5
## Versions
6
6
7
- - API version: ` 0.9.0-alpha.8 `
8
7
- SDK version: ` 0.9.0-alpha.1 `
9
8
10
9
## About the API
11
10
12
- The SaladCloud REST API. Please refer to the [ SaladCloud API Documentation] ( https://docs.salad.com/api- reference ) for more details.
11
+ The Transcription REST API. Please refer to the [ Transcription API Documentation] ( https://docs.salad.com/reference/transcribe/inference_endpoints/create-an-inference-endpoint-job ) for more details.
13
12
14
13
## Installation
15
14
@@ -23,6 +22,22 @@ npm install @saladtechnologies-oss/salad-cloud-transcription-sdk
23
22
yarn add @saladtechnologies-oss/salad-cloud-transcription-sdk
24
23
```
25
24
25
+ ## Table of Contents
26
+
27
+ - [ Authentication] ( #authentication )
28
+ - [ Setting the API key] ( #transcribe )
29
+ - [ Setting a Custom Timeout] ( #get )
30
+ - [ Sample Usage] ( #sample-usage )
31
+ - [ Features and Methods] ( #features-and-methods )
32
+ - [ Transcribe] ( #transcribe )
33
+ - [ Transcribe and Get Updates via a Webhook] ( #transcribe-and-get-updates-via-a-webhook )
34
+ - [ Get] ( #get )
35
+ - [ Stop] ( #stop )
36
+ - [ List] ( #list )
37
+ - [ WaitFor] ( #waitfor )
38
+ - [ Error Handling] ( #error-handling )
39
+ - [ License] ( #license )
40
+
26
41
## Authentication
27
42
28
43
### API Key Authentication
@@ -45,24 +60,184 @@ You can set a custom timeout for the SDK's HTTP requests as follows:
45
60
const sdk = new SaladCloudTranscriptionSdk ({ timeout: 10000 })
46
61
```
47
62
48
- # Sample Usage
63
+ ## Sample Usage
49
64
50
65
Below is a comprehensive example demonstrating how to authenticate and transcribe:
51
66
52
67
``` ts
53
- import { SaladCloudTranscriptionSdk } from ' @saladtechnologies-oss/salad-cloud-transcription-sdk' ;
68
+ import { SaladCloudTranscriptionSdk } from ' @saladtechnologies-oss/salad-cloud-transcription-sdk'
69
+
70
+ const organizationName = ' organization_name'
71
+ const file = ' file_to_path_or_url'
72
+
73
+ const sdk = new SaladCloudTranscriptionSdk ({ apiKey: ' YOUR_API_KEY' })
74
+
75
+ const transcribe = async (): Promise <string > => {
76
+ const { id } = await sdk .transcribe (organizationName , file )
77
+ return id
78
+ }
79
+
80
+ ;(async () => {
81
+ try {
82
+ await transcribe ()
83
+ } catch (error ) {
84
+ console .error (error )
85
+ }
86
+ })()
87
+ ```
88
+
89
+ ## Features and Methods
90
+
91
+ The SDK exposes several key methods:
92
+
93
+ ### Transcribe
94
+
95
+ Transcribes a file or remote source. If a local file is provided, it is uploaded before transcription.
96
+
97
+ ``` ts
98
+ import { SaladCloudTranscriptionSdk } from ' @saladtechnologies-oss/salad-cloud-transcription-sdk'
99
+
100
+ const sdk = new SaladCloudTranscriptionSdk ({
101
+ apiKey: ' YOUR_API_KEY' ,
102
+ })
103
+
104
+ const controller = new AbortController ()
105
+ const signal = controller .signal
106
+
107
+ const transcribe = await sdk .transcribe (
108
+ ' organization_name' , // organization name
109
+ ' path_to_file_or_url/video.mp4' , // local file or a remote URL
110
+ { language: ' en-US' }, // optional transcription options
111
+ ' https://your-webhook-endpoint.com' , // optional webhook URL for callbacks
112
+ signal , // optional AbortSignal to cancel the operation
113
+ )
114
+ ```
54
115
55
- (async () => {
56
- const sdk = new SaladCloudTranscriptionSdk ({
116
+ ### Transcribe and Get Updates via a Webhook
117
+
118
+ Transcribes a file or remote source via a Webhook.
119
+
120
+ ``` ts
121
+ import { SaladCloudTranscriptionSdk } from ' @saladtechnologies-oss/salad-cloud-transcription-sdk'
122
+
123
+ const sdk = new SaladCloudTranscriptionSdk ({
124
+ apiKey: ' YOUR_API_KEY' ,
125
+ })
126
+
127
+ const controller = new AbortController ()
128
+ const signal = controller .signal
129
+
130
+ const transcribe = await sdk .transcribe (
131
+ ' organization_name' ,
132
+ ' path_to_file_or_url/video.mp4' ,
133
+ { language: ' en-US' },
134
+ ' https://your-webhook-endpoint.com' ,
135
+ signal ,
136
+ )
137
+ ```
138
+
139
+ ``` ts
140
+ import { SaladCloudSdk } from ' @saladtechnologies-oss/salad-cloud-sdk'
141
+ import { SaladCloudTranscriptionSdk } from ' @saladtechnologies-oss/salad-cloud-transcription-sdk'
142
+
143
+ // In your webhook handler you need to validate the payload being sent to you:
144
+ const handleWebhook = (payload : any ): Promise <void > => {
145
+ const saladCloudTranscriptionSdk = new SaladCloudTranscriptionSdk ({
146
+ apiKey: ' YOUR_API_KEY' ,
147
+ })
148
+
149
+ const saladCloudSdk = new SaladCloudSdk ({
57
150
apiKey: ' YOUR_API_KEY' ,
58
- });
151
+ })
152
+
153
+ // Extract the signing parameters from the headers.
154
+ const {
155
+ ' webhook-signature' : webhookSignature,
156
+ ' webhook-timestamp' : webhookTimestamp,
157
+ ' webhook-id' : webhookId,
158
+ } = payload .headers
159
+
160
+ // Retrieve the webhook signing secret for your organization.
161
+ const getWebhookSecretKeyResponse = await saladCloudSdk .webhookSecretKey .getWebhookSecretKey (' organization_name' )
162
+ const signingSecret = ` whsec_${getWebhookSecretKeyResponse .data ?.secretKey } `
163
+
164
+ // Process the webhook payload.
165
+ const job = await saladCloudTranscriptionSdk .processWebhookRequest ({
166
+ payload ,
167
+ signingSecret ,
168
+ webhookId ,
169
+ webhookTimestamp ,
170
+ webhookSignature ,
171
+ })
172
+
173
+ console .log (' Transcription Job:' , job .data )
174
+ }
175
+ ```
176
+
177
+ ### Get
178
+
179
+ Retrieves the current status or result of a transcription job.
59
180
60
- const { id } = await saladCloudTranscriptionSdk .transcribe (' organization_name' , ' path_to_file_or_url/video.mp4' );
181
+ ``` ts
182
+ import { SaladCloudTranscriptionSdk } from ' @saladtechnologies-oss/salad-cloud-transcription-sdk'
183
+
184
+ const sdk = new SaladCloudTranscriptionSdk ({
185
+ apiKey: ' YOUR_API_KEY' ,
186
+ })
61
187
62
- console .log (id );
63
- })();
188
+ const transcription = await sdk .get (' organization_name' , ' transcription_job_id' )
64
189
```
65
190
191
+ ### Stop
192
+
193
+ Stops (cancels) an active transcription job.
194
+
195
+ ``` ts
196
+ import { SaladCloudTranscriptionSdk } from ' @saladtechnologies-oss/salad-cloud-transcription-sdk'
197
+
198
+ const sdk = new SaladCloudTranscriptionSdk ({
199
+ apiKey: ' YOUR_API_KEY' ,
200
+ })
201
+
202
+ await sdk .stop (' organization_name' , ' transcription_job_id' )
203
+ ```
204
+
205
+ ### List
206
+
207
+ Lists all transcription jobs for a given organization.
208
+
209
+ ``` ts
210
+ import { SaladCloudTranscriptionSdk } from ' @saladtechnologies-oss/salad-cloud-transcription-sdk'
211
+
212
+ const sdk = new SaladCloudTranscriptionSdk ({
213
+ apiKey: ' YOUR_API_KEY' ,
214
+ })
215
+
216
+ const transcriptionsList = await sdk .list (' organization_name' )
217
+ ```
218
+
219
+ ### WaitFor
220
+
221
+ Polls the transcription status until the job reaches a final state ("succeeded" or "failed"), a timeout is reached, or the operation is aborted.
222
+
223
+ ``` ts
224
+ import { SaladCloudTranscriptionSdk } from ' @saladtechnologies-oss/salad-cloud-transcription-sdk'
225
+
226
+ const sdk = new SaladCloudTranscriptionSdk ({
227
+ apiKey: ' YOUR_API_KEY' ,
228
+ })
229
+
230
+ try {
231
+ const finalResult = await sdk .waitFor (' organization_name' , ' transcription_job_id' )
232
+ } catch (error ) {
233
+ console .error (' Error or timeout while waiting:' , error )
234
+ }
235
+ ```
236
+
237
+ ## Error Handling
238
+
239
+ Each method validates the request and response payloads. If an error is detected—for example, a transcription job failure with an error message—the SDK throws an error with a descriptive message. This allows implement custom error handling.
240
+
66
241
## License
67
242
68
243
This SDK is licensed under the MIT License.
0 commit comments