assemblyai 3.1.0 → 3.1.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/README.md +64 -50
- package/dist/index.esm.js +63 -1
- package/dist/index.js +63 -1
- package/dist/services/files/index.d.ts +2 -2
- package/dist/services/lemur/index.d.ts +5 -5
- package/dist/services/transcripts/index.d.ts +25 -5
- package/dist/types/deprecated.d.ts +63 -0
- package/dist/types/files/index.d.ts +2 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/openapi.generated.d.ts +125 -125
- package/dist/types/services/abstractions.d.ts +3 -3
- package/dist/types/transcripts/index.d.ts +20 -0
- package/package.json +10 -5
- package/src/services/files/index.ts +2 -2
- package/src/services/lemur/index.ts +8 -8
- package/src/services/transcripts/index.ts +60 -7
- package/src/types/deprecated.ts +78 -0
- package/src/types/files/index.ts +2 -2
- package/src/types/index.ts +1 -0
- package/src/types/openapi.generated.ts +127 -127
- package/src/types/services/abstractions.ts +3 -3
- package/src/types/transcripts/index.ts +27 -0
- package/src/utils/.gitkeep +0 -0
|
@@ -86,113 +86,10 @@ export type ContentSafetyLabelsResult = {
|
|
|
86
86
|
[key: string]: number;
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
|
-
export type
|
|
89
|
+
export type CreateRealtimeTemporaryTokenParams = {
|
|
90
90
|
/** @description The amount of time until the token expires in seconds */
|
|
91
91
|
expires_in: number;
|
|
92
92
|
};
|
|
93
|
-
/** @description The parameters for creating a transcript */
|
|
94
|
-
export type CreateTranscriptOptionalParameters = {
|
|
95
|
-
/** @description The point in time, in milliseconds, to stop transcribing in your media file */
|
|
96
|
-
audio_end_at?: number;
|
|
97
|
-
/** @description The point in time, in milliseconds, to begin transcribing in your media file */
|
|
98
|
-
audio_start_from?: number;
|
|
99
|
-
/** @description Enable [Auto Chapters](https://www.assemblyai.com/docs/Models/auto_chapters), can be true or false */
|
|
100
|
-
auto_chapters?: boolean;
|
|
101
|
-
/** @description Whether Key Phrases is enabled, either true or false */
|
|
102
|
-
auto_highlights?: boolean;
|
|
103
|
-
/** @description The word boost parameter value */
|
|
104
|
-
boost_param?: TranscriptBoostParam;
|
|
105
|
-
/** @description Enable [Content Moderation](https://www.assemblyai.com/docs/Models/content_moderation), can be true or false */
|
|
106
|
-
content_safety?: boolean;
|
|
107
|
-
/** @description Customize how words are spelled and formatted using to and from values */
|
|
108
|
-
custom_spelling?: TranscriptCustomSpelling[];
|
|
109
|
-
/** @description Whether custom topics is enabled, either true or false */
|
|
110
|
-
custom_topics?: boolean;
|
|
111
|
-
/** @description Transcribe Filler Words, like "umm", in your media file; can be true or false */
|
|
112
|
-
disfluencies?: boolean;
|
|
113
|
-
/** @description Enable [Dual Channel](https://assemblyai.com/docs/Models/speech_recognition#dual-channel-transcription) transcription, can be true or false */
|
|
114
|
-
dual_channel?: boolean;
|
|
115
|
-
/** @description Enable [Entity Detection](https://www.assemblyai.com/docs/Models/entity_detection), can be true or false */
|
|
116
|
-
entity_detection?: boolean;
|
|
117
|
-
/** @description Filter profanity from the transcribed text, can be true or false */
|
|
118
|
-
filter_profanity?: boolean;
|
|
119
|
-
/** @description Enable Text Formatting, can be true or false */
|
|
120
|
-
format_text?: boolean;
|
|
121
|
-
/** @description Enable [Topic Detection](https://www.assemblyai.com/docs/Models/iab_classification), can be true or false */
|
|
122
|
-
iab_categories?: boolean;
|
|
123
|
-
/**
|
|
124
|
-
* @description The language of your audio file. Possible values are found in [Supported Languages](https://www.assemblyai.com/docs/Concepts/supported_languages).
|
|
125
|
-
* The default value is 'en_us'.
|
|
126
|
-
*/
|
|
127
|
-
language_code?: TranscriptLanguageCode | null;
|
|
128
|
-
/** @description Whether [Automatic language detection](https://www.assemblyai.com/docs/Models/speech_recognition#automatic-language-detection) is enabled, either true or false */
|
|
129
|
-
language_detection?: boolean;
|
|
130
|
-
/** @description Enable Automatic Punctuation, can be true or false */
|
|
131
|
-
punctuate?: boolean;
|
|
132
|
-
/** @description Redact PII from the transcribed text using the Redact PII model, can be true or false */
|
|
133
|
-
redact_pii?: boolean;
|
|
134
|
-
/** @description Generate a copy of the original media file with spoken PII "beeped" out, can be true or false. See [PII redaction](https://www.assemblyai.com/docs/Models/pii_redaction) for more details. */
|
|
135
|
-
redact_pii_audio?: boolean;
|
|
136
|
-
/**
|
|
137
|
-
* @description Controls the filetype of the audio created by redact_pii_audio. Currently supports mp3 (default) and wav. See [PII redaction](https://www.assemblyai.com/docs/Models/pii_redaction) for more details.
|
|
138
|
-
* @default mp3
|
|
139
|
-
*/
|
|
140
|
-
redact_pii_audio_quality?: string;
|
|
141
|
-
/** @description The list of PII Redaction policies to enable. See [PII redaction](https://www.assemblyai.com/docs/Models/pii_redaction) for more details. */
|
|
142
|
-
redact_pii_policies?: PiiPolicy[];
|
|
143
|
-
/** @description The replacement logic for detected PII, can be "entity_type" or "hash". See [PII redaction](https://www.assemblyai.com/docs/Models/pii_redaction) for more details. */
|
|
144
|
-
redact_pii_sub?: SubstitutionPolicy | null;
|
|
145
|
-
/** @description Enable [Sentiment Analysis](https://www.assemblyai.com/docs/Models/sentiment_analysis), can be true or false */
|
|
146
|
-
sentiment_analysis?: boolean;
|
|
147
|
-
/** @description Enable [Speaker diarization](https://www.assemblyai.com/docs/Models/speaker_diarization), can be true or false */
|
|
148
|
-
speaker_labels?: boolean;
|
|
149
|
-
/**
|
|
150
|
-
* @description Tell the speaker label model how many speakers it should attempt to identify, up to 10. See [Speaker diarization](https://www.assemblyai.com/docs/Models/speaker_diarization) for more details.
|
|
151
|
-
* @default null
|
|
152
|
-
*/
|
|
153
|
-
speakers_expected?: number | null;
|
|
154
|
-
/**
|
|
155
|
-
* Format: float
|
|
156
|
-
* @description Reject audio files that contain less than this fraction of speech.
|
|
157
|
-
* Valid values are in the range [0, 1] inclusive.
|
|
158
|
-
*
|
|
159
|
-
* @default null
|
|
160
|
-
*/
|
|
161
|
-
speech_threshold?: number | null;
|
|
162
|
-
/** @description Enable [Summarization](https://www.assemblyai.com/docs/Models/summarization), can be true or false */
|
|
163
|
-
summarization?: boolean;
|
|
164
|
-
/**
|
|
165
|
-
* @description The model to summarize the transcript
|
|
166
|
-
* @default informative
|
|
167
|
-
*/
|
|
168
|
-
summary_model?: SummaryModel;
|
|
169
|
-
/**
|
|
170
|
-
* @description The type of summary
|
|
171
|
-
* @default bullets
|
|
172
|
-
*/
|
|
173
|
-
summary_type?: SummaryType;
|
|
174
|
-
/** @description The list of custom topics provided, if custom topics is enabled */
|
|
175
|
-
topics?: string[];
|
|
176
|
-
/**
|
|
177
|
-
* @description The header name which should be sent back with webhook calls
|
|
178
|
-
* @default null
|
|
179
|
-
*/
|
|
180
|
-
webhook_auth_header_name?: string | null;
|
|
181
|
-
/**
|
|
182
|
-
* @description Specify a header name and value to send back with a webhook call for added security
|
|
183
|
-
* @default null
|
|
184
|
-
*/
|
|
185
|
-
webhook_auth_header_value?: string | null;
|
|
186
|
-
/** @description The URL to which AssemblyAI send webhooks upon trancription completion */
|
|
187
|
-
webhook_url?: string;
|
|
188
|
-
/** @description The list of custom vocabulary to boost transcription probability for */
|
|
189
|
-
word_boost?: string[];
|
|
190
|
-
};
|
|
191
|
-
/** @description The parameters for creating a transcript */
|
|
192
|
-
export type CreateTranscriptParameters = CreateTranscriptOptionalParameters & {
|
|
193
|
-
/** @description The URL of the audio or video file to transcribe. */
|
|
194
|
-
audio_url: string;
|
|
195
|
-
};
|
|
196
93
|
/** @description A detected entity */
|
|
197
94
|
export type Entity = {
|
|
198
95
|
/** @description The ending time, in milliseconds, for the detected entity in the audio file */
|
|
@@ -215,12 +112,12 @@ export type Error = {
|
|
|
215
112
|
/** @constant */
|
|
216
113
|
status?: "error";
|
|
217
114
|
};
|
|
218
|
-
export type
|
|
115
|
+
export type LemurActionItemsParams = LemurBaseParams;
|
|
219
116
|
export type LemurActionItemsResponse = LemurBaseResponse & {
|
|
220
117
|
/** @description The response generated by LeMUR */
|
|
221
118
|
response: string;
|
|
222
119
|
};
|
|
223
|
-
export type
|
|
120
|
+
export type LemurBaseParams = {
|
|
224
121
|
/** @description Context to provide the model. This can be a string or a free-form JSON value. */
|
|
225
122
|
context?: OneOf<[
|
|
226
123
|
string,
|
|
@@ -281,7 +178,7 @@ export type LemurQuestionAnswer = {
|
|
|
281
178
|
/** @description The question for LeMUR to answer */
|
|
282
179
|
question: string;
|
|
283
180
|
};
|
|
284
|
-
export type
|
|
181
|
+
export type LemurQuestionAnswerParams = LemurBaseParams & {
|
|
285
182
|
/** @description A list of questions to ask */
|
|
286
183
|
questions: LemurQuestion[];
|
|
287
184
|
};
|
|
@@ -289,7 +186,7 @@ export type LemurQuestionAnswerResponse = LemurBaseResponse & {
|
|
|
289
186
|
/** @description The answers generated by LeMUR and their questions */
|
|
290
187
|
response: LemurQuestionAnswer[];
|
|
291
188
|
};
|
|
292
|
-
export type
|
|
189
|
+
export type LemurSummaryParams = LemurBaseParams & {
|
|
293
190
|
/** @description How you want the summary to be returned. This can be any text. Examples: "TLDR", "bullet points" */
|
|
294
191
|
answer_format?: string;
|
|
295
192
|
};
|
|
@@ -297,7 +194,7 @@ export type LemurSummaryResponse = LemurBaseResponse & {
|
|
|
297
194
|
/** @description The response generated by LeMUR */
|
|
298
195
|
response: string;
|
|
299
196
|
};
|
|
300
|
-
export type
|
|
197
|
+
export type LemurTaskParams = LemurBaseParams & {
|
|
301
198
|
/** @description Your text to prompt the model to produce a desired output, including any context you want to pass into the model. */
|
|
302
199
|
prompt: string;
|
|
303
200
|
};
|
|
@@ -305,6 +202,27 @@ export type LemurTaskResponse = LemurBaseResponse & {
|
|
|
305
202
|
/** @description The response generated by LeMUR */
|
|
306
203
|
response: string;
|
|
307
204
|
};
|
|
205
|
+
export type ListTranscriptParams = {
|
|
206
|
+
/** @description Get transcripts that were created after this transcript ID */
|
|
207
|
+
after_id?: string;
|
|
208
|
+
/** @description Get transcripts that were created before this transcript ID */
|
|
209
|
+
before_id?: string;
|
|
210
|
+
/**
|
|
211
|
+
* Format: date
|
|
212
|
+
* @description Only get transcripts created on this date
|
|
213
|
+
*/
|
|
214
|
+
created_on?: string;
|
|
215
|
+
/**
|
|
216
|
+
* Format: int64
|
|
217
|
+
* @description Maximum amount of transcripts to retrieve
|
|
218
|
+
* @default 10
|
|
219
|
+
*/
|
|
220
|
+
limit?: number;
|
|
221
|
+
/** @description Filter by transcript status */
|
|
222
|
+
status?: TranscriptStatus;
|
|
223
|
+
/** @description Only get throttled transcripts, overrides the status filter */
|
|
224
|
+
throttled_only?: boolean;
|
|
225
|
+
};
|
|
308
226
|
export type PageDetails = {
|
|
309
227
|
current_url: string;
|
|
310
228
|
limit: number;
|
|
@@ -638,26 +556,103 @@ export type TranscriptListItem = {
|
|
|
638
556
|
resource_url: string;
|
|
639
557
|
status: TranscriptStatus;
|
|
640
558
|
};
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
559
|
+
/** @description The parameters for creating a transcript */
|
|
560
|
+
export type TranscriptOptionalParams = {
|
|
561
|
+
/** @description The point in time, in milliseconds, to stop transcribing in your media file */
|
|
562
|
+
audio_end_at?: number;
|
|
563
|
+
/** @description The point in time, in milliseconds, to begin transcribing in your media file */
|
|
564
|
+
audio_start_from?: number;
|
|
565
|
+
/** @description Enable [Auto Chapters](https://www.assemblyai.com/docs/Models/auto_chapters), can be true or false */
|
|
566
|
+
auto_chapters?: boolean;
|
|
567
|
+
/** @description Whether Key Phrases is enabled, either true or false */
|
|
568
|
+
auto_highlights?: boolean;
|
|
569
|
+
/** @description The word boost parameter value */
|
|
570
|
+
boost_param?: TranscriptBoostParam;
|
|
571
|
+
/** @description Enable [Content Moderation](https://www.assemblyai.com/docs/Models/content_moderation), can be true or false */
|
|
572
|
+
content_safety?: boolean;
|
|
573
|
+
/** @description Customize how words are spelled and formatted using to and from values */
|
|
574
|
+
custom_spelling?: TranscriptCustomSpelling[];
|
|
575
|
+
/** @description Whether custom topics is enabled, either true or false */
|
|
576
|
+
custom_topics?: boolean;
|
|
577
|
+
/** @description Transcribe Filler Words, like "umm", in your media file; can be true or false */
|
|
578
|
+
disfluencies?: boolean;
|
|
579
|
+
/** @description Enable [Dual Channel](https://assemblyai.com/docs/Models/speech_recognition#dual-channel-transcription) transcription, can be true or false */
|
|
580
|
+
dual_channel?: boolean;
|
|
581
|
+
/** @description Enable [Entity Detection](https://www.assemblyai.com/docs/Models/entity_detection), can be true or false */
|
|
582
|
+
entity_detection?: boolean;
|
|
583
|
+
/** @description Filter profanity from the transcribed text, can be true or false */
|
|
584
|
+
filter_profanity?: boolean;
|
|
585
|
+
/** @description Enable Text Formatting, can be true or false */
|
|
586
|
+
format_text?: boolean;
|
|
587
|
+
/** @description Enable [Topic Detection](https://www.assemblyai.com/docs/Models/iab_classification), can be true or false */
|
|
588
|
+
iab_categories?: boolean;
|
|
646
589
|
/**
|
|
647
|
-
*
|
|
648
|
-
*
|
|
590
|
+
* @description The language of your audio file. Possible values are found in [Supported Languages](https://www.assemblyai.com/docs/Concepts/supported_languages).
|
|
591
|
+
* The default value is 'en_us'.
|
|
649
592
|
*/
|
|
650
|
-
|
|
593
|
+
language_code?: TranscriptLanguageCode | null;
|
|
594
|
+
/** @description Whether [Automatic language detection](https://www.assemblyai.com/docs/Models/speech_recognition#automatic-language-detection) is enabled, either true or false */
|
|
595
|
+
language_detection?: boolean;
|
|
596
|
+
/** @description Enable Automatic Punctuation, can be true or false */
|
|
597
|
+
punctuate?: boolean;
|
|
598
|
+
/** @description Redact PII from the transcribed text using the Redact PII model, can be true or false */
|
|
599
|
+
redact_pii?: boolean;
|
|
600
|
+
/** @description Generate a copy of the original media file with spoken PII "beeped" out, can be true or false. See [PII redaction](https://www.assemblyai.com/docs/Models/pii_redaction) for more details. */
|
|
601
|
+
redact_pii_audio?: boolean;
|
|
651
602
|
/**
|
|
652
|
-
*
|
|
653
|
-
* @
|
|
654
|
-
* @default 10
|
|
603
|
+
* @description Controls the filetype of the audio created by redact_pii_audio. Currently supports mp3 (default) and wav. See [PII redaction](https://www.assemblyai.com/docs/Models/pii_redaction) for more details.
|
|
604
|
+
* @default mp3
|
|
655
605
|
*/
|
|
656
|
-
|
|
657
|
-
/** @description
|
|
658
|
-
|
|
659
|
-
/** @description
|
|
660
|
-
|
|
606
|
+
redact_pii_audio_quality?: string;
|
|
607
|
+
/** @description The list of PII Redaction policies to enable. See [PII redaction](https://www.assemblyai.com/docs/Models/pii_redaction) for more details. */
|
|
608
|
+
redact_pii_policies?: PiiPolicy[];
|
|
609
|
+
/** @description The replacement logic for detected PII, can be "entity_type" or "hash". See [PII redaction](https://www.assemblyai.com/docs/Models/pii_redaction) for more details. */
|
|
610
|
+
redact_pii_sub?: SubstitutionPolicy | null;
|
|
611
|
+
/** @description Enable [Sentiment Analysis](https://www.assemblyai.com/docs/Models/sentiment_analysis), can be true or false */
|
|
612
|
+
sentiment_analysis?: boolean;
|
|
613
|
+
/** @description Enable [Speaker diarization](https://www.assemblyai.com/docs/Models/speaker_diarization), can be true or false */
|
|
614
|
+
speaker_labels?: boolean;
|
|
615
|
+
/**
|
|
616
|
+
* @description Tell the speaker label model how many speakers it should attempt to identify, up to 10. See [Speaker diarization](https://www.assemblyai.com/docs/Models/speaker_diarization) for more details.
|
|
617
|
+
* @default null
|
|
618
|
+
*/
|
|
619
|
+
speakers_expected?: number | null;
|
|
620
|
+
/**
|
|
621
|
+
* Format: float
|
|
622
|
+
* @description Reject audio files that contain less than this fraction of speech.
|
|
623
|
+
* Valid values are in the range [0, 1] inclusive.
|
|
624
|
+
*
|
|
625
|
+
* @default null
|
|
626
|
+
*/
|
|
627
|
+
speech_threshold?: number | null;
|
|
628
|
+
/** @description Enable [Summarization](https://www.assemblyai.com/docs/Models/summarization), can be true or false */
|
|
629
|
+
summarization?: boolean;
|
|
630
|
+
/**
|
|
631
|
+
* @description The model to summarize the transcript
|
|
632
|
+
* @default informative
|
|
633
|
+
*/
|
|
634
|
+
summary_model?: SummaryModel;
|
|
635
|
+
/**
|
|
636
|
+
* @description The type of summary
|
|
637
|
+
* @default bullets
|
|
638
|
+
*/
|
|
639
|
+
summary_type?: SummaryType;
|
|
640
|
+
/** @description The list of custom topics provided, if custom topics is enabled */
|
|
641
|
+
topics?: string[];
|
|
642
|
+
/**
|
|
643
|
+
* @description The header name which should be sent back with webhook calls
|
|
644
|
+
* @default null
|
|
645
|
+
*/
|
|
646
|
+
webhook_auth_header_name?: string | null;
|
|
647
|
+
/**
|
|
648
|
+
* @description Specify a header name and value to send back with a webhook call for added security
|
|
649
|
+
* @default null
|
|
650
|
+
*/
|
|
651
|
+
webhook_auth_header_value?: string | null;
|
|
652
|
+
/** @description The URL to which AssemblyAI send webhooks upon trancription completion */
|
|
653
|
+
webhook_url?: string;
|
|
654
|
+
/** @description The list of custom vocabulary to boost transcription probability for */
|
|
655
|
+
word_boost?: string[];
|
|
661
656
|
};
|
|
662
657
|
export type TranscriptParagraph = {
|
|
663
658
|
/** Format: double */
|
|
@@ -667,6 +662,11 @@ export type TranscriptParagraph = {
|
|
|
667
662
|
text: string;
|
|
668
663
|
words: TranscriptWord[];
|
|
669
664
|
};
|
|
665
|
+
/** @description The parameters for creating a transcript */
|
|
666
|
+
export type TranscriptParams = TranscriptOptionalParams & {
|
|
667
|
+
/** @description The URL of the audio or video file to transcribe. */
|
|
668
|
+
audio_url: string;
|
|
669
|
+
};
|
|
670
670
|
export type TranscriptSentence = {
|
|
671
671
|
/** Format: double */
|
|
672
672
|
confidence: number;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Interface for classes that can create resources.
|
|
3
3
|
* @template T The type of the resource.
|
|
4
|
-
* @template
|
|
4
|
+
* @template Params The type of the parameters required to create the resource.
|
|
5
5
|
*/
|
|
6
|
-
interface Createable<T,
|
|
6
|
+
interface Createable<T, Params, Options = Record<string, unknown>> {
|
|
7
7
|
/**
|
|
8
8
|
* Create a new resource.
|
|
9
9
|
* @param params The parameters of the new resource.
|
|
10
10
|
* @param options The options used for creating the new resource.
|
|
11
11
|
* @return A promise that resolves to the newly created resource.
|
|
12
12
|
*/
|
|
13
|
-
create(params:
|
|
13
|
+
create(params: Params, options?: Options): Promise<T>;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Interface for classes that can retrieve resources.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { FileUploadParams } from "../files";
|
|
2
|
+
import { TranscriptParams } from "../openapi.generated";
|
|
1
3
|
export type PollingOptions = {
|
|
2
4
|
/**
|
|
3
5
|
* The amount of time to wait between polling requests.
|
|
@@ -17,3 +19,21 @@ export type CreateTranscriptOptions = {
|
|
|
17
19
|
*/
|
|
18
20
|
poll?: boolean;
|
|
19
21
|
} & PollingOptions;
|
|
22
|
+
/**
|
|
23
|
+
* The audio to transcribe. This can be a public URL, a local file path, a readable file stream, or a file buffer.
|
|
24
|
+
*/
|
|
25
|
+
export type AudioToTranscribe = FileUploadParams;
|
|
26
|
+
/**
|
|
27
|
+
* The parameters to transcribe an audio file.
|
|
28
|
+
*/
|
|
29
|
+
export type TranscribeParams = {
|
|
30
|
+
audio: AudioToTranscribe;
|
|
31
|
+
} & Omit<TranscriptParams, "audio_url">;
|
|
32
|
+
/**
|
|
33
|
+
* The parameters to start the transcription of an audio file.
|
|
34
|
+
*/
|
|
35
|
+
export type SubmitParams = TranscribeParams;
|
|
36
|
+
/**
|
|
37
|
+
* The options to transcribe an audio file, including polling options.
|
|
38
|
+
*/
|
|
39
|
+
export type TranscribeOptions = PollingOptions;
|
package/package.json
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assemblyai",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "The AssemblyAI Node.js SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async and real-time transcription, as well as the latest LeMUR models.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"typings": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"import": "./dist/index.esm.js",
|
|
12
|
+
"node": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
9
15
|
"repository": {
|
|
10
16
|
"type": "git",
|
|
11
17
|
"url": "git+https://github.com/AssemblyAI/assemblyai-node-sdk.git"
|
|
@@ -18,10 +24,10 @@
|
|
|
18
24
|
"scripts": {
|
|
19
25
|
"build": "pnpm clean && pnpm rollup -c",
|
|
20
26
|
"clean": "rimraf dist",
|
|
21
|
-
"lint": "eslint -c .eslintrc.json 'src
|
|
27
|
+
"lint": "eslint -c .eslintrc.json '{src,tests}/**/*.{js,ts}'",
|
|
22
28
|
"test": "pnpm lint && pnpm test:unit",
|
|
23
29
|
"test:unit": "jest --config jest.config.rollup.ts",
|
|
24
|
-
"format": "prettier --write
|
|
30
|
+
"format": "prettier '**/*' --write",
|
|
25
31
|
"generate-types": "tsx ./scripts/generate-types.ts && pnpm format",
|
|
26
32
|
"copybara:dry-run": "./copybara.sh dry_run --init-history",
|
|
27
33
|
"copybara:pr": "./copybara.sh sync_out --init-history"
|
|
@@ -38,8 +44,7 @@
|
|
|
38
44
|
"homepage": "https://www.assemblyai.com/docs",
|
|
39
45
|
"files": [
|
|
40
46
|
"dist",
|
|
41
|
-
"src"
|
|
42
|
-
"types"
|
|
47
|
+
"src"
|
|
43
48
|
],
|
|
44
49
|
"devDependencies": {
|
|
45
50
|
"@types/jest": "^29.5.5",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// to keep the assemblyai module more compatible. Some fs polyfills don't include `createReadStream`.
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import { BaseService } from "../base";
|
|
5
|
-
import { UploadedFile,
|
|
5
|
+
import { UploadedFile, FileUploadParams, FileUploadData } from "../..";
|
|
6
6
|
|
|
7
7
|
export class FileService extends BaseService {
|
|
8
8
|
/**
|
|
@@ -10,7 +10,7 @@ export class FileService extends BaseService {
|
|
|
10
10
|
* @param input The local file path to upload, or a stream or buffer of the file to upload.
|
|
11
11
|
* @return A promise that resolves to the uploaded file URL.
|
|
12
12
|
*/
|
|
13
|
-
async upload(input:
|
|
13
|
+
async upload(input: FileUploadParams): Promise<string> {
|
|
14
14
|
let fileData: FileUploadData;
|
|
15
15
|
if (typeof input === "string") fileData = fs.createReadStream(input);
|
|
16
16
|
else fileData = input;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
LemurSummaryParams,
|
|
3
|
+
LemurActionItemsParams,
|
|
4
|
+
LemurQuestionAnswerParams,
|
|
5
|
+
LemurTaskParams,
|
|
6
6
|
LemurSummaryResponse,
|
|
7
7
|
LemurQuestionAnswerResponse,
|
|
8
8
|
LemurActionItemsResponse,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import { BaseService } from "../base";
|
|
13
13
|
|
|
14
14
|
export class LemurService extends BaseService {
|
|
15
|
-
summary(params:
|
|
15
|
+
summary(params: LemurSummaryParams): Promise<LemurSummaryResponse> {
|
|
16
16
|
return this.fetchJson<LemurSummaryResponse>("/lemur/v3/generate/summary", {
|
|
17
17
|
method: "POST",
|
|
18
18
|
body: JSON.stringify(params),
|
|
@@ -20,7 +20,7 @@ export class LemurService extends BaseService {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
questionAnswer(
|
|
23
|
-
params:
|
|
23
|
+
params: LemurQuestionAnswerParams
|
|
24
24
|
): Promise<LemurQuestionAnswerResponse> {
|
|
25
25
|
return this.fetchJson<LemurQuestionAnswerResponse>(
|
|
26
26
|
"/lemur/v3/generate/question-answer",
|
|
@@ -32,7 +32,7 @@ export class LemurService extends BaseService {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
actionItems(
|
|
35
|
-
params:
|
|
35
|
+
params: LemurActionItemsParams
|
|
36
36
|
): Promise<LemurActionItemsResponse> {
|
|
37
37
|
return this.fetchJson<LemurActionItemsResponse>(
|
|
38
38
|
"/lemur/v3/generate/action-items",
|
|
@@ -43,7 +43,7 @@ export class LemurService extends BaseService {
|
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
task(params:
|
|
46
|
+
task(params: LemurTaskParams): Promise<LemurTaskResponse> {
|
|
47
47
|
return this.fetchJson<LemurTaskResponse>("/lemur/v3/generate/task", {
|
|
48
48
|
method: "POST",
|
|
49
49
|
body: JSON.stringify(params),
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
SentencesResponse,
|
|
5
5
|
Transcript,
|
|
6
6
|
TranscriptList,
|
|
7
|
-
|
|
7
|
+
TranscriptParams,
|
|
8
8
|
CreateTranscriptOptions,
|
|
9
9
|
Createable,
|
|
10
10
|
Deletable,
|
|
@@ -12,17 +12,20 @@ import {
|
|
|
12
12
|
Retrieveable,
|
|
13
13
|
SubtitleFormat,
|
|
14
14
|
RedactedAudioResponse,
|
|
15
|
-
|
|
15
|
+
ListTranscriptParams,
|
|
16
16
|
WordSearchResponse,
|
|
17
17
|
BaseServiceParams,
|
|
18
18
|
PollingOptions,
|
|
19
|
+
TranscribeParams,
|
|
20
|
+
TranscribeOptions,
|
|
21
|
+
SubmitParams,
|
|
19
22
|
} from "../..";
|
|
20
23
|
import { FileService } from "../files";
|
|
21
24
|
|
|
22
25
|
export class TranscriptService
|
|
23
26
|
extends BaseService
|
|
24
27
|
implements
|
|
25
|
-
Createable<Transcript,
|
|
28
|
+
Createable<Transcript, TranscriptParams, CreateTranscriptOptions>,
|
|
26
29
|
Retrieveable<Transcript>,
|
|
27
30
|
Deletable<Transcript>,
|
|
28
31
|
Listable<TranscriptList>
|
|
@@ -31,14 +34,58 @@ export class TranscriptService
|
|
|
31
34
|
super(params);
|
|
32
35
|
}
|
|
33
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Transcribe an audio file. This will create a transcript and wait until the transcript status is "completed" or "error".
|
|
39
|
+
* @param params The parameters to transcribe an audio file.
|
|
40
|
+
* @param options The options to transcribe an audio file.
|
|
41
|
+
* @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
|
|
42
|
+
*/
|
|
43
|
+
async transcribe(
|
|
44
|
+
params: TranscribeParams,
|
|
45
|
+
options?: TranscribeOptions
|
|
46
|
+
): Promise<Transcript> {
|
|
47
|
+
const transcript = await this.submit(params);
|
|
48
|
+
return await this.waitUntilReady(transcript.id, options);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Submits a transcription job for an audio file. This will not wait until the transcript status is "completed" or "error".
|
|
53
|
+
* @param params The parameters to start the transcription of an audio file.
|
|
54
|
+
* @returns A promise that resolves to the queued transcript.
|
|
55
|
+
*/
|
|
56
|
+
async submit(params: SubmitParams): Promise<Transcript> {
|
|
57
|
+
const { audio, ...createParams } = params;
|
|
58
|
+
let audioUrl;
|
|
59
|
+
if (typeof audio === "string") {
|
|
60
|
+
const path = getPath(audio);
|
|
61
|
+
if (path !== null) {
|
|
62
|
+
// audio is local path, upload local file
|
|
63
|
+
audioUrl = await this.files.upload(path);
|
|
64
|
+
} else {
|
|
65
|
+
// audio is not a local path, assume it's a URL
|
|
66
|
+
audioUrl = audio;
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
// audio is of uploadable type
|
|
70
|
+
audioUrl = await this.files.upload(audio);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const data = await this.fetchJson<Transcript>("/v2/transcript", {
|
|
74
|
+
method: "POST",
|
|
75
|
+
body: JSON.stringify({ ...createParams, audio_url: audioUrl }),
|
|
76
|
+
});
|
|
77
|
+
return data;
|
|
78
|
+
}
|
|
79
|
+
|
|
34
80
|
/**
|
|
35
81
|
* Create a transcript.
|
|
36
82
|
* @param params The parameters to create a transcript.
|
|
37
83
|
* @param options The options used for creating the new transcript.
|
|
38
|
-
* @returns A promise that resolves to the
|
|
84
|
+
* @returns A promise that resolves to the transcript.
|
|
85
|
+
* @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
|
|
39
86
|
*/
|
|
40
87
|
async create(
|
|
41
|
-
params:
|
|
88
|
+
params: TranscriptParams,
|
|
42
89
|
options?: CreateTranscriptOptions
|
|
43
90
|
): Promise<Transcript> {
|
|
44
91
|
const path = getPath(params.audio_url);
|
|
@@ -59,6 +106,12 @@ export class TranscriptService
|
|
|
59
106
|
return data;
|
|
60
107
|
}
|
|
61
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Wait until the transcript ready, either the status is "completed" or "error".
|
|
111
|
+
* @param transcriptId The ID of the transcript.
|
|
112
|
+
* @param options The options to wait until the transcript is ready.
|
|
113
|
+
* @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
|
|
114
|
+
*/
|
|
62
115
|
async waitUntilReady(
|
|
63
116
|
transcriptId: string,
|
|
64
117
|
options?: PollingOptions
|
|
@@ -96,7 +149,7 @@ export class TranscriptService
|
|
|
96
149
|
* @param parameters The parameters to filter the transcript list by, or the URL to retrieve the transcript list from.
|
|
97
150
|
*/
|
|
98
151
|
async list(
|
|
99
|
-
parameters?:
|
|
152
|
+
parameters?: ListTranscriptParams | string
|
|
100
153
|
): Promise<TranscriptList> {
|
|
101
154
|
let url = "/v2/transcript";
|
|
102
155
|
if (typeof parameters === "string") {
|
|
@@ -105,7 +158,7 @@ export class TranscriptService
|
|
|
105
158
|
url = `${url}?${new URLSearchParams(
|
|
106
159
|
Object.keys(parameters).map((key) => [
|
|
107
160
|
key,
|
|
108
|
-
parameters[key as keyof
|
|
161
|
+
parameters[key as keyof ListTranscriptParams]?.toString() || "",
|
|
109
162
|
])
|
|
110
163
|
)}`;
|
|
111
164
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { FileUploadParams } from "./files";
|
|
2
|
+
import {
|
|
3
|
+
CreateRealtimeTemporaryTokenParams,
|
|
4
|
+
LemurActionItemsParams,
|
|
5
|
+
LemurBaseParams,
|
|
6
|
+
LemurQuestionAnswerParams,
|
|
7
|
+
LemurSummaryParams,
|
|
8
|
+
LemurTaskParams,
|
|
9
|
+
ListTranscriptParams,
|
|
10
|
+
TranscriptOptionalParams,
|
|
11
|
+
TranscriptParams,
|
|
12
|
+
} from "./openapi.generated";
|
|
13
|
+
import { SubmitParams, TranscribeParams } from "./transcripts";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated
|
|
17
|
+
* Use`FileUploadParams` instead.
|
|
18
|
+
*/
|
|
19
|
+
export type FileUploadParameters = FileUploadParams;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated
|
|
23
|
+
* Use`TranscribeParams` instead.
|
|
24
|
+
*/
|
|
25
|
+
export type TranscribeParameters = TranscribeParams;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated
|
|
29
|
+
* Use`SubmitParams` instead.
|
|
30
|
+
*/
|
|
31
|
+
export type SubmitParameters = SubmitParams;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated
|
|
35
|
+
* Use`CreateRealtimeTemporaryTokenParams` instead.
|
|
36
|
+
*/
|
|
37
|
+
export type CreateRealtimeTemporaryTokenParameters =
|
|
38
|
+
CreateRealtimeTemporaryTokenParams;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated
|
|
41
|
+
* Use`LemurActionItemsParams` instead.
|
|
42
|
+
*/
|
|
43
|
+
export type LemurActionItemsParameters = LemurActionItemsParams;
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated
|
|
46
|
+
* Use`LemurBaseParams` instead.
|
|
47
|
+
*/
|
|
48
|
+
export type LemurBaseParameters = LemurBaseParams;
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated
|
|
51
|
+
* Use`LemurQuestionAnswerParams` instead.
|
|
52
|
+
*/
|
|
53
|
+
export type LemurQuestionAnswerParameters = LemurQuestionAnswerParams;
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated
|
|
56
|
+
* Use`LemurSummaryParams` instead.
|
|
57
|
+
*/
|
|
58
|
+
export type LemurSummaryParameters = LemurSummaryParams;
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated
|
|
61
|
+
* Use`LemurTaskParams` instead.
|
|
62
|
+
*/
|
|
63
|
+
export type LemurTaskParameters = LemurTaskParams;
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated
|
|
66
|
+
* Use`ListTranscriptParams` instead.
|
|
67
|
+
*/
|
|
68
|
+
export type TranscriptListParameters = ListTranscriptParams;
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated
|
|
71
|
+
* Use`TranscriptOptionalParams` instead.
|
|
72
|
+
*/
|
|
73
|
+
export type CreateTranscriptOptionalParameters = TranscriptOptionalParams;
|
|
74
|
+
/**
|
|
75
|
+
* @deprecated
|
|
76
|
+
* Use`TranscriptParams` instead.
|
|
77
|
+
*/
|
|
78
|
+
export type CreateTranscriptParameters = TranscriptParams;
|