assemblyai 4.3.2 → 4.3.4
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 +33 -0
- package/README.md +9 -4
- package/dist/types/asyncapi.generated.d.ts +1 -1
- package/dist/types/openapi.generated.d.ts +170 -84
- package/package.json +25 -25
- package/src/polyfills/fs/index.ts +2 -2
- package/src/polyfills/fs/node.ts +1 -1
- package/src/polyfills/streams/index.ts +2 -2
- package/src/services/base.ts +2 -2
- package/src/services/lemur/index.ts +4 -4
- package/src/services/realtime/factory.ts +1 -1
- package/src/services/realtime/service.ts +4 -4
- package/src/services/transcripts/index.ts +12 -9
- package/src/types/asyncapi.generated.ts +3 -3
- package/src/types/openapi.generated.ts +174 -88
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assemblyai",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.4",
|
|
4
4
|
"description": "The AssemblyAI JavaScript 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
|
"engines": {
|
|
6
6
|
"node": ">=18"
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"build": "pnpm clean && pnpm rollup -c",
|
|
70
|
-
"clean": "rimraf dist/*",
|
|
71
|
-
"lint": "eslint -c .eslintrc.json '{src,tests}/**/*.{js,ts}' && publint",
|
|
70
|
+
"clean": "rimraf dist/* && rimraf temp/* && rimraf temp-docs/*",
|
|
71
|
+
"lint": "eslint -c .eslintrc.json '{src,tests}/**/*.{js,ts}' && publint && tsc --noEmit -p tsconfig.json",
|
|
72
72
|
"test": "jest --config jest.config.js",
|
|
73
73
|
"format": "prettier '**/*' --write",
|
|
74
74
|
"generate-types": "tsx ./scripts/generate-types.ts && pnpm format",
|
|
@@ -98,36 +98,36 @@
|
|
|
98
98
|
"docs"
|
|
99
99
|
],
|
|
100
100
|
"devDependencies": {
|
|
101
|
-
"@babel/preset-env": "^7.
|
|
101
|
+
"@babel/preset-env": "^7.24.0",
|
|
102
102
|
"@babel/preset-typescript": "^7.23.3",
|
|
103
103
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
104
104
|
"@rollup/plugin-terser": "^0.4.4",
|
|
105
|
-
"@rollup/plugin-typescript": "^11.1.
|
|
106
|
-
"@types/jest": "^29.5.
|
|
107
|
-
"@types/node": "^
|
|
108
|
-
"@types/websocket": "^1.0.
|
|
109
|
-
"@types/ws": "^8.5.
|
|
110
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
111
|
-
"dotenv": "^16.
|
|
112
|
-
"eslint": "^8.
|
|
105
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
106
|
+
"@types/jest": "^29.5.12",
|
|
107
|
+
"@types/node": "^18.11.9",
|
|
108
|
+
"@types/websocket": "^1.0.10",
|
|
109
|
+
"@types/ws": "^8.5.10",
|
|
110
|
+
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
|
111
|
+
"dotenv": "^16.4.5",
|
|
112
|
+
"eslint": "^8.57.0",
|
|
113
113
|
"eslint-plugin-tsdoc": "^0.2.17",
|
|
114
|
-
"jest": "^29.
|
|
115
|
-
"jest-cli": "^29.
|
|
114
|
+
"jest": "^29.7.0",
|
|
115
|
+
"jest-cli": "^29.7.0",
|
|
116
116
|
"jest-fetch-mock": "^3.0.3",
|
|
117
117
|
"jest-junit": "^16.0.0",
|
|
118
|
-
"jest-websocket-mock": "^2.
|
|
119
|
-
"mock-socket": "^9.
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"
|
|
125
|
-
"
|
|
126
|
-
"ts-jest": "^29.1.0",
|
|
118
|
+
"jest-websocket-mock": "^2.5.0",
|
|
119
|
+
"mock-socket": "^9.3.1",
|
|
120
|
+
"openapi-typescript": "^6.7.5",
|
|
121
|
+
"prettier": "^3.2.5",
|
|
122
|
+
"publint": "^0.2.7",
|
|
123
|
+
"rimraf": "^5.0.5",
|
|
124
|
+
"rollup": "^4.13.0",
|
|
125
|
+
"ts-jest": "^29.1.2",
|
|
127
126
|
"tslib": "^2.5.3",
|
|
128
|
-
"typescript": "^5.
|
|
127
|
+
"typescript": "^5.4.2",
|
|
128
|
+
"typedoc": "^0.25.12"
|
|
129
129
|
},
|
|
130
130
|
"dependencies": {
|
|
131
|
-
"ws": "^8.
|
|
131
|
+
"ws": "^8.16.0"
|
|
132
132
|
}
|
|
133
133
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export const readFile = async function (
|
|
2
2
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3
|
-
path: string
|
|
3
|
+
path: string,
|
|
4
4
|
): Promise<ReadableStream<Uint8Array>> {
|
|
5
5
|
throw new Error(
|
|
6
|
-
"Interacting with the file system is not supported in this environment."
|
|
6
|
+
"Interacting with the file system is not supported in this environment.",
|
|
7
7
|
);
|
|
8
8
|
};
|
package/src/polyfills/fs/node.ts
CHANGED
package/src/services/base.ts
CHANGED
|
@@ -12,7 +12,7 @@ export abstract class BaseService {
|
|
|
12
12
|
constructor(private params: BaseServiceParams) {}
|
|
13
13
|
protected async fetch(
|
|
14
14
|
input: string,
|
|
15
|
-
init?: RequestInit | undefined
|
|
15
|
+
init?: RequestInit | undefined,
|
|
16
16
|
): Promise<Response> {
|
|
17
17
|
init = init ?? {};
|
|
18
18
|
init.headers = init.headers ?? {};
|
|
@@ -45,7 +45,7 @@ export abstract class BaseService {
|
|
|
45
45
|
|
|
46
46
|
protected async fetchJson<T>(
|
|
47
47
|
input: string,
|
|
48
|
-
init?: RequestInit | undefined
|
|
48
|
+
init?: RequestInit | undefined,
|
|
49
49
|
): Promise<T> {
|
|
50
50
|
const response = await this.fetch(input, init);
|
|
51
51
|
return response.json() as Promise<T>;
|
|
@@ -20,26 +20,26 @@ export class LemurService extends BaseService {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
questionAnswer(
|
|
23
|
-
params: LemurQuestionAnswerParams
|
|
23
|
+
params: LemurQuestionAnswerParams,
|
|
24
24
|
): Promise<LemurQuestionAnswerResponse> {
|
|
25
25
|
return this.fetchJson<LemurQuestionAnswerResponse>(
|
|
26
26
|
"/lemur/v3/generate/question-answer",
|
|
27
27
|
{
|
|
28
28
|
method: "POST",
|
|
29
29
|
body: JSON.stringify(params),
|
|
30
|
-
}
|
|
30
|
+
},
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
actionItems(
|
|
35
|
-
params: LemurActionItemsParams
|
|
35
|
+
params: LemurActionItemsParams,
|
|
36
36
|
): Promise<LemurActionItemsResponse> {
|
|
37
37
|
return this.fetchJson<LemurActionItemsResponse>(
|
|
38
38
|
"/lemur/v3/generate/action-items",
|
|
39
39
|
{
|
|
40
40
|
method: "POST",
|
|
41
41
|
body: JSON.stringify(params),
|
|
42
|
-
}
|
|
42
|
+
},
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -93,15 +93,15 @@ export class RealtimeTranscriber {
|
|
|
93
93
|
on(event: "open", listener: (event: SessionBeginsEventData) => void): void;
|
|
94
94
|
on(
|
|
95
95
|
event: "transcript",
|
|
96
|
-
listener: (transcript: RealtimeTranscript) => void
|
|
96
|
+
listener: (transcript: RealtimeTranscript) => void,
|
|
97
97
|
): void;
|
|
98
98
|
on(
|
|
99
99
|
event: "transcript.partial",
|
|
100
|
-
listener: (transcript: PartialTranscript) => void
|
|
100
|
+
listener: (transcript: PartialTranscript) => void,
|
|
101
101
|
): void;
|
|
102
102
|
on(
|
|
103
103
|
event: "transcript.final",
|
|
104
|
-
listener: (transcript: FinalTranscript) => void
|
|
104
|
+
listener: (transcript: FinalTranscript) => void,
|
|
105
105
|
): void;
|
|
106
106
|
on(event: "error", listener: (error: Error) => void): void;
|
|
107
107
|
on(event: "close", listener: (code: number, reason: string) => void): void;
|
|
@@ -135,7 +135,7 @@ export class RealtimeTranscriber {
|
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
137
|
this.configureEndUtteranceSilenceThreshold(
|
|
138
|
-
this.endUtteranceSilenceThreshold
|
|
138
|
+
this.endUtteranceSilenceThreshold,
|
|
139
139
|
);
|
|
140
140
|
};
|
|
141
141
|
|
|
@@ -20,7 +20,10 @@ import { FileService } from "../files";
|
|
|
20
20
|
import { getPath } from "../../utils/path";
|
|
21
21
|
|
|
22
22
|
export class TranscriptService extends BaseService {
|
|
23
|
-
constructor(
|
|
23
|
+
constructor(
|
|
24
|
+
params: BaseServiceParams,
|
|
25
|
+
private files: FileService,
|
|
26
|
+
) {
|
|
24
27
|
super(params);
|
|
25
28
|
}
|
|
26
29
|
|
|
@@ -32,7 +35,7 @@ export class TranscriptService extends BaseService {
|
|
|
32
35
|
*/
|
|
33
36
|
async transcribe(
|
|
34
37
|
params: TranscribeParams,
|
|
35
|
-
options?: TranscribeOptions
|
|
38
|
+
options?: TranscribeOptions,
|
|
36
39
|
): Promise<Transcript> {
|
|
37
40
|
const transcript = await this.submit(params);
|
|
38
41
|
return await this.waitUntilReady(transcript.id, options);
|
|
@@ -82,7 +85,7 @@ export class TranscriptService extends BaseService {
|
|
|
82
85
|
*/
|
|
83
86
|
async create(
|
|
84
87
|
params: TranscriptParams,
|
|
85
|
-
options?: CreateTranscriptOptions
|
|
88
|
+
options?: CreateTranscriptOptions,
|
|
86
89
|
): Promise<Transcript> {
|
|
87
90
|
const path = getPath(params.audio_url);
|
|
88
91
|
if (path !== null) {
|
|
@@ -110,7 +113,7 @@ export class TranscriptService extends BaseService {
|
|
|
110
113
|
*/
|
|
111
114
|
async waitUntilReady(
|
|
112
115
|
transcriptId: string,
|
|
113
|
-
options?: PollingOptions
|
|
116
|
+
options?: PollingOptions,
|
|
114
117
|
): Promise<Transcript> {
|
|
115
118
|
const pollingInterval = options?.pollingInterval ?? 3_000;
|
|
116
119
|
const pollingTimeout = options?.pollingTimeout ?? -1;
|
|
@@ -153,7 +156,7 @@ export class TranscriptService extends BaseService {
|
|
|
153
156
|
Object.keys(params).map((key) => [
|
|
154
157
|
key,
|
|
155
158
|
params[key as keyof ListTranscriptParams]?.toString() || "",
|
|
156
|
-
])
|
|
159
|
+
]),
|
|
157
160
|
)}`;
|
|
158
161
|
}
|
|
159
162
|
const data = await this.fetchJson<TranscriptList>(url);
|
|
@@ -186,7 +189,7 @@ export class TranscriptService extends BaseService {
|
|
|
186
189
|
wordSearch(id: string, words: string[]): Promise<WordSearchResponse> {
|
|
187
190
|
const params = new URLSearchParams({ words: words.join(",") });
|
|
188
191
|
return this.fetchJson<WordSearchResponse>(
|
|
189
|
-
`/v2/transcript/${id}/word-search?${params.toString()}
|
|
192
|
+
`/v2/transcript/${id}/word-search?${params.toString()}`,
|
|
190
193
|
);
|
|
191
194
|
}
|
|
192
195
|
|
|
@@ -206,7 +209,7 @@ export class TranscriptService extends BaseService {
|
|
|
206
209
|
*/
|
|
207
210
|
paragraphs(id: string): Promise<ParagraphsResponse> {
|
|
208
211
|
return this.fetchJson<ParagraphsResponse>(
|
|
209
|
-
`/v2/transcript/${id}/paragraphs
|
|
212
|
+
`/v2/transcript/${id}/paragraphs`,
|
|
210
213
|
);
|
|
211
214
|
}
|
|
212
215
|
|
|
@@ -220,7 +223,7 @@ export class TranscriptService extends BaseService {
|
|
|
220
223
|
async subtitles(
|
|
221
224
|
id: string,
|
|
222
225
|
format: SubtitleFormat = "srt",
|
|
223
|
-
chars_per_caption?: number
|
|
226
|
+
chars_per_caption?: number,
|
|
224
227
|
): Promise<string> {
|
|
225
228
|
let url = `/v2/transcript/${id}/${format}`;
|
|
226
229
|
if (chars_per_caption) {
|
|
@@ -239,7 +242,7 @@ export class TranscriptService extends BaseService {
|
|
|
239
242
|
*/
|
|
240
243
|
redactions(id: string): Promise<RedactedAudioResponse> {
|
|
241
244
|
return this.fetchJson<RedactedAudioResponse>(
|
|
242
|
-
`/v2/transcript/${id}/redacted-audio
|
|
245
|
+
`/v2/transcript/${id}/redacted-audio`,
|
|
243
246
|
);
|
|
244
247
|
}
|
|
245
248
|
}
|
|
@@ -11,8 +11,8 @@ type XOR<T, U> = T | U extends object
|
|
|
11
11
|
type OneOf<T extends any[]> = T extends [infer Only]
|
|
12
12
|
? Only
|
|
13
13
|
: T extends [infer A, infer B, ...infer Rest]
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
? OneOf<[XOR<A, B>, ...Rest]>
|
|
15
|
+
: never;
|
|
16
16
|
|
|
17
17
|
/* eslint-enable */
|
|
18
18
|
|
|
@@ -149,7 +149,7 @@ export type SessionTerminated = RealtimeBaseMessage & {
|
|
|
149
149
|
|
|
150
150
|
export type TerminateSession = {
|
|
151
151
|
/**
|
|
152
|
-
* Set to true to end your
|
|
152
|
+
* Set to true to end your streaming session forever
|
|
153
153
|
*/
|
|
154
154
|
terminate_session: boolean;
|
|
155
155
|
};
|