assemblyai 4.4.6 → 4.4.7
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 +6 -0
- package/dist/assemblyai.umd.js +49 -9
- package/dist/assemblyai.umd.min.js +1 -1
- package/dist/browser.mjs +43 -8
- package/dist/bun.mjs +43 -8
- package/dist/deno.mjs +43 -8
- package/dist/index.cjs +49 -9
- package/dist/index.mjs +49 -9
- package/dist/node.cjs +43 -8
- package/dist/node.mjs +43 -8
- package/dist/polyfills/fetch/default.d.ts +1 -0
- package/dist/polyfills/fetch/workerd.d.ts +1 -0
- package/dist/services/transcripts/index.d.ts +16 -3
- package/dist/types/transcripts/index.d.ts +9 -0
- package/dist/workerd.mjs +719 -0
- package/package.json +6 -2
- package/src/polyfills/fetch/default.ts +3 -0
- package/src/polyfills/fetch/workerd.ts +1 -0
- package/src/services/base.ts +7 -7
- package/src/services/transcripts/index.ts +35 -2
- package/src/types/transcripts/index.ts +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assemblyai",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.7",
|
|
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"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"types": "./dist/exports/index.d.ts",
|
|
17
17
|
"default": "./dist/deno.mjs"
|
|
18
18
|
},
|
|
19
|
-
"workerd": "./dist/
|
|
19
|
+
"workerd": "./dist/workerd.mjs",
|
|
20
20
|
"browser": "./dist/browser.mjs",
|
|
21
21
|
"react-native": "./dist/browser.mjs",
|
|
22
22
|
"node": {
|
|
@@ -38,6 +38,10 @@
|
|
|
38
38
|
"./package.json": "./package.json"
|
|
39
39
|
},
|
|
40
40
|
"imports": {
|
|
41
|
+
"#fetch": {
|
|
42
|
+
"workerd": "./src/polyfills/fetch/workerd.ts",
|
|
43
|
+
"default": "./src/polyfills/fetch/default.ts"
|
|
44
|
+
},
|
|
41
45
|
"#fs": {
|
|
42
46
|
"node": "./src/polyfills/fs/node.ts",
|
|
43
47
|
"bun": "./src/polyfills/fs/bun.ts",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DEFAULT_FETCH_INIT: Record<string, unknown> = {};
|
package/src/services/base.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Error as JsonError } from "..";
|
|
1
|
+
import { DEFAULT_FETCH_INIT } from "#fetch";
|
|
2
|
+
import { BaseServiceParams, Error as JsonError } from "..";
|
|
3
3
|
import { buildUserAgent } from "../utils/userAgent";
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -22,13 +22,14 @@ export abstract class BaseService {
|
|
|
22
22
|
input: string,
|
|
23
23
|
init?: RequestInit | undefined,
|
|
24
24
|
): Promise<Response> {
|
|
25
|
-
init = init
|
|
26
|
-
let headers =
|
|
27
|
-
headers = {
|
|
25
|
+
init = { ...DEFAULT_FETCH_INIT, ...init };
|
|
26
|
+
let headers = {
|
|
28
27
|
Authorization: this.params.apiKey,
|
|
29
28
|
"Content-Type": "application/json",
|
|
30
|
-
...init.headers,
|
|
31
29
|
};
|
|
30
|
+
if (DEFAULT_FETCH_INIT?.headers)
|
|
31
|
+
headers = { ...headers, ...DEFAULT_FETCH_INIT.headers };
|
|
32
|
+
if (init?.headers) headers = { ...headers, ...init.headers };
|
|
32
33
|
|
|
33
34
|
if (this.userAgent) {
|
|
34
35
|
(headers as Record<string, string>)["User-Agent"] = this.userAgent;
|
|
@@ -40,7 +41,6 @@ export abstract class BaseService {
|
|
|
40
41
|
}
|
|
41
42
|
init.headers = headers;
|
|
42
43
|
|
|
43
|
-
init.cache = "no-store";
|
|
44
44
|
if (!input.startsWith("http")) input = this.params.baseUrl + input;
|
|
45
45
|
|
|
46
46
|
const response = await fetch(input, init);
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
TranscribeOptions,
|
|
17
17
|
SubmitParams,
|
|
18
18
|
SpeechModel,
|
|
19
|
+
RedactedAudioFile,
|
|
19
20
|
} from "../..";
|
|
20
21
|
import { FileService } from "../files";
|
|
21
22
|
import { getPath } from "../../utils/path";
|
|
@@ -244,15 +245,47 @@ export class TranscriptService extends BaseService {
|
|
|
244
245
|
}
|
|
245
246
|
|
|
246
247
|
/**
|
|
247
|
-
* Retrieve
|
|
248
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
248
249
|
* @param id - The identifier of the transcript.
|
|
249
|
-
* @returns A promise that resolves to the
|
|
250
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
251
|
+
* @deprecated Use `redactedAudio` instead.
|
|
250
252
|
*/
|
|
251
253
|
redactions(id: string): Promise<RedactedAudioResponse> {
|
|
254
|
+
return this.redactedAudio(id);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
259
|
+
* @param id - The identifier of the transcript.
|
|
260
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
261
|
+
*/
|
|
262
|
+
redactedAudio(id: string): Promise<RedactedAudioResponse> {
|
|
252
263
|
return this.fetchJson<RedactedAudioResponse>(
|
|
253
264
|
`/v2/transcript/${id}/redacted-audio`,
|
|
254
265
|
);
|
|
255
266
|
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Retrieve the redacted audio file of a transcript.
|
|
270
|
+
* @param id - The identifier of the transcript.
|
|
271
|
+
* @returns A promise that resolves to the fetch HTTP response of the redacted audio file.
|
|
272
|
+
*/
|
|
273
|
+
async redactedAudioFile(id: string): Promise<RedactedAudioFile> {
|
|
274
|
+
const { redacted_audio_url, status } = await this.redactedAudio(id);
|
|
275
|
+
if (status !== "redacted_audio_ready") {
|
|
276
|
+
throw new Error(`Redacted audio status is ${status}`);
|
|
277
|
+
}
|
|
278
|
+
const response = await fetch(redacted_audio_url);
|
|
279
|
+
if (!response.ok) {
|
|
280
|
+
throw new Error(`Failed to fetch redacted audio: ${response.statusText}`);
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
arrayBuffer: response.arrayBuffer.bind(response),
|
|
284
|
+
blob: response.blob.bind(response),
|
|
285
|
+
body: response.body,
|
|
286
|
+
bodyUsed: response.bodyUsed,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
256
289
|
}
|
|
257
290
|
|
|
258
291
|
function deprecateConformer2(params: { speech_model?: SpeechModel | null }) {
|
|
@@ -54,3 +54,13 @@ export type SubmitParams = TranscribeParams;
|
|
|
54
54
|
* The options to transcribe an audio file, including polling options.
|
|
55
55
|
*/
|
|
56
56
|
export type TranscribeOptions = PollingOptions;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The PII redacted audio file, transmitted over the network.
|
|
60
|
+
*/
|
|
61
|
+
export type RedactedAudioFile = {
|
|
62
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
63
|
+
blob: () => Promise<Blob>;
|
|
64
|
+
body: ReadableStream<Uint8Array> | null;
|
|
65
|
+
bodyUsed: boolean;
|
|
66
|
+
};
|