assemblyai 4.3.1 → 4.3.2
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 +12 -0
- package/README.md +161 -86
- package/dist/assemblyai.umd.js +62 -56
- package/dist/assemblyai.umd.min.js +1 -1
- package/dist/bun.mjs +57 -51
- package/dist/deno.mjs +57 -51
- package/dist/index.cjs +62 -56
- package/dist/index.mjs +62 -56
- package/dist/node.cjs +57 -51
- package/dist/node.mjs +57 -51
- package/dist/services/base.d.ts +1 -1
- package/dist/services/files/index.d.ts +2 -2
- package/dist/services/index.d.ts +1 -1
- package/dist/services/lemur/index.d.ts +1 -1
- package/dist/services/realtime/service.d.ts +2 -2
- package/dist/services/transcripts/index.d.ts +26 -26
- package/dist/types/asyncapi.generated.d.ts +60 -39
- package/dist/types/openapi.generated.d.ts +722 -329
- package/dist/types/services/index.d.ts +0 -1
- package/dist/types/transcripts/index.d.ts +14 -5
- package/package.json +2 -1
- package/src/services/base.ts +1 -1
- package/src/services/files/index.ts +2 -2
- package/src/services/index.ts +1 -1
- package/src/services/lemur/index.ts +1 -1
- package/src/services/realtime/service.ts +3 -4
- package/src/services/transcripts/index.ts +47 -54
- package/src/types/asyncapi.generated.ts +62 -40
- package/src/types/openapi.generated.ts +726 -330
- package/src/types/services/index.ts +0 -1
- package/src/types/transcripts/index.ts +17 -7
- package/dist/types/services/abstractions.d.ts +0 -52
- package/src/types/services/abstractions.ts +0 -56
package/dist/node.cjs
CHANGED
|
@@ -11,7 +11,7 @@ var stream = require('stream');
|
|
|
11
11
|
class BaseService {
|
|
12
12
|
/**
|
|
13
13
|
* Create a new service.
|
|
14
|
-
* @param params The parameters to use for the service.
|
|
14
|
+
* @param params - The parameters to use for the service.
|
|
15
15
|
*/
|
|
16
16
|
constructor(params) {
|
|
17
17
|
this.params = params;
|
|
@@ -78,7 +78,7 @@ class LemurService extends BaseService {
|
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* Delete the data for a previously submitted LeMUR request.
|
|
81
|
-
* @param id ID of the LeMUR request
|
|
81
|
+
* @param id - ID of the LeMUR request
|
|
82
82
|
*/
|
|
83
83
|
purgeRequestData(id) {
|
|
84
84
|
return this.fetchJson(`/lemur/v3/${id}`, {
|
|
@@ -135,11 +135,10 @@ class RealtimeTranscriber {
|
|
|
135
135
|
constructor(params) {
|
|
136
136
|
this.listeners = {};
|
|
137
137
|
this.realtimeUrl = params.realtimeUrl ?? defaultRealtimeUrl;
|
|
138
|
-
this.sampleRate = params.sampleRate ??
|
|
138
|
+
this.sampleRate = params.sampleRate ?? 16_000;
|
|
139
139
|
this.wordBoost = params.wordBoost;
|
|
140
140
|
this.encoding = params.encoding;
|
|
141
|
-
this.endUtteranceSilenceThreshold =
|
|
142
|
-
params.endUtteranceSilenceThreshold;
|
|
141
|
+
this.endUtteranceSilenceThreshold = params.endUtteranceSilenceThreshold;
|
|
143
142
|
if ("token" in params && params.token)
|
|
144
143
|
this.token = params.token;
|
|
145
144
|
if ("apiKey" in params && params.apiKey)
|
|
@@ -263,8 +262,8 @@ class RealtimeTranscriber {
|
|
|
263
262
|
}
|
|
264
263
|
/**
|
|
265
264
|
* Configure the threshold for how long to wait before ending an utterance. Default is 700ms.
|
|
266
|
-
* @param threshold The duration of the end utterance silence threshold in milliseconds
|
|
267
|
-
*
|
|
265
|
+
* @param threshold - The duration of the end utterance silence threshold in milliseconds.
|
|
266
|
+
* This value must be an integer between 0 and 20_000.
|
|
268
267
|
*/
|
|
269
268
|
configureEndUtteranceSilenceThreshold(threshold) {
|
|
270
269
|
this.send(`{"end_utterance_silence_threshold":${threshold}}`);
|
|
@@ -354,8 +353,8 @@ class TranscriptService extends BaseService {
|
|
|
354
353
|
}
|
|
355
354
|
/**
|
|
356
355
|
* Transcribe an audio file. This will create a transcript and wait until the transcript status is "completed" or "error".
|
|
357
|
-
* @param params The parameters to transcribe an audio file.
|
|
358
|
-
* @param options The options to transcribe an audio file.
|
|
356
|
+
* @param params - The parameters to transcribe an audio file.
|
|
357
|
+
* @param options - The options to transcribe an audio file.
|
|
359
358
|
* @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
|
|
360
359
|
*/
|
|
361
360
|
async transcribe(params, options) {
|
|
@@ -364,37 +363,44 @@ class TranscriptService extends BaseService {
|
|
|
364
363
|
}
|
|
365
364
|
/**
|
|
366
365
|
* Submits a transcription job for an audio file. This will not wait until the transcript status is "completed" or "error".
|
|
367
|
-
* @param params The parameters to start the transcription of an audio file.
|
|
366
|
+
* @param params - The parameters to start the transcription of an audio file.
|
|
368
367
|
* @returns A promise that resolves to the queued transcript.
|
|
369
368
|
*/
|
|
370
369
|
async submit(params) {
|
|
371
|
-
const { audio, ...createParams } = params;
|
|
372
370
|
let audioUrl;
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
371
|
+
let transcriptParams = undefined;
|
|
372
|
+
if ("audio" in params) {
|
|
373
|
+
const { audio, ...audioTranscriptParams } = params;
|
|
374
|
+
if (typeof audio === "string") {
|
|
375
|
+
const path = getPath(audio);
|
|
376
|
+
if (path !== null) {
|
|
377
|
+
// audio is local path, upload local file
|
|
378
|
+
audioUrl = await this.files.upload(path);
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
// audio is not a local path, assume it's a URL
|
|
382
|
+
audioUrl = audio;
|
|
383
|
+
}
|
|
378
384
|
}
|
|
379
385
|
else {
|
|
380
|
-
// audio is
|
|
381
|
-
audioUrl = audio;
|
|
386
|
+
// audio is of uploadable type
|
|
387
|
+
audioUrl = await this.files.upload(audio);
|
|
382
388
|
}
|
|
389
|
+
transcriptParams = { ...audioTranscriptParams, audio_url: audioUrl };
|
|
383
390
|
}
|
|
384
391
|
else {
|
|
385
|
-
|
|
386
|
-
audioUrl = await this.files.upload(audio);
|
|
392
|
+
transcriptParams = params;
|
|
387
393
|
}
|
|
388
394
|
const data = await this.fetchJson("/v2/transcript", {
|
|
389
395
|
method: "POST",
|
|
390
|
-
body: JSON.stringify(
|
|
396
|
+
body: JSON.stringify(transcriptParams),
|
|
391
397
|
});
|
|
392
398
|
return data;
|
|
393
399
|
}
|
|
394
400
|
/**
|
|
395
401
|
* Create a transcript.
|
|
396
|
-
* @param params The parameters to create a transcript.
|
|
397
|
-
* @param options The options used for creating the new transcript.
|
|
402
|
+
* @param params - The parameters to create a transcript.
|
|
403
|
+
* @param options - The options used for creating the new transcript.
|
|
398
404
|
* @returns A promise that resolves to the transcript.
|
|
399
405
|
* @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
|
|
400
406
|
*/
|
|
@@ -415,12 +421,12 @@ class TranscriptService extends BaseService {
|
|
|
415
421
|
}
|
|
416
422
|
/**
|
|
417
423
|
* Wait until the transcript ready, either the status is "completed" or "error".
|
|
418
|
-
* @param transcriptId The ID of the transcript.
|
|
419
|
-
* @param options The options to wait until the transcript is ready.
|
|
424
|
+
* @param transcriptId - The ID of the transcript.
|
|
425
|
+
* @param options - The options to wait until the transcript is ready.
|
|
420
426
|
* @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
|
|
421
427
|
*/
|
|
422
428
|
async waitUntilReady(transcriptId, options) {
|
|
423
|
-
const pollingInterval = options?.pollingInterval ??
|
|
429
|
+
const pollingInterval = options?.pollingInterval ?? 3_000;
|
|
424
430
|
const pollingTimeout = options?.pollingTimeout ?? -1;
|
|
425
431
|
const startTime = Date.now();
|
|
426
432
|
// eslint-disable-next-line no-constant-condition
|
|
@@ -440,7 +446,7 @@ class TranscriptService extends BaseService {
|
|
|
440
446
|
}
|
|
441
447
|
/**
|
|
442
448
|
* Retrieve a transcript.
|
|
443
|
-
* @param id The identifier of the transcript.
|
|
449
|
+
* @param id - The identifier of the transcript.
|
|
444
450
|
* @returns A promise that resolves to the transcript.
|
|
445
451
|
*/
|
|
446
452
|
get(id) {
|
|
@@ -448,17 +454,17 @@ class TranscriptService extends BaseService {
|
|
|
448
454
|
}
|
|
449
455
|
/**
|
|
450
456
|
* Retrieves a page of transcript listings.
|
|
451
|
-
* @param
|
|
457
|
+
* @param params - The parameters to filter the transcript list by, or the URL to retrieve the transcript list from.
|
|
452
458
|
*/
|
|
453
|
-
async list(
|
|
459
|
+
async list(params) {
|
|
454
460
|
let url = "/v2/transcript";
|
|
455
|
-
if (typeof
|
|
456
|
-
url =
|
|
461
|
+
if (typeof params === "string") {
|
|
462
|
+
url = params;
|
|
457
463
|
}
|
|
458
|
-
else if (
|
|
459
|
-
url = `${url}?${new URLSearchParams(Object.keys(
|
|
464
|
+
else if (params) {
|
|
465
|
+
url = `${url}?${new URLSearchParams(Object.keys(params).map((key) => [
|
|
460
466
|
key,
|
|
461
|
-
|
|
467
|
+
params[key]?.toString() || "",
|
|
462
468
|
]))}`;
|
|
463
469
|
}
|
|
464
470
|
const data = await this.fetchJson(url);
|
|
@@ -472,7 +478,7 @@ class TranscriptService extends BaseService {
|
|
|
472
478
|
}
|
|
473
479
|
/**
|
|
474
480
|
* Delete a transcript
|
|
475
|
-
* @param id The identifier of the transcript.
|
|
481
|
+
* @param id - The identifier of the transcript.
|
|
476
482
|
* @returns A promise that resolves to the transcript.
|
|
477
483
|
*/
|
|
478
484
|
delete(id) {
|
|
@@ -481,9 +487,9 @@ class TranscriptService extends BaseService {
|
|
|
481
487
|
/**
|
|
482
488
|
* Search through the transcript for a specific set of keywords.
|
|
483
489
|
* You can search for individual words, numbers, or phrases containing up to five words or numbers.
|
|
484
|
-
* @param id The identifier of the transcript.
|
|
485
|
-
* @param words Keywords to search for.
|
|
486
|
-
* @
|
|
490
|
+
* @param id - The identifier of the transcript.
|
|
491
|
+
* @param words - Keywords to search for.
|
|
492
|
+
* @returns A promise that resolves to the sentences.
|
|
487
493
|
*/
|
|
488
494
|
wordSearch(id, words) {
|
|
489
495
|
const params = new URLSearchParams({ words: words.join(",") });
|
|
@@ -491,26 +497,26 @@ class TranscriptService extends BaseService {
|
|
|
491
497
|
}
|
|
492
498
|
/**
|
|
493
499
|
* Retrieve all sentences of a transcript.
|
|
494
|
-
* @param id The identifier of the transcript.
|
|
495
|
-
* @
|
|
500
|
+
* @param id - The identifier of the transcript.
|
|
501
|
+
* @returns A promise that resolves to the sentences.
|
|
496
502
|
*/
|
|
497
503
|
sentences(id) {
|
|
498
504
|
return this.fetchJson(`/v2/transcript/${id}/sentences`);
|
|
499
505
|
}
|
|
500
506
|
/**
|
|
501
507
|
* Retrieve all paragraphs of a transcript.
|
|
502
|
-
* @param id The identifier of the transcript.
|
|
503
|
-
* @
|
|
508
|
+
* @param id - The identifier of the transcript.
|
|
509
|
+
* @returns A promise that resolves to the paragraphs.
|
|
504
510
|
*/
|
|
505
511
|
paragraphs(id) {
|
|
506
512
|
return this.fetchJson(`/v2/transcript/${id}/paragraphs`);
|
|
507
513
|
}
|
|
508
514
|
/**
|
|
509
515
|
* Retrieve subtitles of a transcript.
|
|
510
|
-
* @param id The identifier of the transcript.
|
|
511
|
-
* @param format The format of the subtitles.
|
|
512
|
-
* @param chars_per_caption The maximum number of characters per caption.
|
|
513
|
-
* @
|
|
516
|
+
* @param id - The identifier of the transcript.
|
|
517
|
+
* @param format - The format of the subtitles.
|
|
518
|
+
* @param chars_per_caption - The maximum number of characters per caption.
|
|
519
|
+
* @returns A promise that resolves to the subtitles text.
|
|
514
520
|
*/
|
|
515
521
|
async subtitles(id, format = "srt", chars_per_caption) {
|
|
516
522
|
let url = `/v2/transcript/${id}/${format}`;
|
|
@@ -524,8 +530,8 @@ class TranscriptService extends BaseService {
|
|
|
524
530
|
}
|
|
525
531
|
/**
|
|
526
532
|
* Retrieve redactions of a transcript.
|
|
527
|
-
* @param id The identifier of the transcript.
|
|
528
|
-
* @
|
|
533
|
+
* @param id - The identifier of the transcript.
|
|
534
|
+
* @returns A promise that resolves to the subtitles text.
|
|
529
535
|
*/
|
|
530
536
|
redactions(id) {
|
|
531
537
|
return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
|
|
@@ -537,8 +543,8 @@ const readFile = async (path) => stream.Readable.toWeb(fs.createReadStream(path)
|
|
|
537
543
|
class FileService extends BaseService {
|
|
538
544
|
/**
|
|
539
545
|
* Upload a local file to AssemblyAI.
|
|
540
|
-
* @param input The local file path to upload, or a stream or buffer of the file to upload.
|
|
541
|
-
* @
|
|
546
|
+
* @param input - The local file path to upload, or a stream or buffer of the file to upload.
|
|
547
|
+
* @returns A promise that resolves to the uploaded file URL.
|
|
542
548
|
*/
|
|
543
549
|
async upload(input) {
|
|
544
550
|
let fileData;
|
|
@@ -562,7 +568,7 @@ const defaultBaseUrl = "https://api.assemblyai.com";
|
|
|
562
568
|
class AssemblyAI {
|
|
563
569
|
/**
|
|
564
570
|
* Create a new AssemblyAI client.
|
|
565
|
-
* @param params The parameters for the service, including the API key and base URL, if any.
|
|
571
|
+
* @param params - The parameters for the service, including the API key and base URL, if any.
|
|
566
572
|
*/
|
|
567
573
|
constructor(params) {
|
|
568
574
|
params.baseUrl = params.baseUrl || defaultBaseUrl;
|
package/dist/node.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { Readable } from 'stream';
|
|
|
9
9
|
class BaseService {
|
|
10
10
|
/**
|
|
11
11
|
* Create a new service.
|
|
12
|
-
* @param params The parameters to use for the service.
|
|
12
|
+
* @param params - The parameters to use for the service.
|
|
13
13
|
*/
|
|
14
14
|
constructor(params) {
|
|
15
15
|
this.params = params;
|
|
@@ -76,7 +76,7 @@ class LemurService extends BaseService {
|
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* Delete the data for a previously submitted LeMUR request.
|
|
79
|
-
* @param id ID of the LeMUR request
|
|
79
|
+
* @param id - ID of the LeMUR request
|
|
80
80
|
*/
|
|
81
81
|
purgeRequestData(id) {
|
|
82
82
|
return this.fetchJson(`/lemur/v3/${id}`, {
|
|
@@ -133,11 +133,10 @@ class RealtimeTranscriber {
|
|
|
133
133
|
constructor(params) {
|
|
134
134
|
this.listeners = {};
|
|
135
135
|
this.realtimeUrl = params.realtimeUrl ?? defaultRealtimeUrl;
|
|
136
|
-
this.sampleRate = params.sampleRate ??
|
|
136
|
+
this.sampleRate = params.sampleRate ?? 16_000;
|
|
137
137
|
this.wordBoost = params.wordBoost;
|
|
138
138
|
this.encoding = params.encoding;
|
|
139
|
-
this.endUtteranceSilenceThreshold =
|
|
140
|
-
params.endUtteranceSilenceThreshold;
|
|
139
|
+
this.endUtteranceSilenceThreshold = params.endUtteranceSilenceThreshold;
|
|
141
140
|
if ("token" in params && params.token)
|
|
142
141
|
this.token = params.token;
|
|
143
142
|
if ("apiKey" in params && params.apiKey)
|
|
@@ -261,8 +260,8 @@ class RealtimeTranscriber {
|
|
|
261
260
|
}
|
|
262
261
|
/**
|
|
263
262
|
* Configure the threshold for how long to wait before ending an utterance. Default is 700ms.
|
|
264
|
-
* @param threshold The duration of the end utterance silence threshold in milliseconds
|
|
265
|
-
*
|
|
263
|
+
* @param threshold - The duration of the end utterance silence threshold in milliseconds.
|
|
264
|
+
* This value must be an integer between 0 and 20_000.
|
|
266
265
|
*/
|
|
267
266
|
configureEndUtteranceSilenceThreshold(threshold) {
|
|
268
267
|
this.send(`{"end_utterance_silence_threshold":${threshold}}`);
|
|
@@ -352,8 +351,8 @@ class TranscriptService extends BaseService {
|
|
|
352
351
|
}
|
|
353
352
|
/**
|
|
354
353
|
* Transcribe an audio file. This will create a transcript and wait until the transcript status is "completed" or "error".
|
|
355
|
-
* @param params The parameters to transcribe an audio file.
|
|
356
|
-
* @param options The options to transcribe an audio file.
|
|
354
|
+
* @param params - The parameters to transcribe an audio file.
|
|
355
|
+
* @param options - The options to transcribe an audio file.
|
|
357
356
|
* @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
|
|
358
357
|
*/
|
|
359
358
|
async transcribe(params, options) {
|
|
@@ -362,37 +361,44 @@ class TranscriptService extends BaseService {
|
|
|
362
361
|
}
|
|
363
362
|
/**
|
|
364
363
|
* Submits a transcription job for an audio file. This will not wait until the transcript status is "completed" or "error".
|
|
365
|
-
* @param params The parameters to start the transcription of an audio file.
|
|
364
|
+
* @param params - The parameters to start the transcription of an audio file.
|
|
366
365
|
* @returns A promise that resolves to the queued transcript.
|
|
367
366
|
*/
|
|
368
367
|
async submit(params) {
|
|
369
|
-
const { audio, ...createParams } = params;
|
|
370
368
|
let audioUrl;
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
369
|
+
let transcriptParams = undefined;
|
|
370
|
+
if ("audio" in params) {
|
|
371
|
+
const { audio, ...audioTranscriptParams } = params;
|
|
372
|
+
if (typeof audio === "string") {
|
|
373
|
+
const path = getPath(audio);
|
|
374
|
+
if (path !== null) {
|
|
375
|
+
// audio is local path, upload local file
|
|
376
|
+
audioUrl = await this.files.upload(path);
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
// audio is not a local path, assume it's a URL
|
|
380
|
+
audioUrl = audio;
|
|
381
|
+
}
|
|
376
382
|
}
|
|
377
383
|
else {
|
|
378
|
-
// audio is
|
|
379
|
-
audioUrl = audio;
|
|
384
|
+
// audio is of uploadable type
|
|
385
|
+
audioUrl = await this.files.upload(audio);
|
|
380
386
|
}
|
|
387
|
+
transcriptParams = { ...audioTranscriptParams, audio_url: audioUrl };
|
|
381
388
|
}
|
|
382
389
|
else {
|
|
383
|
-
|
|
384
|
-
audioUrl = await this.files.upload(audio);
|
|
390
|
+
transcriptParams = params;
|
|
385
391
|
}
|
|
386
392
|
const data = await this.fetchJson("/v2/transcript", {
|
|
387
393
|
method: "POST",
|
|
388
|
-
body: JSON.stringify(
|
|
394
|
+
body: JSON.stringify(transcriptParams),
|
|
389
395
|
});
|
|
390
396
|
return data;
|
|
391
397
|
}
|
|
392
398
|
/**
|
|
393
399
|
* Create a transcript.
|
|
394
|
-
* @param params The parameters to create a transcript.
|
|
395
|
-
* @param options The options used for creating the new transcript.
|
|
400
|
+
* @param params - The parameters to create a transcript.
|
|
401
|
+
* @param options - The options used for creating the new transcript.
|
|
396
402
|
* @returns A promise that resolves to the transcript.
|
|
397
403
|
* @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
|
|
398
404
|
*/
|
|
@@ -413,12 +419,12 @@ class TranscriptService extends BaseService {
|
|
|
413
419
|
}
|
|
414
420
|
/**
|
|
415
421
|
* Wait until the transcript ready, either the status is "completed" or "error".
|
|
416
|
-
* @param transcriptId The ID of the transcript.
|
|
417
|
-
* @param options The options to wait until the transcript is ready.
|
|
422
|
+
* @param transcriptId - The ID of the transcript.
|
|
423
|
+
* @param options - The options to wait until the transcript is ready.
|
|
418
424
|
* @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
|
|
419
425
|
*/
|
|
420
426
|
async waitUntilReady(transcriptId, options) {
|
|
421
|
-
const pollingInterval = options?.pollingInterval ??
|
|
427
|
+
const pollingInterval = options?.pollingInterval ?? 3_000;
|
|
422
428
|
const pollingTimeout = options?.pollingTimeout ?? -1;
|
|
423
429
|
const startTime = Date.now();
|
|
424
430
|
// eslint-disable-next-line no-constant-condition
|
|
@@ -438,7 +444,7 @@ class TranscriptService extends BaseService {
|
|
|
438
444
|
}
|
|
439
445
|
/**
|
|
440
446
|
* Retrieve a transcript.
|
|
441
|
-
* @param id The identifier of the transcript.
|
|
447
|
+
* @param id - The identifier of the transcript.
|
|
442
448
|
* @returns A promise that resolves to the transcript.
|
|
443
449
|
*/
|
|
444
450
|
get(id) {
|
|
@@ -446,17 +452,17 @@ class TranscriptService extends BaseService {
|
|
|
446
452
|
}
|
|
447
453
|
/**
|
|
448
454
|
* Retrieves a page of transcript listings.
|
|
449
|
-
* @param
|
|
455
|
+
* @param params - The parameters to filter the transcript list by, or the URL to retrieve the transcript list from.
|
|
450
456
|
*/
|
|
451
|
-
async list(
|
|
457
|
+
async list(params) {
|
|
452
458
|
let url = "/v2/transcript";
|
|
453
|
-
if (typeof
|
|
454
|
-
url =
|
|
459
|
+
if (typeof params === "string") {
|
|
460
|
+
url = params;
|
|
455
461
|
}
|
|
456
|
-
else if (
|
|
457
|
-
url = `${url}?${new URLSearchParams(Object.keys(
|
|
462
|
+
else if (params) {
|
|
463
|
+
url = `${url}?${new URLSearchParams(Object.keys(params).map((key) => [
|
|
458
464
|
key,
|
|
459
|
-
|
|
465
|
+
params[key]?.toString() || "",
|
|
460
466
|
]))}`;
|
|
461
467
|
}
|
|
462
468
|
const data = await this.fetchJson(url);
|
|
@@ -470,7 +476,7 @@ class TranscriptService extends BaseService {
|
|
|
470
476
|
}
|
|
471
477
|
/**
|
|
472
478
|
* Delete a transcript
|
|
473
|
-
* @param id The identifier of the transcript.
|
|
479
|
+
* @param id - The identifier of the transcript.
|
|
474
480
|
* @returns A promise that resolves to the transcript.
|
|
475
481
|
*/
|
|
476
482
|
delete(id) {
|
|
@@ -479,9 +485,9 @@ class TranscriptService extends BaseService {
|
|
|
479
485
|
/**
|
|
480
486
|
* Search through the transcript for a specific set of keywords.
|
|
481
487
|
* You can search for individual words, numbers, or phrases containing up to five words or numbers.
|
|
482
|
-
* @param id The identifier of the transcript.
|
|
483
|
-
* @param words Keywords to search for.
|
|
484
|
-
* @
|
|
488
|
+
* @param id - The identifier of the transcript.
|
|
489
|
+
* @param words - Keywords to search for.
|
|
490
|
+
* @returns A promise that resolves to the sentences.
|
|
485
491
|
*/
|
|
486
492
|
wordSearch(id, words) {
|
|
487
493
|
const params = new URLSearchParams({ words: words.join(",") });
|
|
@@ -489,26 +495,26 @@ class TranscriptService extends BaseService {
|
|
|
489
495
|
}
|
|
490
496
|
/**
|
|
491
497
|
* Retrieve all sentences of a transcript.
|
|
492
|
-
* @param id The identifier of the transcript.
|
|
493
|
-
* @
|
|
498
|
+
* @param id - The identifier of the transcript.
|
|
499
|
+
* @returns A promise that resolves to the sentences.
|
|
494
500
|
*/
|
|
495
501
|
sentences(id) {
|
|
496
502
|
return this.fetchJson(`/v2/transcript/${id}/sentences`);
|
|
497
503
|
}
|
|
498
504
|
/**
|
|
499
505
|
* Retrieve all paragraphs of a transcript.
|
|
500
|
-
* @param id The identifier of the transcript.
|
|
501
|
-
* @
|
|
506
|
+
* @param id - The identifier of the transcript.
|
|
507
|
+
* @returns A promise that resolves to the paragraphs.
|
|
502
508
|
*/
|
|
503
509
|
paragraphs(id) {
|
|
504
510
|
return this.fetchJson(`/v2/transcript/${id}/paragraphs`);
|
|
505
511
|
}
|
|
506
512
|
/**
|
|
507
513
|
* Retrieve subtitles of a transcript.
|
|
508
|
-
* @param id The identifier of the transcript.
|
|
509
|
-
* @param format The format of the subtitles.
|
|
510
|
-
* @param chars_per_caption The maximum number of characters per caption.
|
|
511
|
-
* @
|
|
514
|
+
* @param id - The identifier of the transcript.
|
|
515
|
+
* @param format - The format of the subtitles.
|
|
516
|
+
* @param chars_per_caption - The maximum number of characters per caption.
|
|
517
|
+
* @returns A promise that resolves to the subtitles text.
|
|
512
518
|
*/
|
|
513
519
|
async subtitles(id, format = "srt", chars_per_caption) {
|
|
514
520
|
let url = `/v2/transcript/${id}/${format}`;
|
|
@@ -522,8 +528,8 @@ class TranscriptService extends BaseService {
|
|
|
522
528
|
}
|
|
523
529
|
/**
|
|
524
530
|
* Retrieve redactions of a transcript.
|
|
525
|
-
* @param id The identifier of the transcript.
|
|
526
|
-
* @
|
|
531
|
+
* @param id - The identifier of the transcript.
|
|
532
|
+
* @returns A promise that resolves to the subtitles text.
|
|
527
533
|
*/
|
|
528
534
|
redactions(id) {
|
|
529
535
|
return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
|
|
@@ -535,8 +541,8 @@ const readFile = async (path) => Readable.toWeb(createReadStream(path));
|
|
|
535
541
|
class FileService extends BaseService {
|
|
536
542
|
/**
|
|
537
543
|
* Upload a local file to AssemblyAI.
|
|
538
|
-
* @param input The local file path to upload, or a stream or buffer of the file to upload.
|
|
539
|
-
* @
|
|
544
|
+
* @param input - The local file path to upload, or a stream or buffer of the file to upload.
|
|
545
|
+
* @returns A promise that resolves to the uploaded file URL.
|
|
540
546
|
*/
|
|
541
547
|
async upload(input) {
|
|
542
548
|
let fileData;
|
|
@@ -560,7 +566,7 @@ const defaultBaseUrl = "https://api.assemblyai.com";
|
|
|
560
566
|
class AssemblyAI {
|
|
561
567
|
/**
|
|
562
568
|
* Create a new AssemblyAI client.
|
|
563
|
-
* @param params The parameters for the service, including the API key and base URL, if any.
|
|
569
|
+
* @param params - The parameters for the service, including the API key and base URL, if any.
|
|
564
570
|
*/
|
|
565
571
|
constructor(params) {
|
|
566
572
|
params.baseUrl = params.baseUrl || defaultBaseUrl;
|
package/dist/services/base.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare abstract class BaseService {
|
|
|
6
6
|
private params;
|
|
7
7
|
/**
|
|
8
8
|
* Create a new service.
|
|
9
|
-
* @param params The parameters to use for the service.
|
|
9
|
+
* @param params - The parameters to use for the service.
|
|
10
10
|
*/
|
|
11
11
|
constructor(params: BaseServiceParams);
|
|
12
12
|
protected fetch(input: string, init?: RequestInit | undefined): Promise<Response>;
|
|
@@ -3,8 +3,8 @@ import { FileUploadParams } from "../..";
|
|
|
3
3
|
export declare class FileService extends BaseService {
|
|
4
4
|
/**
|
|
5
5
|
* Upload a local file to AssemblyAI.
|
|
6
|
-
* @param input The local file path to upload, or a stream or buffer of the file to upload.
|
|
7
|
-
* @
|
|
6
|
+
* @param input - The local file path to upload, or a stream or buffer of the file to upload.
|
|
7
|
+
* @returns A promise that resolves to the uploaded file URL.
|
|
8
8
|
*/
|
|
9
9
|
upload(input: FileUploadParams): Promise<string>;
|
|
10
10
|
}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ declare class AssemblyAI {
|
|
|
22
22
|
realtime: RealtimeTranscriberFactory;
|
|
23
23
|
/**
|
|
24
24
|
* Create a new AssemblyAI client.
|
|
25
|
-
* @param params The parameters for the service, including the API key and base URL, if any.
|
|
25
|
+
* @param params - The parameters for the service, including the API key and base URL, if any.
|
|
26
26
|
*/
|
|
27
27
|
constructor(params: BaseServiceParams);
|
|
28
28
|
}
|
|
@@ -7,7 +7,7 @@ export declare class LemurService extends BaseService {
|
|
|
7
7
|
task(params: LemurTaskParams): Promise<LemurTaskResponse>;
|
|
8
8
|
/**
|
|
9
9
|
* Delete the data for a previously submitted LeMUR request.
|
|
10
|
-
* @param id ID of the LeMUR request
|
|
10
|
+
* @param id - ID of the LeMUR request
|
|
11
11
|
*/
|
|
12
12
|
purgeRequestData(id: string): Promise<PurgeLemurRequestDataResponse>;
|
|
13
13
|
}
|
|
@@ -27,8 +27,8 @@ export declare class RealtimeTranscriber {
|
|
|
27
27
|
forceEndUtterance(): void;
|
|
28
28
|
/**
|
|
29
29
|
* Configure the threshold for how long to wait before ending an utterance. Default is 700ms.
|
|
30
|
-
* @param threshold The duration of the end utterance silence threshold in milliseconds
|
|
31
|
-
*
|
|
30
|
+
* @param threshold - The duration of the end utterance silence threshold in milliseconds.
|
|
31
|
+
* This value must be an integer between 0 and 20_000.
|
|
32
32
|
*/
|
|
33
33
|
configureEndUtteranceSilenceThreshold(threshold: number): void;
|
|
34
34
|
private send;
|