@eka-care/ekascribe-ts-sdk 2.0.48 → 2.0.50
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.
- package/README.md +58 -1
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -196,7 +196,9 @@ const response = await ekascribe.initTransaction({
|
|
|
196
196
|
},
|
|
197
197
|
version: '1.0.0',
|
|
198
198
|
additional_data: {},
|
|
199
|
-
}
|
|
199
|
+
},
|
|
200
|
+
sharedWorkerUrl: 'worker-url', // optional - see Shared Worker Configuration below
|
|
201
|
+
);
|
|
200
202
|
```
|
|
201
203
|
|
|
202
204
|
**Key Parameters:**
|
|
@@ -209,6 +211,7 @@ const response = await ekascribe.initTransaction({
|
|
|
209
211
|
- `additional_data`: Optional - Pass any data you want to receive unchanged in the response
|
|
210
212
|
- `transfer`: Audio mode. Use `vaded` for audio already processed with Voice Activity Detection (SDK does this by default); use `non-vaded` only if you are sending raw audio without VAD.
|
|
211
213
|
- `model_type`: Transcription model choice. `pro` = most accurate; `lite` = lower latency, more performant.
|
|
214
|
+
- `sharedWorkerUrl`: Optional - Custom URL for the shared worker script. See **Shared Worker Configuration** section below for usage details.
|
|
212
215
|
|
|
213
216
|
- #### Sample Response:
|
|
214
217
|
|
|
@@ -246,6 +249,60 @@ ekascribe.updateAuthTokens({ access_token: sdkConfig.access_token });
|
|
|
246
249
|
const response = await ekascribe.initTransaction({ ... });
|
|
247
250
|
```
|
|
248
251
|
|
|
252
|
+
#### Shared Worker Configuration
|
|
253
|
+
|
|
254
|
+
The SDK supports using a shared worker for efficient background audio file uploads. If you provide a `sharedWorkerUrl`, the SDK will use a shared worker for file uploads. If not provided, the SDK will use the main thread for file uploads.
|
|
255
|
+
|
|
256
|
+
**Why use Shared Worker:**
|
|
257
|
+
|
|
258
|
+
- **Better Performance**: Offloads file uploads to a background thread, keeping the main thread free for UI interactions
|
|
259
|
+
- **Resource Efficiency**: A single shared worker instance can handle uploads across multiple tabs/windows
|
|
260
|
+
- **Improved User Experience**: Prevents UI blocking during large file uploads
|
|
261
|
+
|
|
262
|
+
**How to configure:**
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
// Step 1: Create a function to fetch and prepare the worker URL
|
|
266
|
+
async function getSharedWorkerUrl() {
|
|
267
|
+
// Fetch the worker script from CDN (or your own hosting) - update the latest sdk version
|
|
268
|
+
const workerScriptResponse = await fetch(
|
|
269
|
+
'https://cdn.jsdelivr.net/npm/@eka-care/ekascribe-ts-sdk@2.0.48/dist/worker.bundle.js'
|
|
270
|
+
);
|
|
271
|
+
const workerScript = await workerScriptResponse.text();
|
|
272
|
+
|
|
273
|
+
// Create a blob from the worker script
|
|
274
|
+
const blob = new Blob([workerScript], { type: 'application/javascript' });
|
|
275
|
+
|
|
276
|
+
// Generate an object URL for the blob
|
|
277
|
+
const workerUrl = URL.createObjectURL(blob);
|
|
278
|
+
|
|
279
|
+
return workerUrl;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Step 2: Use the worker URL in initTransaction
|
|
283
|
+
const sharedWorkerUrl = await getSharedWorkerUrl();
|
|
284
|
+
|
|
285
|
+
const response = await ekascribe.initTransaction(
|
|
286
|
+
{
|
|
287
|
+
mode: 'consultation',
|
|
288
|
+
input_language: ['en-IN'],
|
|
289
|
+
output_format_template: [{ template_id: 'your_template_id' }],
|
|
290
|
+
txn_id: 'unique-transaction-id',
|
|
291
|
+
transfer: 'vaded',
|
|
292
|
+
model_type: 'pro',
|
|
293
|
+
// ... other parameters
|
|
294
|
+
},
|
|
295
|
+
sharedWorkerUrl // Pass the custom worker URL;
|
|
296
|
+
);
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
**Important notes:**
|
|
300
|
+
|
|
301
|
+
- Make sure to use the correct SDK version in the CDN URL
|
|
302
|
+
- The worker URL must be accessible from the same origin or have proper CORS headers
|
|
303
|
+
- Remember to revoke the object URL when you're done: `URL.revokeObjectURL(workerUrl)`
|
|
304
|
+
- If `sharedWorkerUrl` is not provided, the SDK will use the main thread for file uploads (no shared worker)
|
|
305
|
+
|
|
249
306
|
### 5. Start recording
|
|
250
307
|
|
|
251
308
|
Start recording audio after initializing the transaction.
|
package/dist/index.d.ts
CHANGED