assemblyai 4.3.1 → 4.3.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/CHANGELOG.md +12 -0
- package/README.md +161 -86
- package/dist/assemblyai.umd.js +62 -56
- package/dist/assemblyai.umd.min.js +1 -1
- package/dist/bun.mjs +57 -51
- package/dist/deno.mjs +57 -51
- package/dist/index.cjs +62 -56
- package/dist/index.mjs +62 -56
- package/dist/node.cjs +57 -51
- package/dist/node.mjs +57 -51
- package/dist/services/base.d.ts +1 -1
- package/dist/services/files/index.d.ts +2 -2
- package/dist/services/index.d.ts +1 -1
- package/dist/services/lemur/index.d.ts +1 -1
- package/dist/services/realtime/service.d.ts +2 -2
- package/dist/services/transcripts/index.d.ts +26 -26
- package/dist/types/asyncapi.generated.d.ts +60 -39
- package/dist/types/openapi.generated.d.ts +722 -329
- package/dist/types/services/index.d.ts +0 -1
- package/dist/types/transcripts/index.d.ts +14 -5
- package/package.json +2 -1
- package/src/services/base.ts +1 -1
- package/src/services/files/index.ts +2 -2
- package/src/services/index.ts +1 -1
- package/src/services/lemur/index.ts +1 -1
- package/src/services/realtime/service.ts +3 -4
- package/src/services/transcripts/index.ts +47 -54
- package/src/types/asyncapi.generated.ts +62 -40
- package/src/types/openapi.generated.ts +726 -330
- package/src/types/services/index.ts +0 -1
- package/src/types/transcripts/index.ts +17 -7
- package/dist/types/services/abstractions.d.ts +0 -52
- package/src/types/services/abstractions.ts +0 -56
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { FileUploadParams } from "../files";
|
|
2
2
|
import { TranscriptParams } from "../openapi.generated";
|
|
3
|
+
/**
|
|
4
|
+
* Options for polling.
|
|
5
|
+
*/
|
|
3
6
|
export type PollingOptions = {
|
|
4
7
|
/**
|
|
5
8
|
* The amount of time to wait between polling requests.
|
|
6
|
-
* @
|
|
9
|
+
* @defaultValue 3000 or every 3 seconds
|
|
7
10
|
*/
|
|
8
11
|
pollingInterval?: number;
|
|
9
12
|
/**
|
|
10
13
|
* The maximum amount of time to wait for the transcript to be ready.
|
|
11
|
-
* @
|
|
14
|
+
* @defaultValue -1 which means wait forever
|
|
12
15
|
*/
|
|
13
16
|
pollingTimeout?: number;
|
|
14
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Use `TranscriptService.transcribe` with `TranscribeOptions`.
|
|
20
|
+
*/
|
|
15
21
|
export type CreateTranscriptOptions = {
|
|
16
22
|
/**
|
|
17
23
|
* Whether to poll the transcript until it is ready.
|
|
18
|
-
* @
|
|
24
|
+
* @defaultValue true
|
|
19
25
|
*/
|
|
20
26
|
poll?: boolean;
|
|
21
27
|
} & PollingOptions;
|
|
@@ -26,9 +32,12 @@ export type AudioToTranscribe = FileUploadParams;
|
|
|
26
32
|
/**
|
|
27
33
|
* The parameters to transcribe an audio file.
|
|
28
34
|
*/
|
|
29
|
-
export type TranscribeParams = {
|
|
35
|
+
export type TranscribeParams = ({
|
|
36
|
+
/**
|
|
37
|
+
* The audio to transcribe. This can be a public URL, a local file path, a readable file stream, or a file buffer.
|
|
38
|
+
*/
|
|
30
39
|
audio: AudioToTranscribe;
|
|
31
|
-
} & Omit<TranscriptParams, "audio_url"
|
|
40
|
+
} & Omit<TranscriptParams, "audio_url">) | TranscriptParams;
|
|
32
41
|
/**
|
|
33
42
|
* The parameters to start the transcription of an audio file.
|
|
34
43
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assemblyai",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.2",
|
|
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"
|
|
@@ -110,6 +110,7 @@
|
|
|
110
110
|
"@typescript-eslint/eslint-plugin": "^6.7.5",
|
|
111
111
|
"dotenv": "^16.3.1",
|
|
112
112
|
"eslint": "^8.48.0",
|
|
113
|
+
"eslint-plugin-tsdoc": "^0.2.17",
|
|
113
114
|
"jest": "^29.5.0",
|
|
114
115
|
"jest-cli": "^29.5.0",
|
|
115
116
|
"jest-fetch-mock": "^3.0.3",
|
package/src/services/base.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { Error as JsonError } from "..";
|
|
|
7
7
|
export abstract class BaseService {
|
|
8
8
|
/**
|
|
9
9
|
* Create a new service.
|
|
10
|
-
* @param params The parameters to use for the service.
|
|
10
|
+
* @param params - The parameters to use for the service.
|
|
11
11
|
*/
|
|
12
12
|
constructor(private params: BaseServiceParams) {}
|
|
13
13
|
protected async fetch(
|
|
@@ -5,8 +5,8 @@ import { UploadedFile, FileUploadParams, FileUploadData } from "../..";
|
|
|
5
5
|
export class FileService extends BaseService {
|
|
6
6
|
/**
|
|
7
7
|
* Upload a local file to AssemblyAI.
|
|
8
|
-
* @param input The local file path to upload, or a stream or buffer of the file to upload.
|
|
9
|
-
* @
|
|
8
|
+
* @param input - The local file path to upload, or a stream or buffer of the file to upload.
|
|
9
|
+
* @returns A promise that resolves to the uploaded file URL.
|
|
10
10
|
*/
|
|
11
11
|
async upload(input: FileUploadParams): Promise<string> {
|
|
12
12
|
let fileData: FileUploadData;
|
package/src/services/index.ts
CHANGED
|
@@ -34,7 +34,7 @@ class AssemblyAI {
|
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Create a new AssemblyAI client.
|
|
37
|
-
* @param params The parameters for the service, including the API key and base URL, if any.
|
|
37
|
+
* @param params - The parameters for the service, including the API key and base URL, if any.
|
|
38
38
|
*/
|
|
39
39
|
constructor(params: BaseServiceParams) {
|
|
40
40
|
params.baseUrl = params.baseUrl || defaultBaseUrl;
|
|
@@ -52,7 +52,7 @@ export class LemurService extends BaseService {
|
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* Delete the data for a previously submitted LeMUR request.
|
|
55
|
-
* @param id ID of the LeMUR request
|
|
55
|
+
* @param id - ID of the LeMUR request
|
|
56
56
|
*/
|
|
57
57
|
purgeRequestData(id: string): Promise<PurgeLemurRequestDataResponse> {
|
|
58
58
|
return this.fetchJson<PurgeLemurRequestDataResponse>(`/lemur/v3/${id}`, {
|
|
@@ -58,8 +58,7 @@ export class RealtimeTranscriber {
|
|
|
58
58
|
this.sampleRate = params.sampleRate ?? 16_000;
|
|
59
59
|
this.wordBoost = params.wordBoost;
|
|
60
60
|
this.encoding = params.encoding;
|
|
61
|
-
this.endUtteranceSilenceThreshold =
|
|
62
|
-
params.endUtteranceSilenceThreshold;
|
|
61
|
+
this.endUtteranceSilenceThreshold = params.endUtteranceSilenceThreshold;
|
|
63
62
|
if ("token" in params && params.token) this.token = params.token;
|
|
64
63
|
if ("apiKey" in params && params.apiKey) this.apiKey = params.apiKey;
|
|
65
64
|
|
|
@@ -214,8 +213,8 @@ export class RealtimeTranscriber {
|
|
|
214
213
|
|
|
215
214
|
/**
|
|
216
215
|
* Configure the threshold for how long to wait before ending an utterance. Default is 700ms.
|
|
217
|
-
* @param threshold The duration of the end utterance silence threshold in milliseconds
|
|
218
|
-
*
|
|
216
|
+
* @param threshold - The duration of the end utterance silence threshold in milliseconds.
|
|
217
|
+
* This value must be an integer between 0 and 20_000.
|
|
219
218
|
*/
|
|
220
219
|
configureEndUtteranceSilenceThreshold(threshold: number) {
|
|
221
220
|
this.send(`{"end_utterance_silence_threshold":${threshold}}`);
|
|
@@ -6,10 +6,6 @@ import {
|
|
|
6
6
|
TranscriptList,
|
|
7
7
|
TranscriptParams,
|
|
8
8
|
CreateTranscriptOptions,
|
|
9
|
-
Createable,
|
|
10
|
-
Deletable,
|
|
11
|
-
Listable,
|
|
12
|
-
Retrieveable,
|
|
13
9
|
SubtitleFormat,
|
|
14
10
|
RedactedAudioResponse,
|
|
15
11
|
ListTranscriptParams,
|
|
@@ -23,22 +19,15 @@ import {
|
|
|
23
19
|
import { FileService } from "../files";
|
|
24
20
|
import { getPath } from "../../utils/path";
|
|
25
21
|
|
|
26
|
-
export class TranscriptService
|
|
27
|
-
extends BaseService
|
|
28
|
-
implements
|
|
29
|
-
Createable<Transcript, TranscriptParams, CreateTranscriptOptions>,
|
|
30
|
-
Retrieveable<Transcript>,
|
|
31
|
-
Deletable<Transcript>,
|
|
32
|
-
Listable<TranscriptList>
|
|
33
|
-
{
|
|
22
|
+
export class TranscriptService extends BaseService {
|
|
34
23
|
constructor(params: BaseServiceParams, private files: FileService) {
|
|
35
24
|
super(params);
|
|
36
25
|
}
|
|
37
26
|
|
|
38
27
|
/**
|
|
39
28
|
* Transcribe an audio file. This will create a transcript and wait until the transcript status is "completed" or "error".
|
|
40
|
-
* @param params The parameters to transcribe an audio file.
|
|
41
|
-
* @param options The options to transcribe an audio file.
|
|
29
|
+
* @param params - The parameters to transcribe an audio file.
|
|
30
|
+
* @param options - The options to transcribe an audio file.
|
|
42
31
|
* @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
|
|
43
32
|
*/
|
|
44
33
|
async transcribe(
|
|
@@ -51,37 +40,43 @@ export class TranscriptService
|
|
|
51
40
|
|
|
52
41
|
/**
|
|
53
42
|
* Submits a transcription job for an audio file. This will not wait until the transcript status is "completed" or "error".
|
|
54
|
-
* @param params The parameters to start the transcription of an audio file.
|
|
43
|
+
* @param params - The parameters to start the transcription of an audio file.
|
|
55
44
|
* @returns A promise that resolves to the queued transcript.
|
|
56
45
|
*/
|
|
57
46
|
async submit(params: SubmitParams): Promise<Transcript> {
|
|
58
|
-
const { audio, ...createParams } = params;
|
|
59
47
|
let audioUrl;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
48
|
+
let transcriptParams: TranscriptParams | undefined = undefined;
|
|
49
|
+
if ("audio" in params) {
|
|
50
|
+
const { audio, ...audioTranscriptParams } = params;
|
|
51
|
+
if (typeof audio === "string") {
|
|
52
|
+
const path = getPath(audio);
|
|
53
|
+
if (path !== null) {
|
|
54
|
+
// audio is local path, upload local file
|
|
55
|
+
audioUrl = await this.files.upload(path);
|
|
56
|
+
} else {
|
|
57
|
+
// audio is not a local path, assume it's a URL
|
|
58
|
+
audioUrl = audio;
|
|
59
|
+
}
|
|
65
60
|
} else {
|
|
66
|
-
// audio is
|
|
67
|
-
audioUrl = audio;
|
|
61
|
+
// audio is of uploadable type
|
|
62
|
+
audioUrl = await this.files.upload(audio);
|
|
68
63
|
}
|
|
64
|
+
transcriptParams = { ...audioTranscriptParams, audio_url: audioUrl };
|
|
69
65
|
} else {
|
|
70
|
-
|
|
71
|
-
audioUrl = await this.files.upload(audio);
|
|
66
|
+
transcriptParams = params;
|
|
72
67
|
}
|
|
73
68
|
|
|
74
69
|
const data = await this.fetchJson<Transcript>("/v2/transcript", {
|
|
75
70
|
method: "POST",
|
|
76
|
-
body: JSON.stringify(
|
|
71
|
+
body: JSON.stringify(transcriptParams),
|
|
77
72
|
});
|
|
78
73
|
return data;
|
|
79
74
|
}
|
|
80
75
|
|
|
81
76
|
/**
|
|
82
77
|
* Create a transcript.
|
|
83
|
-
* @param params The parameters to create a transcript.
|
|
84
|
-
* @param options The options used for creating the new transcript.
|
|
78
|
+
* @param params - The parameters to create a transcript.
|
|
79
|
+
* @param options - The options used for creating the new transcript.
|
|
85
80
|
* @returns A promise that resolves to the transcript.
|
|
86
81
|
* @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
|
|
87
82
|
*/
|
|
@@ -109,8 +104,8 @@ export class TranscriptService
|
|
|
109
104
|
|
|
110
105
|
/**
|
|
111
106
|
* Wait until the transcript ready, either the status is "completed" or "error".
|
|
112
|
-
* @param transcriptId The ID of the transcript.
|
|
113
|
-
* @param options The options to wait until the transcript is ready.
|
|
107
|
+
* @param transcriptId - The ID of the transcript.
|
|
108
|
+
* @param options - The options to wait until the transcript is ready.
|
|
114
109
|
* @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
|
|
115
110
|
*/
|
|
116
111
|
async waitUntilReady(
|
|
@@ -138,7 +133,7 @@ export class TranscriptService
|
|
|
138
133
|
|
|
139
134
|
/**
|
|
140
135
|
* Retrieve a transcript.
|
|
141
|
-
* @param id The identifier of the transcript.
|
|
136
|
+
* @param id - The identifier of the transcript.
|
|
142
137
|
* @returns A promise that resolves to the transcript.
|
|
143
138
|
*/
|
|
144
139
|
get(id: string): Promise<Transcript> {
|
|
@@ -147,19 +142,17 @@ export class TranscriptService
|
|
|
147
142
|
|
|
148
143
|
/**
|
|
149
144
|
* Retrieves a page of transcript listings.
|
|
150
|
-
* @param
|
|
145
|
+
* @param params - The parameters to filter the transcript list by, or the URL to retrieve the transcript list from.
|
|
151
146
|
*/
|
|
152
|
-
async list(
|
|
153
|
-
parameters?: ListTranscriptParams | string
|
|
154
|
-
): Promise<TranscriptList> {
|
|
147
|
+
async list(params?: ListTranscriptParams | string): Promise<TranscriptList> {
|
|
155
148
|
let url = "/v2/transcript";
|
|
156
|
-
if (typeof
|
|
157
|
-
url =
|
|
158
|
-
} else if (
|
|
149
|
+
if (typeof params === "string") {
|
|
150
|
+
url = params;
|
|
151
|
+
} else if (params) {
|
|
159
152
|
url = `${url}?${new URLSearchParams(
|
|
160
|
-
Object.keys(
|
|
153
|
+
Object.keys(params).map((key) => [
|
|
161
154
|
key,
|
|
162
|
-
|
|
155
|
+
params[key as keyof ListTranscriptParams]?.toString() || "",
|
|
163
156
|
])
|
|
164
157
|
)}`;
|
|
165
158
|
}
|
|
@@ -176,7 +169,7 @@ export class TranscriptService
|
|
|
176
169
|
|
|
177
170
|
/**
|
|
178
171
|
* Delete a transcript
|
|
179
|
-
* @param id The identifier of the transcript.
|
|
172
|
+
* @param id - The identifier of the transcript.
|
|
180
173
|
* @returns A promise that resolves to the transcript.
|
|
181
174
|
*/
|
|
182
175
|
delete(id: string): Promise<Transcript> {
|
|
@@ -186,9 +179,9 @@ export class TranscriptService
|
|
|
186
179
|
/**
|
|
187
180
|
* Search through the transcript for a specific set of keywords.
|
|
188
181
|
* You can search for individual words, numbers, or phrases containing up to five words or numbers.
|
|
189
|
-
* @param id The identifier of the transcript.
|
|
190
|
-
* @param words Keywords to search for.
|
|
191
|
-
* @
|
|
182
|
+
* @param id - The identifier of the transcript.
|
|
183
|
+
* @param words - Keywords to search for.
|
|
184
|
+
* @returns A promise that resolves to the sentences.
|
|
192
185
|
*/
|
|
193
186
|
wordSearch(id: string, words: string[]): Promise<WordSearchResponse> {
|
|
194
187
|
const params = new URLSearchParams({ words: words.join(",") });
|
|
@@ -199,8 +192,8 @@ export class TranscriptService
|
|
|
199
192
|
|
|
200
193
|
/**
|
|
201
194
|
* Retrieve all sentences of a transcript.
|
|
202
|
-
* @param id The identifier of the transcript.
|
|
203
|
-
* @
|
|
195
|
+
* @param id - The identifier of the transcript.
|
|
196
|
+
* @returns A promise that resolves to the sentences.
|
|
204
197
|
*/
|
|
205
198
|
sentences(id: string): Promise<SentencesResponse> {
|
|
206
199
|
return this.fetchJson<SentencesResponse>(`/v2/transcript/${id}/sentences`);
|
|
@@ -208,8 +201,8 @@ export class TranscriptService
|
|
|
208
201
|
|
|
209
202
|
/**
|
|
210
203
|
* Retrieve all paragraphs of a transcript.
|
|
211
|
-
* @param id The identifier of the transcript.
|
|
212
|
-
* @
|
|
204
|
+
* @param id - The identifier of the transcript.
|
|
205
|
+
* @returns A promise that resolves to the paragraphs.
|
|
213
206
|
*/
|
|
214
207
|
paragraphs(id: string): Promise<ParagraphsResponse> {
|
|
215
208
|
return this.fetchJson<ParagraphsResponse>(
|
|
@@ -219,10 +212,10 @@ export class TranscriptService
|
|
|
219
212
|
|
|
220
213
|
/**
|
|
221
214
|
* Retrieve subtitles of a transcript.
|
|
222
|
-
* @param id The identifier of the transcript.
|
|
223
|
-
* @param format The format of the subtitles.
|
|
224
|
-
* @param chars_per_caption The maximum number of characters per caption.
|
|
225
|
-
* @
|
|
215
|
+
* @param id - The identifier of the transcript.
|
|
216
|
+
* @param format - The format of the subtitles.
|
|
217
|
+
* @param chars_per_caption - The maximum number of characters per caption.
|
|
218
|
+
* @returns A promise that resolves to the subtitles text.
|
|
226
219
|
*/
|
|
227
220
|
async subtitles(
|
|
228
221
|
id: string,
|
|
@@ -241,8 +234,8 @@ export class TranscriptService
|
|
|
241
234
|
|
|
242
235
|
/**
|
|
243
236
|
* Retrieve redactions of a transcript.
|
|
244
|
-
* @param id The identifier of the transcript.
|
|
245
|
-
* @
|
|
237
|
+
* @param id - The identifier of the transcript.
|
|
238
|
+
* @returns A promise that resolves to the subtitles text.
|
|
246
239
|
*/
|
|
247
240
|
redactions(id: string): Promise<RedactedAudioResponse> {
|
|
248
241
|
return this.fetchJson<RedactedAudioResponse>(
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// this file is generated by typescript/scripts/generate-types.ts
|
|
2
2
|
/* tslint:disable */
|
|
3
3
|
/* eslint-disable */
|
|
4
|
-
|
|
5
4
|
import { LiteralUnion } from "./helpers";
|
|
6
5
|
|
|
7
6
|
/** OneOf type helpers */
|
|
@@ -15,44 +14,54 @@ type OneOf<T extends any[]> = T extends [infer Only]
|
|
|
15
14
|
? OneOf<[XOR<A, B>, ...Rest]>
|
|
16
15
|
: never;
|
|
17
16
|
|
|
17
|
+
/* eslint-enable */
|
|
18
|
+
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @description Binary audio data
|
|
20
|
+
* Binary audio data
|
|
21
21
|
*/
|
|
22
22
|
export type AudioData = ArrayBufferLike;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @
|
|
27
|
-
* @enum {string}
|
|
25
|
+
* The encoding of the audio data
|
|
26
|
+
* @defaultValue "pcm_s16"le
|
|
28
27
|
*/
|
|
29
28
|
export type AudioEncoding = "pcm_s16le" | "pcm_mulaw";
|
|
30
29
|
|
|
31
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Configure the threshold for how long to wait before ending an utterance. Default is 700ms.
|
|
32
|
+
*/
|
|
32
33
|
export type ConfigureEndUtteranceSilenceThreshold = {
|
|
33
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* The duration threshold in milliseconds
|
|
36
|
+
*/
|
|
34
37
|
end_utterance_silence_threshold: number;
|
|
35
38
|
};
|
|
36
39
|
|
|
37
40
|
export type FinalTranscript = RealtimeBaseTranscript & {
|
|
38
41
|
/**
|
|
39
|
-
*
|
|
40
|
-
* @constant
|
|
42
|
+
* Describes the type of message
|
|
41
43
|
*/
|
|
42
44
|
message_type: "FinalTranscript";
|
|
43
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Whether the text is punctuated and cased
|
|
47
|
+
*/
|
|
44
48
|
punctuated: boolean;
|
|
45
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Whether the text is formatted, for example Dollar -> $
|
|
51
|
+
*/
|
|
46
52
|
text_formatted: boolean;
|
|
47
53
|
};
|
|
48
54
|
|
|
49
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Manually end an utterance
|
|
57
|
+
*/
|
|
50
58
|
export type ForceEndUtterance = {
|
|
51
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* A boolean value to communicate that you wish to force the end of the utterance
|
|
61
|
+
*/
|
|
52
62
|
force_end_utterance: boolean;
|
|
53
63
|
};
|
|
54
64
|
|
|
55
|
-
/** @enum {string} */
|
|
56
65
|
export type MessageType =
|
|
57
66
|
| "SessionBegins"
|
|
58
67
|
| "PartialTranscript"
|
|
@@ -61,33 +70,41 @@ export type MessageType =
|
|
|
61
70
|
|
|
62
71
|
export type PartialTranscript = RealtimeBaseTranscript & {
|
|
63
72
|
/**
|
|
64
|
-
*
|
|
65
|
-
* @constant
|
|
73
|
+
* Describes the type of message
|
|
66
74
|
*/
|
|
67
75
|
message_type: "PartialTranscript";
|
|
68
76
|
};
|
|
69
77
|
|
|
70
78
|
export type RealtimeBaseMessage = {
|
|
71
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Describes the type of the message
|
|
81
|
+
*/
|
|
72
82
|
message_type: MessageType;
|
|
73
83
|
};
|
|
74
84
|
|
|
75
85
|
export type RealtimeBaseTranscript = {
|
|
76
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* End time of audio sample relative to session start, in milliseconds
|
|
88
|
+
*/
|
|
77
89
|
audio_end: number;
|
|
78
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* Start time of audio sample relative to session start, in milliseconds
|
|
92
|
+
*/
|
|
79
93
|
audio_start: number;
|
|
80
94
|
/**
|
|
81
|
-
*
|
|
82
|
-
* @description The confidence score of the entire transcription, between 0 and 1
|
|
95
|
+
* The confidence score of the entire transcription, between 0 and 1
|
|
83
96
|
*/
|
|
84
97
|
confidence: number;
|
|
85
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* The timestamp for the partial transcript
|
|
100
|
+
*/
|
|
86
101
|
created: Date;
|
|
87
|
-
/**
|
|
102
|
+
/**
|
|
103
|
+
* The partial transcript for your audio
|
|
104
|
+
*/
|
|
88
105
|
text: string;
|
|
89
106
|
/**
|
|
90
|
-
*
|
|
107
|
+
* An array of objects, with the information for each word in the transcription text.
|
|
91
108
|
* Includes the start and end time of the word in milliseconds, the confidence score of the word, and the text, which is the word itself.
|
|
92
109
|
*/
|
|
93
110
|
words: Word[];
|
|
@@ -106,47 +123,52 @@ export type RealtimeMessage =
|
|
|
106
123
|
|
|
107
124
|
export type RealtimeTranscript = PartialTranscript | FinalTranscript;
|
|
108
125
|
|
|
109
|
-
/** @enum {string} */
|
|
110
126
|
export type RealtimeTranscriptType = "PartialTranscript" | "FinalTranscript";
|
|
111
127
|
|
|
112
128
|
export type SessionBegins = RealtimeBaseMessage & {
|
|
113
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* Timestamp when this session will expire
|
|
131
|
+
*/
|
|
114
132
|
expires_at: Date;
|
|
115
133
|
/**
|
|
116
|
-
*
|
|
117
|
-
* @constant
|
|
134
|
+
* Describes the type of the message
|
|
118
135
|
*/
|
|
119
136
|
message_type: "SessionBegins";
|
|
120
137
|
/**
|
|
121
|
-
*
|
|
122
|
-
* @description Unique identifier for the established session
|
|
138
|
+
* Unique identifier for the established session
|
|
123
139
|
*/
|
|
124
140
|
session_id: string;
|
|
125
141
|
};
|
|
126
142
|
|
|
127
143
|
export type SessionTerminated = RealtimeBaseMessage & {
|
|
128
144
|
/**
|
|
129
|
-
*
|
|
130
|
-
* @constant
|
|
145
|
+
* Describes the type of the message
|
|
131
146
|
*/
|
|
132
147
|
message_type: "SessionTerminated";
|
|
133
148
|
};
|
|
134
149
|
|
|
135
|
-
export type TerminateSession =
|
|
136
|
-
/**
|
|
150
|
+
export type TerminateSession = {
|
|
151
|
+
/**
|
|
152
|
+
* Set to true to end your real-time session forever
|
|
153
|
+
*/
|
|
137
154
|
terminate_session: boolean;
|
|
138
155
|
};
|
|
139
156
|
|
|
140
157
|
export type Word = {
|
|
141
158
|
/**
|
|
142
|
-
*
|
|
143
|
-
* @description Confidence score of the word
|
|
159
|
+
* Confidence score of the word
|
|
144
160
|
*/
|
|
145
161
|
confidence: number;
|
|
146
|
-
/**
|
|
162
|
+
/**
|
|
163
|
+
* End time of the word in milliseconds
|
|
164
|
+
*/
|
|
147
165
|
end: number;
|
|
148
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* Start time of the word in milliseconds
|
|
168
|
+
*/
|
|
149
169
|
start: number;
|
|
150
|
-
/**
|
|
170
|
+
/**
|
|
171
|
+
* The word itself
|
|
172
|
+
*/
|
|
151
173
|
text: string;
|
|
152
174
|
};
|