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/dist/node.cjs
CHANGED
|
@@ -5,6 +5,10 @@ var ws = require('ws');
|
|
|
5
5
|
var fs = require('fs');
|
|
6
6
|
var stream = require('stream');
|
|
7
7
|
|
|
8
|
+
const DEFAULT_FETCH_INIT = {
|
|
9
|
+
cache: "no-store",
|
|
10
|
+
};
|
|
11
|
+
|
|
8
12
|
const buildUserAgent = (userAgent) => defaultUserAgentString +
|
|
9
13
|
(userAgent === false
|
|
10
14
|
? ""
|
|
@@ -18,7 +22,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
18
22
|
defaultUserAgentString += navigator.userAgent;
|
|
19
23
|
}
|
|
20
24
|
const defaultUserAgent = {
|
|
21
|
-
sdk: { name: "JavaScript", version: "4.4.
|
|
25
|
+
sdk: { name: "JavaScript", version: "4.4.7" },
|
|
22
26
|
};
|
|
23
27
|
if (typeof process !== "undefined") {
|
|
24
28
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -58,13 +62,15 @@ class BaseService {
|
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
async fetch(input, init) {
|
|
61
|
-
init = init
|
|
62
|
-
let headers =
|
|
63
|
-
headers = {
|
|
65
|
+
init = { ...DEFAULT_FETCH_INIT, ...init };
|
|
66
|
+
let headers = {
|
|
64
67
|
Authorization: this.params.apiKey,
|
|
65
68
|
"Content-Type": "application/json",
|
|
66
|
-
...init.headers,
|
|
67
69
|
};
|
|
70
|
+
if (DEFAULT_FETCH_INIT?.headers)
|
|
71
|
+
headers = { ...headers, ...DEFAULT_FETCH_INIT.headers };
|
|
72
|
+
if (init?.headers)
|
|
73
|
+
headers = { ...headers, ...init.headers };
|
|
68
74
|
if (this.userAgent) {
|
|
69
75
|
headers["User-Agent"] = this.userAgent;
|
|
70
76
|
// chromium browsers have a bug where the user agent can't be modified
|
|
@@ -74,7 +80,6 @@ class BaseService {
|
|
|
74
80
|
}
|
|
75
81
|
}
|
|
76
82
|
init.headers = headers;
|
|
77
|
-
init.cache = "no-store";
|
|
78
83
|
if (!input.startsWith("http"))
|
|
79
84
|
input = this.params.baseUrl + input;
|
|
80
85
|
const response = await fetch(input, init);
|
|
@@ -601,13 +606,43 @@ class TranscriptService extends BaseService {
|
|
|
601
606
|
return await response.text();
|
|
602
607
|
}
|
|
603
608
|
/**
|
|
604
|
-
* Retrieve
|
|
609
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
605
610
|
* @param id - The identifier of the transcript.
|
|
606
|
-
* @returns A promise that resolves to the
|
|
611
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
612
|
+
* @deprecated Use `redactedAudio` instead.
|
|
607
613
|
*/
|
|
608
614
|
redactions(id) {
|
|
615
|
+
return this.redactedAudio(id);
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
619
|
+
* @param id - The identifier of the transcript.
|
|
620
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
621
|
+
*/
|
|
622
|
+
redactedAudio(id) {
|
|
609
623
|
return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
|
|
610
624
|
}
|
|
625
|
+
/**
|
|
626
|
+
* Retrieve the redacted audio file of a transcript.
|
|
627
|
+
* @param id - The identifier of the transcript.
|
|
628
|
+
* @returns A promise that resolves to the fetch HTTP response of the redacted audio file.
|
|
629
|
+
*/
|
|
630
|
+
async redactedAudioFile(id) {
|
|
631
|
+
const { redacted_audio_url, status } = await this.redactedAudio(id);
|
|
632
|
+
if (status !== "redacted_audio_ready") {
|
|
633
|
+
throw new Error(`Redacted audio status is ${status}`);
|
|
634
|
+
}
|
|
635
|
+
const response = await fetch(redacted_audio_url);
|
|
636
|
+
if (!response.ok) {
|
|
637
|
+
throw new Error(`Failed to fetch redacted audio: ${response.statusText}`);
|
|
638
|
+
}
|
|
639
|
+
return {
|
|
640
|
+
arrayBuffer: response.arrayBuffer.bind(response),
|
|
641
|
+
blob: response.blob.bind(response),
|
|
642
|
+
body: response.body,
|
|
643
|
+
bodyUsed: response.bodyUsed,
|
|
644
|
+
};
|
|
645
|
+
}
|
|
611
646
|
}
|
|
612
647
|
function deprecateConformer2(params) {
|
|
613
648
|
if (!params)
|
package/dist/node.mjs
CHANGED
|
@@ -3,6 +3,10 @@ import ws from 'ws';
|
|
|
3
3
|
import { createReadStream } from 'fs';
|
|
4
4
|
import { Readable } from 'stream';
|
|
5
5
|
|
|
6
|
+
const DEFAULT_FETCH_INIT = {
|
|
7
|
+
cache: "no-store",
|
|
8
|
+
};
|
|
9
|
+
|
|
6
10
|
const buildUserAgent = (userAgent) => defaultUserAgentString +
|
|
7
11
|
(userAgent === false
|
|
8
12
|
? ""
|
|
@@ -16,7 +20,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
16
20
|
defaultUserAgentString += navigator.userAgent;
|
|
17
21
|
}
|
|
18
22
|
const defaultUserAgent = {
|
|
19
|
-
sdk: { name: "JavaScript", version: "4.4.
|
|
23
|
+
sdk: { name: "JavaScript", version: "4.4.7" },
|
|
20
24
|
};
|
|
21
25
|
if (typeof process !== "undefined") {
|
|
22
26
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -56,13 +60,15 @@ class BaseService {
|
|
|
56
60
|
}
|
|
57
61
|
}
|
|
58
62
|
async fetch(input, init) {
|
|
59
|
-
init = init
|
|
60
|
-
let headers =
|
|
61
|
-
headers = {
|
|
63
|
+
init = { ...DEFAULT_FETCH_INIT, ...init };
|
|
64
|
+
let headers = {
|
|
62
65
|
Authorization: this.params.apiKey,
|
|
63
66
|
"Content-Type": "application/json",
|
|
64
|
-
...init.headers,
|
|
65
67
|
};
|
|
68
|
+
if (DEFAULT_FETCH_INIT?.headers)
|
|
69
|
+
headers = { ...headers, ...DEFAULT_FETCH_INIT.headers };
|
|
70
|
+
if (init?.headers)
|
|
71
|
+
headers = { ...headers, ...init.headers };
|
|
66
72
|
if (this.userAgent) {
|
|
67
73
|
headers["User-Agent"] = this.userAgent;
|
|
68
74
|
// chromium browsers have a bug where the user agent can't be modified
|
|
@@ -72,7 +78,6 @@ class BaseService {
|
|
|
72
78
|
}
|
|
73
79
|
}
|
|
74
80
|
init.headers = headers;
|
|
75
|
-
init.cache = "no-store";
|
|
76
81
|
if (!input.startsWith("http"))
|
|
77
82
|
input = this.params.baseUrl + input;
|
|
78
83
|
const response = await fetch(input, init);
|
|
@@ -599,13 +604,43 @@ class TranscriptService extends BaseService {
|
|
|
599
604
|
return await response.text();
|
|
600
605
|
}
|
|
601
606
|
/**
|
|
602
|
-
* Retrieve
|
|
607
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
603
608
|
* @param id - The identifier of the transcript.
|
|
604
|
-
* @returns A promise that resolves to the
|
|
609
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
610
|
+
* @deprecated Use `redactedAudio` instead.
|
|
605
611
|
*/
|
|
606
612
|
redactions(id) {
|
|
613
|
+
return this.redactedAudio(id);
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
617
|
+
* @param id - The identifier of the transcript.
|
|
618
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
619
|
+
*/
|
|
620
|
+
redactedAudio(id) {
|
|
607
621
|
return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
|
|
608
622
|
}
|
|
623
|
+
/**
|
|
624
|
+
* Retrieve the redacted audio file of a transcript.
|
|
625
|
+
* @param id - The identifier of the transcript.
|
|
626
|
+
* @returns A promise that resolves to the fetch HTTP response of the redacted audio file.
|
|
627
|
+
*/
|
|
628
|
+
async redactedAudioFile(id) {
|
|
629
|
+
const { redacted_audio_url, status } = await this.redactedAudio(id);
|
|
630
|
+
if (status !== "redacted_audio_ready") {
|
|
631
|
+
throw new Error(`Redacted audio status is ${status}`);
|
|
632
|
+
}
|
|
633
|
+
const response = await fetch(redacted_audio_url);
|
|
634
|
+
if (!response.ok) {
|
|
635
|
+
throw new Error(`Failed to fetch redacted audio: ${response.statusText}`);
|
|
636
|
+
}
|
|
637
|
+
return {
|
|
638
|
+
arrayBuffer: response.arrayBuffer.bind(response),
|
|
639
|
+
blob: response.blob.bind(response),
|
|
640
|
+
body: response.body,
|
|
641
|
+
bodyUsed: response.bodyUsed,
|
|
642
|
+
};
|
|
643
|
+
}
|
|
609
644
|
}
|
|
610
645
|
function deprecateConformer2(params) {
|
|
611
646
|
if (!params)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_FETCH_INIT: Record<string, unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_FETCH_INIT: Record<string, unknown>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseService } from "../base";
|
|
2
|
-
import { ParagraphsResponse, SentencesResponse, Transcript, TranscriptList, TranscriptParams, CreateTranscriptOptions, SubtitleFormat, RedactedAudioResponse, ListTranscriptParams, WordSearchResponse, BaseServiceParams, PollingOptions, TranscribeParams, TranscribeOptions, SubmitParams } from "../..";
|
|
2
|
+
import { ParagraphsResponse, SentencesResponse, Transcript, TranscriptList, TranscriptParams, CreateTranscriptOptions, SubtitleFormat, RedactedAudioResponse, ListTranscriptParams, WordSearchResponse, BaseServiceParams, PollingOptions, TranscribeParams, TranscribeOptions, SubmitParams, RedactedAudioFile } from "../..";
|
|
3
3
|
import { FileService } from "../files";
|
|
4
4
|
export declare class TranscriptService extends BaseService {
|
|
5
5
|
private files;
|
|
@@ -78,9 +78,22 @@ export declare class TranscriptService extends BaseService {
|
|
|
78
78
|
*/
|
|
79
79
|
subtitles(id: string, format?: SubtitleFormat, chars_per_caption?: number): Promise<string>;
|
|
80
80
|
/**
|
|
81
|
-
* Retrieve
|
|
81
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
82
82
|
* @param id - The identifier of the transcript.
|
|
83
|
-
* @returns A promise that resolves to the
|
|
83
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
84
|
+
* @deprecated Use `redactedAudio` instead.
|
|
84
85
|
*/
|
|
85
86
|
redactions(id: string): Promise<RedactedAudioResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
89
|
+
* @param id - The identifier of the transcript.
|
|
90
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
91
|
+
*/
|
|
92
|
+
redactedAudio(id: string): Promise<RedactedAudioResponse>;
|
|
93
|
+
/**
|
|
94
|
+
* Retrieve the redacted audio file of a transcript.
|
|
95
|
+
* @param id - The identifier of the transcript.
|
|
96
|
+
* @returns A promise that resolves to the fetch HTTP response of the redacted audio file.
|
|
97
|
+
*/
|
|
98
|
+
redactedAudioFile(id: string): Promise<RedactedAudioFile>;
|
|
86
99
|
}
|
|
@@ -46,3 +46,12 @@ export type SubmitParams = TranscribeParams;
|
|
|
46
46
|
* The options to transcribe an audio file, including polling options.
|
|
47
47
|
*/
|
|
48
48
|
export type TranscribeOptions = PollingOptions;
|
|
49
|
+
/**
|
|
50
|
+
* The PII redacted audio file, transmitted over the network.
|
|
51
|
+
*/
|
|
52
|
+
export type RedactedAudioFile = {
|
|
53
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
54
|
+
blob: () => Promise<Blob>;
|
|
55
|
+
body: ReadableStream<Uint8Array> | null;
|
|
56
|
+
bodyUsed: boolean;
|
|
57
|
+
};
|