assemblyai 1.0.1 → 2.0.0-beta
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/LICENSE +21 -0
- package/README.md +93 -84
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +378 -0
- package/dist/index.js +380 -0
- package/dist/services/base.d.ts +15 -0
- package/dist/services/files/index.d.ts +9 -0
- package/dist/services/index.d.ts +31 -0
- package/dist/services/lemur/index.d.ts +8 -0
- package/dist/services/realtime/index.d.ts +16 -0
- package/dist/services/transcripts/index.d.ts +42 -0
- package/dist/services/transcripts/redactions.d.ts +14 -0
- package/dist/services/transcripts/subtitles.d.ts +12 -0
- package/dist/types/core/index.d.ts +2 -0
- package/dist/types/core/params.d.ts +2 -0
- package/dist/types/core/segments.d.ts +28 -0
- package/dist/types/core/transcript.d.ts +113 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/lemur/index.d.ts +79 -0
- package/dist/types/models/auto_chapter.d.ts +8 -0
- package/dist/types/models/auto_highlights.d.ts +11 -0
- package/dist/types/models/content_safety.d.ts +25 -0
- package/dist/types/models/entity_detection.d.ts +7 -0
- package/dist/types/models/index.d.ts +8 -0
- package/dist/types/models/pii.d.ts +3 -0
- package/dist/types/models/sentiment_analysis.d.ts +9 -0
- package/dist/types/models/shared.d.ts +3 -0
- package/dist/types/models/summarization.d.ts +3 -0
- package/dist/types/models/topic_detection.d.ts +17 -0
- package/dist/types/realtime/index.d.ts +17 -0
- package/dist/types/services/abstractions.d.ts +80 -0
- package/dist/types/services/index.d.ts +9 -0
- package/dist/types/shared/index.d.ts +2 -0
- package/dist/types/shared/pagination.d.ts +7 -0
- package/dist/types/shared/timestamp.d.ts +5 -0
- package/dist/utils/errors/index.d.ts +1 -0
- package/dist/utils/errors/realtime.d.ts +26 -0
- package/package.json +55 -21
- package/src/index.ts +2 -0
- package/src/services/base.ts +16 -0
- package/src/services/files/index.ts +22 -0
- package/src/services/index.ts +66 -0
- package/src/services/lemur/index.ts +45 -0
- package/src/services/realtime/index.ts +106 -0
- package/src/services/transcripts/index.ts +156 -0
- package/src/services/transcripts/redactions.ts +27 -0
- package/src/services/transcripts/subtitles.ts +26 -0
- package/src/types/core/index.ts +2 -0
- package/src/types/core/params.ts +3 -0
- package/src/types/core/segments.ts +29 -0
- package/src/types/core/transcript.ts +159 -0
- package/src/types/index.ts +6 -0
- package/src/types/lemur/index.ts +97 -0
- package/src/types/models/auto_chapter.ts +9 -0
- package/src/types/models/auto_highlights.ts +14 -0
- package/src/types/models/content_safety.ts +34 -0
- package/src/types/models/entity_detection.ts +8 -0
- package/src/types/models/index.ts +8 -0
- package/src/types/models/pii.ts +32 -0
- package/src/types/models/sentiment_analysis.ts +11 -0
- package/src/types/models/shared.ts +4 -0
- package/src/types/models/summarization.ts +10 -0
- package/src/types/models/topic_detection.ts +21 -0
- package/src/types/realtime/index.ts +28 -0
- package/src/types/services/abstractions.ts +88 -0
- package/src/types/services/index.ts +11 -0
- package/src/types/shared/index.ts +2 -0
- package/src/types/shared/pagination.ts +8 -0
- package/src/types/shared/timestamp.ts +6 -0
- package/src/utils/.gitkeep +0 -0
- package/src/utils/errors/index.ts +5 -0
- package/src/utils/errors/realtime.ts +58 -0
- package/.eslintrc.json +0 -3
- package/index.js +0 -15
- package/src/Client.js +0 -28
- package/src/api/Http/Request.js +0 -108
- package/src/api/Http/Response.js +0 -23
- package/src/api/Model.js +0 -17
- package/src/api/Transcript.js +0 -16
- package/src/api/Upload.js +0 -41
- package/src/api/util.js +0 -48
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { BaseServiceParams } from "@/services/base";
|
|
2
|
+
import {
|
|
3
|
+
Connectable,
|
|
4
|
+
RealtimeConnectionParams,
|
|
5
|
+
RealtimeListener,
|
|
6
|
+
RealtimeListeners,
|
|
7
|
+
RealtimeTranscript,
|
|
8
|
+
} from "@/types";
|
|
9
|
+
import { RealtimeError, RealtimeErrorType } from "@/utils/errors";
|
|
10
|
+
import WebSocket, { type CloseEvent, type MessageEvent } from "ws";
|
|
11
|
+
|
|
12
|
+
export default class RealtimeService
|
|
13
|
+
implements Connectable<RealtimeTranscript, RealtimeConnectionParams>
|
|
14
|
+
{
|
|
15
|
+
private params: BaseServiceParams;
|
|
16
|
+
private socket?: WebSocket;
|
|
17
|
+
private listeners: RealtimeListeners = {};
|
|
18
|
+
|
|
19
|
+
constructor(params: BaseServiceParams) {
|
|
20
|
+
this.params = params;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private connectionUrl(
|
|
24
|
+
connectionParams: Required<RealtimeConnectionParams>
|
|
25
|
+
): URL {
|
|
26
|
+
if (!this.params.baseUrl) {
|
|
27
|
+
throw new Error("Missing base URL");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const url = new URL(this.params.baseUrl);
|
|
31
|
+
|
|
32
|
+
if (url.protocol !== "wss:") {
|
|
33
|
+
throw new Error("Invalid protocol, must be wss");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const searchParams = new URLSearchParams();
|
|
37
|
+
searchParams.set("sample_rate", connectionParams.sampleRate.toString());
|
|
38
|
+
searchParams.set("word_boost", connectionParams.wordBoost.join(","));
|
|
39
|
+
url.search = searchParams.toString();
|
|
40
|
+
|
|
41
|
+
return url;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
on(event: "data", listener: (transcript: RealtimeTranscript) => void): void;
|
|
45
|
+
on(event: "error", listener: (error: Error) => void): void;
|
|
46
|
+
on(event: "open", listener: () => void): void;
|
|
47
|
+
on(event: "close", listener: (code: number, reason: string) => void): void;
|
|
48
|
+
on(event: RealtimeListener, listener: (...args: any[]) => void) {
|
|
49
|
+
this.listeners[event] = listener;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
connect(connectionParams: RealtimeConnectionParams) {
|
|
53
|
+
if (this.socket) {
|
|
54
|
+
throw new Error("Already connected");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const url = this.connectionUrl({
|
|
58
|
+
...connectionParams,
|
|
59
|
+
sampleRate: connectionParams.sampleRate || 16000,
|
|
60
|
+
wordBoost: connectionParams.wordBoost || [],
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
this.socket = new WebSocket(url.toString(), {
|
|
64
|
+
headers: {
|
|
65
|
+
Authorization: this.params.token,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
this.socket.onopen = () => this.listeners.open?.();
|
|
70
|
+
this.socket.onclose = ({ code, reason }: CloseEvent) =>
|
|
71
|
+
this.listeners.close?.(code, reason);
|
|
72
|
+
|
|
73
|
+
this.socket.onerror = (error) => {
|
|
74
|
+
const code = error.message as unknown as RealtimeErrorType;
|
|
75
|
+
const realtimeError = new RealtimeError(code);
|
|
76
|
+
this.listeners.error?.(realtimeError);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
this.socket.onmessage = ({ data }: MessageEvent) => {
|
|
80
|
+
const message = JSON.parse(data.toString()) as RealtimeTranscript;
|
|
81
|
+
this.listeners.data?.(message);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
send(data: ArrayBuffer) {
|
|
86
|
+
if (!this.socket || this.socket.readyState !== WebSocket.OPEN) {
|
|
87
|
+
throw new Error("Socket is not open for communication");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const payload = {
|
|
91
|
+
audio_data: Buffer.from(data).toString("base64"),
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
this.socket.send(JSON.stringify(payload));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
disconnect() {
|
|
98
|
+
if (this.socket) {
|
|
99
|
+
this.socket.removeAllListeners();
|
|
100
|
+
this.socket.close();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
this.listeners = {};
|
|
104
|
+
this.socket = undefined;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import BaseService from "@/services/base";
|
|
2
|
+
import TranscriptSubtitleService from "./subtitles";
|
|
3
|
+
import {
|
|
4
|
+
ParagraphsBody,
|
|
5
|
+
SegmentType,
|
|
6
|
+
SentencesBody,
|
|
7
|
+
Transcript,
|
|
8
|
+
TranscriptList,
|
|
9
|
+
TranscriptParams,
|
|
10
|
+
TranscriptPollingSettings,
|
|
11
|
+
Createable,
|
|
12
|
+
Deletable,
|
|
13
|
+
Listable,
|
|
14
|
+
Retrieveable,
|
|
15
|
+
TranscriptListInternal,
|
|
16
|
+
TranscriptListItemInternal,
|
|
17
|
+
TranscriptListItem,
|
|
18
|
+
} from "@/types";
|
|
19
|
+
import TranscriptRedactionService from "./redactions";
|
|
20
|
+
import { AxiosInstance } from "axios";
|
|
21
|
+
import FileService from "../files";
|
|
22
|
+
|
|
23
|
+
export default class TranscriptService
|
|
24
|
+
extends BaseService
|
|
25
|
+
implements
|
|
26
|
+
Createable<Transcript, TranscriptParams, TranscriptPollingSettings>,
|
|
27
|
+
Retrieveable<Transcript>,
|
|
28
|
+
Deletable<Transcript>,
|
|
29
|
+
Listable<TranscriptList>
|
|
30
|
+
{
|
|
31
|
+
/**
|
|
32
|
+
* The subtitles service.
|
|
33
|
+
*/
|
|
34
|
+
public subtitles: TranscriptSubtitleService;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The redactions service.
|
|
38
|
+
*/
|
|
39
|
+
public redactions: TranscriptRedactionService;
|
|
40
|
+
|
|
41
|
+
constructor(client: AxiosInstance, private files: FileService) {
|
|
42
|
+
super(client);
|
|
43
|
+
this.subtitles = new TranscriptSubtitleService(client);
|
|
44
|
+
this.redactions = new TranscriptRedactionService(client);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async create(
|
|
48
|
+
params: TranscriptParams,
|
|
49
|
+
settings: TranscriptPollingSettings | null = {
|
|
50
|
+
pollingInterval: 3000,
|
|
51
|
+
pollingTimeout: 180000,
|
|
52
|
+
}
|
|
53
|
+
): Promise<Transcript> {
|
|
54
|
+
const path = getPath(params.audio_url);
|
|
55
|
+
if (path !== null) {
|
|
56
|
+
const uploadUrl = await this.files.upload(path);
|
|
57
|
+
params.audio_url = uploadUrl;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const res = await this.client.post<Transcript>("/v2/transcript", params);
|
|
61
|
+
|
|
62
|
+
if (settings && settings.pollingInterval) {
|
|
63
|
+
return await this.poll(res.data.id, settings);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return res.data;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private async poll(
|
|
70
|
+
transcriptId: string,
|
|
71
|
+
settings: TranscriptPollingSettings
|
|
72
|
+
): Promise<Transcript> {
|
|
73
|
+
const {
|
|
74
|
+
pollingInterval,
|
|
75
|
+
pollingTimeout,
|
|
76
|
+
resolver = (t) => t.status === "completed" || t.status === "error",
|
|
77
|
+
} = settings;
|
|
78
|
+
const startTime = Date.now();
|
|
79
|
+
|
|
80
|
+
while (true) {
|
|
81
|
+
const transcript = await this.retrieve(transcriptId);
|
|
82
|
+
if (resolver(transcript)) {
|
|
83
|
+
return transcript;
|
|
84
|
+
} else if (Date.now() - startTime < pollingTimeout) {
|
|
85
|
+
await new Promise((resolve) => setTimeout(resolve, pollingInterval));
|
|
86
|
+
} else {
|
|
87
|
+
throw new Error("Polling timeout");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async retrieve(id: string): Promise<Transcript> {
|
|
93
|
+
const res = await this.client.get<Transcript>(`/v2/transcript/${id}`);
|
|
94
|
+
return res.data;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async list(nextUrl?: string): Promise<TranscriptList> {
|
|
98
|
+
const { data } = await this.client.get<TranscriptListInternal>(
|
|
99
|
+
nextUrl || "/v2/transcript"
|
|
100
|
+
);
|
|
101
|
+
for (const transcriptListItem of data.transcripts as unknown as (
|
|
102
|
+
| TranscriptListItemInternal
|
|
103
|
+
| TranscriptListItem
|
|
104
|
+
)[]) {
|
|
105
|
+
transcriptListItem.created = new Date(transcriptListItem.created);
|
|
106
|
+
transcriptListItem.completed = new Date(transcriptListItem.completed);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return data as unknown as TranscriptList;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async delete(id: string): Promise<Transcript> {
|
|
113
|
+
const res = await this.client.delete<Transcript>(`/v2/transcript/${id}`);
|
|
114
|
+
return res.data;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Retrieve all segments of a transcript.
|
|
119
|
+
* @param id The identifier of the transcript.
|
|
120
|
+
* @param type The type of segment to retrieve.
|
|
121
|
+
* @return A promise that resolves to the retrieved resource.
|
|
122
|
+
*/
|
|
123
|
+
private async segments<T>(id: string, type: SegmentType): Promise<T> {
|
|
124
|
+
const { data } = await this.client.get<T>(`/v2/transcript/${id}/${type}`);
|
|
125
|
+
return data;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Retrieve all sentences of a transcript.
|
|
130
|
+
* @param id The identifier of the transcript.
|
|
131
|
+
* @return A promise that resolves to the sentences.
|
|
132
|
+
*/
|
|
133
|
+
async sentences(id: string): Promise<SentencesBody> {
|
|
134
|
+
return this.segments<SentencesBody>(id, "sentences");
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Retrieve all paragraphs of a transcript.
|
|
139
|
+
* @param id The identifier of the transcript.
|
|
140
|
+
* @return A promise that resolves to the paragraphs.
|
|
141
|
+
*/
|
|
142
|
+
async paragraphs(id: string): Promise<ParagraphsBody> {
|
|
143
|
+
return this.segments<ParagraphsBody>(id, "paragraphs");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function getPath(path: string) {
|
|
148
|
+
let url: URL;
|
|
149
|
+
try {
|
|
150
|
+
url = new URL(path);
|
|
151
|
+
if (url.protocol === "file:") return url.pathname;
|
|
152
|
+
else return null;
|
|
153
|
+
} catch {
|
|
154
|
+
return path;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import BaseService from "@/services/base";
|
|
2
|
+
import { Retrieveable } from "@/types";
|
|
3
|
+
|
|
4
|
+
type TranscriptRedactionParams = {
|
|
5
|
+
transcript_id: string;
|
|
6
|
+
path: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type TranscriptRedactionResponse = {
|
|
10
|
+
status: "redacted_audio_ready";
|
|
11
|
+
redacted_audio_url: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default class TranscriptRedactionService
|
|
15
|
+
extends BaseService
|
|
16
|
+
implements
|
|
17
|
+
Retrieveable<TranscriptRedactionResponse, TranscriptRedactionParams>
|
|
18
|
+
{
|
|
19
|
+
async retrieve(
|
|
20
|
+
params: TranscriptRedactionParams
|
|
21
|
+
): Promise<TranscriptRedactionResponse> {
|
|
22
|
+
const { data } = await this.client.get<TranscriptRedactionResponse>(
|
|
23
|
+
`/v2/transcript/${params.transcript_id}/redacted-audio`
|
|
24
|
+
);
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import BaseService from "@/services/base";
|
|
2
|
+
import { Retrieveable } from "@/types";
|
|
3
|
+
|
|
4
|
+
type Subtitle = string;
|
|
5
|
+
type SubtitleFormat = "vtt" | "srt";
|
|
6
|
+
|
|
7
|
+
type TranscriptionSubtitleParams = {
|
|
8
|
+
transcript_id: string;
|
|
9
|
+
format: SubtitleFormat;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default class TranscriptSubtitleService
|
|
13
|
+
extends BaseService
|
|
14
|
+
implements Retrieveable<Subtitle, TranscriptionSubtitleParams>
|
|
15
|
+
{
|
|
16
|
+
async retrieve({
|
|
17
|
+
transcript_id,
|
|
18
|
+
format,
|
|
19
|
+
}: TranscriptionSubtitleParams): Promise<Subtitle> {
|
|
20
|
+
const { data } = await this.client.get<Subtitle>(
|
|
21
|
+
`/v2/transcript/${transcript_id}/${format}`
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return data;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type SegmentType = "paragraphs" | "sentences";
|
|
2
|
+
|
|
3
|
+
type Segment<T> = T & {
|
|
4
|
+
id: string;
|
|
5
|
+
confidence: number;
|
|
6
|
+
audio_duration: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type ParagraphsBody = Segment<{ paragraphs: Utterance[] }>;
|
|
10
|
+
type SentencesBody = Segment<{ sentences: Utterance[] }>;
|
|
11
|
+
|
|
12
|
+
type Word = {
|
|
13
|
+
text: string;
|
|
14
|
+
start: number;
|
|
15
|
+
end: number;
|
|
16
|
+
confidence: number;
|
|
17
|
+
speaker?: string | null;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type Utterance = {
|
|
21
|
+
start: number;
|
|
22
|
+
end: number;
|
|
23
|
+
confidence: number;
|
|
24
|
+
speaker?: string;
|
|
25
|
+
text: string;
|
|
26
|
+
words: Word[];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type { Word, Utterance, ParagraphsBody, SentencesBody, SegmentType };
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AutoChapter,
|
|
3
|
+
AutoHighlights,
|
|
4
|
+
ContentSafetyLabels,
|
|
5
|
+
Entity,
|
|
6
|
+
PIIAudioQuality,
|
|
7
|
+
PIIRedactionPolicies,
|
|
8
|
+
SentimentAnalysis,
|
|
9
|
+
SummaryModel,
|
|
10
|
+
SummaryType,
|
|
11
|
+
TopicDetection,
|
|
12
|
+
} from "@/types/models";
|
|
13
|
+
import { PageDetails } from "@/types/shared";
|
|
14
|
+
import { Utterance, Word } from "./segments";
|
|
15
|
+
import { WordBoostWeight } from "./params";
|
|
16
|
+
|
|
17
|
+
type TranscriptStatus = "queued" | "processing" | "completed" | "error";
|
|
18
|
+
|
|
19
|
+
type TranscriptBase = {
|
|
20
|
+
status?: TranscriptStatus | null;
|
|
21
|
+
|
|
22
|
+
// Core Transcription
|
|
23
|
+
audio_url: string;
|
|
24
|
+
audio_start_from?: number | null;
|
|
25
|
+
audio_end_at?: number | null;
|
|
26
|
+
filter_profanity?: boolean;
|
|
27
|
+
custom_spelling?: null;
|
|
28
|
+
disfluencies?: boolean;
|
|
29
|
+
dual_channel?: boolean | null;
|
|
30
|
+
punctuate?: boolean;
|
|
31
|
+
speaker_labels?: boolean;
|
|
32
|
+
format_text?: boolean;
|
|
33
|
+
|
|
34
|
+
// Audio Intelligence
|
|
35
|
+
auto_chapters?: boolean;
|
|
36
|
+
content_safety?: boolean;
|
|
37
|
+
entity_detection?: boolean;
|
|
38
|
+
language_code?: string;
|
|
39
|
+
language_detection?: boolean;
|
|
40
|
+
iab_categories?: boolean;
|
|
41
|
+
auto_highlights?: boolean;
|
|
42
|
+
summarization?: boolean;
|
|
43
|
+
summary_type?: SummaryType;
|
|
44
|
+
summary_model?: SummaryModel;
|
|
45
|
+
redact_pii?: boolean;
|
|
46
|
+
redact_pii_sub?: string;
|
|
47
|
+
redact_pii_audio_quality?: PIIAudioQuality;
|
|
48
|
+
redact_pii_audio?: boolean;
|
|
49
|
+
redact_pii_policies?: PIIRedactionPolicies[];
|
|
50
|
+
sentiment_analysis?: boolean;
|
|
51
|
+
webhook_auth_header_name?: null;
|
|
52
|
+
webhook_auth?: boolean;
|
|
53
|
+
webhook_status_code?: null | number;
|
|
54
|
+
webhook_url?: null | string;
|
|
55
|
+
|
|
56
|
+
word_boost?: string[];
|
|
57
|
+
boost_param?: WordBoostWeight;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
type TranscriptParams = Omit<TranscriptBase, "status">;
|
|
61
|
+
|
|
62
|
+
type TranscriptQueued = TranscriptBase & {
|
|
63
|
+
id: string;
|
|
64
|
+
status: "queued";
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
type TranscriptProcessing = TranscriptBase & {
|
|
68
|
+
id: string;
|
|
69
|
+
status: "processing";
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
type TranscriptCompleted = TranscriptBase & {
|
|
73
|
+
status: "completed";
|
|
74
|
+
id: string;
|
|
75
|
+
audio_duration?: number;
|
|
76
|
+
words?: Word[];
|
|
77
|
+
utterances?: Utterance[];
|
|
78
|
+
text?: string;
|
|
79
|
+
confidence?: number;
|
|
80
|
+
chapters?: AutoChapter[] | null;
|
|
81
|
+
content_safety_labels?: ContentSafetyLabels;
|
|
82
|
+
entities?: Entity[];
|
|
83
|
+
iab_categories_result?: TopicDetection;
|
|
84
|
+
auto_highlights_result?: AutoHighlights;
|
|
85
|
+
summary?: string;
|
|
86
|
+
sentiment_analysis_results?: SentimentAnalysis[];
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated Acoustic Model is deprecated and will be removed in a future release
|
|
90
|
+
*/
|
|
91
|
+
acoustic_model?: unknown;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @deprecated Speed Boost is deprecated and will be removed in a future release
|
|
95
|
+
*/
|
|
96
|
+
speed_boost?: boolean;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @deprecated Language Model is deprecated and will be removed in a future release
|
|
100
|
+
*/
|
|
101
|
+
language_model?: unknown;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
type TranscriptFailed = TranscriptBase & {
|
|
105
|
+
status: "error";
|
|
106
|
+
id: string;
|
|
107
|
+
error?: string;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
type Transcript =
|
|
111
|
+
| Readonly<TranscriptQueued>
|
|
112
|
+
| Readonly<TranscriptProcessing>
|
|
113
|
+
| Readonly<TranscriptCompleted>
|
|
114
|
+
| Readonly<TranscriptFailed>;
|
|
115
|
+
|
|
116
|
+
type TranscriptPollingSettings = {
|
|
117
|
+
pollingInterval: number;
|
|
118
|
+
pollingTimeout: number;
|
|
119
|
+
resolver?: (transcript: Transcript) => boolean;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
type TranscriptListInternal = {
|
|
123
|
+
page_details: PageDetails;
|
|
124
|
+
transcripts: TranscriptListItemInternal[];
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
type TranscriptListItemInternal = {
|
|
128
|
+
id: string;
|
|
129
|
+
resource_url: string;
|
|
130
|
+
status: TranscriptStatus;
|
|
131
|
+
created: string;
|
|
132
|
+
completed: string;
|
|
133
|
+
audio_url: string;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
type TranscriptList = {
|
|
137
|
+
page_details: PageDetails;
|
|
138
|
+
transcripts: TranscriptListItem[];
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
type TranscriptListItem = {
|
|
142
|
+
id: string;
|
|
143
|
+
resource_url: string;
|
|
144
|
+
status: TranscriptStatus;
|
|
145
|
+
created: Date;
|
|
146
|
+
completed: Date;
|
|
147
|
+
audio_url: string;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export type {
|
|
151
|
+
Transcript,
|
|
152
|
+
TranscriptStatus,
|
|
153
|
+
TranscriptParams,
|
|
154
|
+
TranscriptList,
|
|
155
|
+
TranscriptListItem,
|
|
156
|
+
TranscriptListInternal,
|
|
157
|
+
TranscriptListItemInternal,
|
|
158
|
+
TranscriptPollingSettings,
|
|
159
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
type LeMURModel = "default" | "basic";
|
|
2
|
+
type LeMURContext = string | object | LeMURContext[];
|
|
3
|
+
|
|
4
|
+
type LeMURBaseServiceParams = {
|
|
5
|
+
/**
|
|
6
|
+
* A list of completed transcripts with text. Up to 100 files max, or 100 hours max. Whichever is lower.
|
|
7
|
+
*/
|
|
8
|
+
transcript_ids: string[];
|
|
9
|
+
/**
|
|
10
|
+
* The model that is used for the final prompt after compression is performed (options: "basic" and "default").
|
|
11
|
+
*/
|
|
12
|
+
final_model?: LeMURModel;
|
|
13
|
+
/**
|
|
14
|
+
* Max output size in tokens. Up to 4000 allowed.
|
|
15
|
+
*/
|
|
16
|
+
max_output_size?: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type SummaryParams = LeMURBaseServiceParams & {
|
|
20
|
+
/**
|
|
21
|
+
* How you want the summary to be returned. This can be any text. Examples: "TLDR", "bullet points"
|
|
22
|
+
*/
|
|
23
|
+
answer_format?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Any context about the transcripts you wish to provide. This can be a string, or free-form JSON.
|
|
26
|
+
*/
|
|
27
|
+
context?: LeMURContext;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type Question = {
|
|
31
|
+
/**
|
|
32
|
+
* The question you wish to ask. For more complex questions use default model.
|
|
33
|
+
*/
|
|
34
|
+
question: string;
|
|
35
|
+
/**
|
|
36
|
+
* Any context about the transcripts you wish to provide. This can be a string, or free-form JSON.
|
|
37
|
+
*/
|
|
38
|
+
context?: LeMURContext;
|
|
39
|
+
/**
|
|
40
|
+
* How you want the answer to be returned. This can be any text. Cannot be used with answer_options. Examples: "short sentence", "bullet points"
|
|
41
|
+
*/
|
|
42
|
+
answer_format?: string;
|
|
43
|
+
/**
|
|
44
|
+
* What discrete options to return. Useful for precise responses. Cannot be used with answer_format. Example: ["Yes", "No"]
|
|
45
|
+
*/
|
|
46
|
+
answer_options?: string[];
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
type QuestionAnswerParams = LeMURBaseServiceParams & {
|
|
50
|
+
/**
|
|
51
|
+
* Any context about the transcripts you wish to provide. This can be a string, or free-form JSON.
|
|
52
|
+
*/
|
|
53
|
+
context?: LeMURContext;
|
|
54
|
+
/**
|
|
55
|
+
* A list of questions to ask. Question format listed below.
|
|
56
|
+
*/
|
|
57
|
+
questions: Question[];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
type ActionItemsParams = LeMURBaseServiceParams & {
|
|
61
|
+
/**
|
|
62
|
+
* Any context about the transcripts you wish to provide. This can be a string, or free-form JSON.
|
|
63
|
+
*/
|
|
64
|
+
context?: LeMURContext;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
type TaskParams = LeMURBaseServiceParams & {
|
|
68
|
+
/**
|
|
69
|
+
* Your text to prompt the model to produce a desired output, including any context you want to pass into the model.
|
|
70
|
+
*/
|
|
71
|
+
prompt: string;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
type LeMURResponse = {
|
|
75
|
+
response: string;
|
|
76
|
+
request_id: string;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
type QuestionAnswer = {
|
|
80
|
+
question: string;
|
|
81
|
+
answer: string;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
type LeMURQuestionAnswerResponse = {
|
|
85
|
+
response: QuestionAnswer[];
|
|
86
|
+
request_id: string;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export type {
|
|
90
|
+
SummaryParams,
|
|
91
|
+
QuestionAnswerParams,
|
|
92
|
+
ActionItemsParams,
|
|
93
|
+
TaskParams,
|
|
94
|
+
LeMURResponse,
|
|
95
|
+
LeMURQuestionAnswerResponse,
|
|
96
|
+
LeMURBaseServiceParams,
|
|
97
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ModelResultStatus } from "./shared";
|
|
2
|
+
|
|
3
|
+
type AutoHighlightsResult = {
|
|
4
|
+
text: string;
|
|
5
|
+
count: number;
|
|
6
|
+
rank: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type AutoHighlights = {
|
|
10
|
+
status: ModelResultStatus;
|
|
11
|
+
results: AutoHighlightsResult[];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type { AutoHighlights };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ModelResultStatus, ModelSummary } from "./shared";
|
|
2
|
+
import { Timestamp } from "@/types/shared";
|
|
3
|
+
|
|
4
|
+
type ContentSafetyLabel = {
|
|
5
|
+
label: string;
|
|
6
|
+
confidence: number;
|
|
7
|
+
severity: number | null;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type ContentSafetyResult = {
|
|
11
|
+
text: string;
|
|
12
|
+
labels: ContentSafetyLabel[];
|
|
13
|
+
timestamp: Timestamp;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type ContentSafetySeverityScore = {
|
|
17
|
+
low: number;
|
|
18
|
+
medium: number;
|
|
19
|
+
high: number;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type ContentSafetySeverityScoreSummary = Record<
|
|
23
|
+
string,
|
|
24
|
+
ContentSafetySeverityScore
|
|
25
|
+
>;
|
|
26
|
+
|
|
27
|
+
type ContentSafetyLabels = {
|
|
28
|
+
status: ModelResultStatus;
|
|
29
|
+
results: ContentSafetyResult[];
|
|
30
|
+
summary: ModelSummary;
|
|
31
|
+
severity_score_summary: ContentSafetySeverityScoreSummary;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type { ContentSafetyLabels };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type * from "./auto_chapter";
|
|
2
|
+
export type * from "./auto_highlights";
|
|
3
|
+
export type * from "./content_safety";
|
|
4
|
+
export type * from "./entity_detection";
|
|
5
|
+
export type * from "./pii";
|
|
6
|
+
export type * from "./sentiment_analysis";
|
|
7
|
+
export type * from "./summarization";
|
|
8
|
+
export type * from "./topic_detection";
|