voice-router-dev 0.3.4 → 0.3.5
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/CHANGELOG.md +9 -6
- package/dist/index.d.mts +18 -9
- package/dist/index.d.ts +18 -9
- package/dist/index.js +24 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -11,22 +11,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
11
11
|
|
|
12
12
|
#### Gladia Audio File Download
|
|
13
13
|
|
|
14
|
-
New `getAudioFile()` method for Gladia adapter - download the original audio used for transcription
|
|
14
|
+
New `getAudioFile()` method for Gladia adapter - download the original audio used for transcription.
|
|
15
|
+
|
|
16
|
+
Returns `ArrayBuffer` for cross-platform compatibility (Node.js and browser):
|
|
15
17
|
|
|
16
18
|
```typescript
|
|
17
|
-
// Download audio from a pre-recorded transcription
|
|
18
19
|
const result = await gladiaAdapter.getAudioFile('transcript-123')
|
|
19
20
|
if (result.success && result.data) {
|
|
20
|
-
//
|
|
21
|
-
const buffer = Buffer.from(
|
|
21
|
+
// Node.js: Convert to Buffer and save
|
|
22
|
+
const buffer = Buffer.from(result.data)
|
|
22
23
|
fs.writeFileSync('audio.mp3', buffer)
|
|
23
24
|
|
|
24
|
-
//
|
|
25
|
-
const
|
|
25
|
+
// Browser: Convert to Blob for playback/download
|
|
26
|
+
const blob = new Blob([result.data], { type: result.contentType || 'audio/mpeg' })
|
|
27
|
+
const url = URL.createObjectURL(blob)
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
// Download audio from a live/streaming session
|
|
29
31
|
const liveResult = await gladiaAdapter.getAudioFile('stream-456', 'streaming')
|
|
32
|
+
console.log('Size:', liveResult.data?.byteLength, 'bytes')
|
|
30
33
|
```
|
|
31
34
|
|
|
32
35
|
**Note:** This is a Gladia-specific feature. Other providers (Deepgram, AssemblyAI, Azure) do not store audio files after transcription.
|
package/dist/index.d.mts
CHANGED
|
@@ -8354,28 +8354,36 @@ declare class GladiaAdapter extends BaseAdapter {
|
|
|
8354
8354
|
* Gladia stores the audio files used for transcription and allows downloading them.
|
|
8355
8355
|
* This works for both pre-recorded and streaming (live) transcriptions.
|
|
8356
8356
|
*
|
|
8357
|
+
* Returns ArrayBuffer for cross-platform compatibility (Node.js and browser).
|
|
8358
|
+
*
|
|
8357
8359
|
* @param transcriptId - The ID of the transcript/job
|
|
8358
8360
|
* @param jobType - Type of job: 'pre-recorded' or 'streaming' (defaults to 'pre-recorded')
|
|
8359
|
-
* @returns Promise with the audio file as
|
|
8361
|
+
* @returns Promise with the audio file as ArrayBuffer, or error
|
|
8360
8362
|
*
|
|
8361
|
-
* @example Download
|
|
8363
|
+
* @example Download and save audio (Node.js)
|
|
8362
8364
|
* ```typescript
|
|
8363
8365
|
* const result = await adapter.getAudioFile('abc123');
|
|
8364
8366
|
* if (result.success && result.data) {
|
|
8365
|
-
*
|
|
8366
|
-
* const buffer = Buffer.from(await result.data.arrayBuffer());
|
|
8367
|
+
* const buffer = Buffer.from(result.data);
|
|
8367
8368
|
* fs.writeFileSync('audio.mp3', buffer);
|
|
8369
|
+
* }
|
|
8370
|
+
* ```
|
|
8368
8371
|
*
|
|
8369
|
-
*
|
|
8370
|
-
*
|
|
8372
|
+
* @example Download and create URL (Browser)
|
|
8373
|
+
* ```typescript
|
|
8374
|
+
* const result = await adapter.getAudioFile('abc123');
|
|
8375
|
+
* if (result.success && result.data) {
|
|
8376
|
+
* const blob = new Blob([result.data], { type: 'audio/mpeg' });
|
|
8377
|
+
* const url = URL.createObjectURL(blob);
|
|
8378
|
+
* audioElement.src = url;
|
|
8371
8379
|
* }
|
|
8372
8380
|
* ```
|
|
8373
8381
|
*
|
|
8374
8382
|
* @example Download audio from a live/streaming session
|
|
8375
8383
|
* ```typescript
|
|
8376
8384
|
* const result = await adapter.getAudioFile('stream-456', 'streaming');
|
|
8377
|
-
* if (result.success) {
|
|
8378
|
-
* console.log('Audio file size:', result.data
|
|
8385
|
+
* if (result.success && result.data) {
|
|
8386
|
+
* console.log('Audio file size:', result.data.byteLength, 'bytes');
|
|
8379
8387
|
* }
|
|
8380
8388
|
* ```
|
|
8381
8389
|
*
|
|
@@ -8383,7 +8391,8 @@ declare class GladiaAdapter extends BaseAdapter {
|
|
|
8383
8391
|
*/
|
|
8384
8392
|
getAudioFile(transcriptId: string, jobType?: "pre-recorded" | "streaming"): Promise<{
|
|
8385
8393
|
success: boolean;
|
|
8386
|
-
data?:
|
|
8394
|
+
data?: ArrayBuffer;
|
|
8395
|
+
contentType?: string;
|
|
8387
8396
|
error?: {
|
|
8388
8397
|
code: string;
|
|
8389
8398
|
message: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -8354,28 +8354,36 @@ declare class GladiaAdapter extends BaseAdapter {
|
|
|
8354
8354
|
* Gladia stores the audio files used for transcription and allows downloading them.
|
|
8355
8355
|
* This works for both pre-recorded and streaming (live) transcriptions.
|
|
8356
8356
|
*
|
|
8357
|
+
* Returns ArrayBuffer for cross-platform compatibility (Node.js and browser).
|
|
8358
|
+
*
|
|
8357
8359
|
* @param transcriptId - The ID of the transcript/job
|
|
8358
8360
|
* @param jobType - Type of job: 'pre-recorded' or 'streaming' (defaults to 'pre-recorded')
|
|
8359
|
-
* @returns Promise with the audio file as
|
|
8361
|
+
* @returns Promise with the audio file as ArrayBuffer, or error
|
|
8360
8362
|
*
|
|
8361
|
-
* @example Download
|
|
8363
|
+
* @example Download and save audio (Node.js)
|
|
8362
8364
|
* ```typescript
|
|
8363
8365
|
* const result = await adapter.getAudioFile('abc123');
|
|
8364
8366
|
* if (result.success && result.data) {
|
|
8365
|
-
*
|
|
8366
|
-
* const buffer = Buffer.from(await result.data.arrayBuffer());
|
|
8367
|
+
* const buffer = Buffer.from(result.data);
|
|
8367
8368
|
* fs.writeFileSync('audio.mp3', buffer);
|
|
8369
|
+
* }
|
|
8370
|
+
* ```
|
|
8368
8371
|
*
|
|
8369
|
-
*
|
|
8370
|
-
*
|
|
8372
|
+
* @example Download and create URL (Browser)
|
|
8373
|
+
* ```typescript
|
|
8374
|
+
* const result = await adapter.getAudioFile('abc123');
|
|
8375
|
+
* if (result.success && result.data) {
|
|
8376
|
+
* const blob = new Blob([result.data], { type: 'audio/mpeg' });
|
|
8377
|
+
* const url = URL.createObjectURL(blob);
|
|
8378
|
+
* audioElement.src = url;
|
|
8371
8379
|
* }
|
|
8372
8380
|
* ```
|
|
8373
8381
|
*
|
|
8374
8382
|
* @example Download audio from a live/streaming session
|
|
8375
8383
|
* ```typescript
|
|
8376
8384
|
* const result = await adapter.getAudioFile('stream-456', 'streaming');
|
|
8377
|
-
* if (result.success) {
|
|
8378
|
-
* console.log('Audio file size:', result.data
|
|
8385
|
+
* if (result.success && result.data) {
|
|
8386
|
+
* console.log('Audio file size:', result.data.byteLength, 'bytes');
|
|
8379
8387
|
* }
|
|
8380
8388
|
* ```
|
|
8381
8389
|
*
|
|
@@ -8383,7 +8391,8 @@ declare class GladiaAdapter extends BaseAdapter {
|
|
|
8383
8391
|
*/
|
|
8384
8392
|
getAudioFile(transcriptId: string, jobType?: "pre-recorded" | "streaming"): Promise<{
|
|
8385
8393
|
success: boolean;
|
|
8386
|
-
data?:
|
|
8394
|
+
data?: ArrayBuffer;
|
|
8395
|
+
contentType?: string;
|
|
8387
8396
|
error?: {
|
|
8388
8397
|
code: string;
|
|
8389
8398
|
message: string;
|
package/dist/index.js
CHANGED
|
@@ -2276,28 +2276,36 @@ var GladiaAdapter = class extends BaseAdapter {
|
|
|
2276
2276
|
* Gladia stores the audio files used for transcription and allows downloading them.
|
|
2277
2277
|
* This works for both pre-recorded and streaming (live) transcriptions.
|
|
2278
2278
|
*
|
|
2279
|
+
* Returns ArrayBuffer for cross-platform compatibility (Node.js and browser).
|
|
2280
|
+
*
|
|
2279
2281
|
* @param transcriptId - The ID of the transcript/job
|
|
2280
2282
|
* @param jobType - Type of job: 'pre-recorded' or 'streaming' (defaults to 'pre-recorded')
|
|
2281
|
-
* @returns Promise with the audio file as
|
|
2283
|
+
* @returns Promise with the audio file as ArrayBuffer, or error
|
|
2282
2284
|
*
|
|
2283
|
-
* @example Download
|
|
2285
|
+
* @example Download and save audio (Node.js)
|
|
2284
2286
|
* ```typescript
|
|
2285
2287
|
* const result = await adapter.getAudioFile('abc123');
|
|
2286
2288
|
* if (result.success && result.data) {
|
|
2287
|
-
*
|
|
2288
|
-
* const buffer = Buffer.from(await result.data.arrayBuffer());
|
|
2289
|
+
* const buffer = Buffer.from(result.data);
|
|
2289
2290
|
* fs.writeFileSync('audio.mp3', buffer);
|
|
2291
|
+
* }
|
|
2292
|
+
* ```
|
|
2290
2293
|
*
|
|
2291
|
-
*
|
|
2292
|
-
*
|
|
2294
|
+
* @example Download and create URL (Browser)
|
|
2295
|
+
* ```typescript
|
|
2296
|
+
* const result = await adapter.getAudioFile('abc123');
|
|
2297
|
+
* if (result.success && result.data) {
|
|
2298
|
+
* const blob = new Blob([result.data], { type: 'audio/mpeg' });
|
|
2299
|
+
* const url = URL.createObjectURL(blob);
|
|
2300
|
+
* audioElement.src = url;
|
|
2293
2301
|
* }
|
|
2294
2302
|
* ```
|
|
2295
2303
|
*
|
|
2296
2304
|
* @example Download audio from a live/streaming session
|
|
2297
2305
|
* ```typescript
|
|
2298
2306
|
* const result = await adapter.getAudioFile('stream-456', 'streaming');
|
|
2299
|
-
* if (result.success) {
|
|
2300
|
-
* console.log('Audio file size:', result.data
|
|
2307
|
+
* if (result.success && result.data) {
|
|
2308
|
+
* console.log('Audio file size:', result.data.byteLength, 'bytes');
|
|
2301
2309
|
* }
|
|
2302
2310
|
* ```
|
|
2303
2311
|
*
|
|
@@ -2306,15 +2314,20 @@ var GladiaAdapter = class extends BaseAdapter {
|
|
|
2306
2314
|
async getAudioFile(transcriptId, jobType = "pre-recorded") {
|
|
2307
2315
|
this.validateConfig();
|
|
2308
2316
|
try {
|
|
2317
|
+
const config = {
|
|
2318
|
+
...this.getAxiosConfig(),
|
|
2319
|
+
responseType: "arraybuffer"
|
|
2320
|
+
};
|
|
2309
2321
|
let response;
|
|
2310
2322
|
if (jobType === "streaming") {
|
|
2311
|
-
response = await streamingControllerGetAudioV2(transcriptId,
|
|
2323
|
+
response = await streamingControllerGetAudioV2(transcriptId, config);
|
|
2312
2324
|
} else {
|
|
2313
|
-
response = await preRecordedControllerGetAudioV2(transcriptId,
|
|
2325
|
+
response = await preRecordedControllerGetAudioV2(transcriptId, config);
|
|
2314
2326
|
}
|
|
2315
2327
|
return {
|
|
2316
2328
|
success: true,
|
|
2317
|
-
data: response.data
|
|
2329
|
+
data: response.data,
|
|
2330
|
+
contentType: response.headers?.["content-type"]
|
|
2318
2331
|
};
|
|
2319
2332
|
} catch (error) {
|
|
2320
2333
|
const err = error;
|