assemblyai 3.0.0 → 3.1.0

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.
Files changed (36) hide show
  1. package/README.md +15 -3
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.esm.js +119 -102
  4. package/dist/index.js +120 -103
  5. package/dist/services/base.d.ts +6 -4
  6. package/dist/services/files/index.d.ts +2 -2
  7. package/dist/services/index.d.ts +1 -1
  8. package/dist/services/lemur/index.d.ts +2 -2
  9. package/dist/services/realtime/factory.d.ts +5 -6
  10. package/dist/services/realtime/index.d.ts +2 -2
  11. package/dist/services/realtime/service.d.ts +2 -3
  12. package/dist/services/transcripts/index.d.ts +7 -7
  13. package/dist/types/asyncapi.generated.d.ts +20 -17
  14. package/dist/types/files/index.d.ts +1 -2
  15. package/dist/types/index.d.ts +6 -6
  16. package/dist/types/openapi.generated.d.ts +134 -108
  17. package/dist/types/services/index.d.ts +1 -1
  18. package/dist/types/transcripts/index.d.ts +16 -2
  19. package/package.json +2 -2
  20. package/src/index.ts +1 -1
  21. package/src/services/base.ts +44 -3
  22. package/src/services/files/index.ts +10 -12
  23. package/src/services/index.ts +10 -8
  24. package/src/services/lemur/index.ts +28 -27
  25. package/src/services/realtime/factory.ts +17 -12
  26. package/src/services/realtime/index.ts +2 -2
  27. package/src/services/realtime/service.ts +5 -6
  28. package/src/services/transcripts/index.ts +57 -55
  29. package/src/types/asyncapi.generated.ts +20 -17
  30. package/src/types/files/index.ts +2 -1
  31. package/src/types/index.ts +6 -6
  32. package/src/types/openapi.generated.ts +136 -108
  33. package/src/types/services/index.ts +1 -1
  34. package/src/types/transcripts/index.ts +16 -2
  35. package/dist/utils/axios.d.ts +0 -3
  36. package/src/utils/axios.ts +0 -19
@@ -1,4 +1,5 @@
1
- import { AxiosInstance } from "axios";
1
+ import { BaseServiceParams } from "..";
2
+ import { Error as JsonError } from "..";
2
3
 
3
4
  /**
4
5
  * Base class for services that communicate with the API.
@@ -6,7 +7,47 @@ import { AxiosInstance } from "axios";
6
7
  export abstract class BaseService {
7
8
  /**
8
9
  * Create a new service.
9
- * @param params The AxiosInstance to send HTTP requests to the API.
10
+ * @param params The parameters to use for the service.
10
11
  */
11
- constructor(protected client: AxiosInstance) {}
12
+ constructor(private params: BaseServiceParams) {}
13
+ protected async fetch(
14
+ input: string,
15
+ init?: RequestInit | undefined
16
+ ): Promise<Response> {
17
+ init = init ?? {};
18
+ init.headers = init.headers ?? {};
19
+ init.headers = {
20
+ Authorization: this.params.apiKey,
21
+ "Content-Type": "application/json",
22
+ ...init.headers,
23
+ };
24
+ if (!input.startsWith("http")) input = this.params.baseUrl + input;
25
+
26
+ const response = await fetch(input, init);
27
+
28
+ if (response.status >= 400) {
29
+ let json: JsonError | undefined;
30
+ const text = await response.text();
31
+ if (text) {
32
+ try {
33
+ json = JSON.parse(text);
34
+ } catch {
35
+ /* empty */
36
+ }
37
+ if (json?.error) throw new Error(json.error);
38
+ throw new Error(text);
39
+ }
40
+ throw new Error(`HTTP Error: ${response.status} ${response.statusText}`);
41
+ }
42
+
43
+ return response;
44
+ }
45
+
46
+ protected async fetchJson<T>(
47
+ input: string,
48
+ init?: RequestInit | undefined
49
+ ): Promise<T> {
50
+ const response = await this.fetch(input, init);
51
+ return response.json() as Promise<T>;
52
+ }
12
53
  }
@@ -1,8 +1,8 @@
1
1
  // import the fs module instead if specific named exports
2
2
  // to keep the assemblyai module more compatible. Some fs polyfills don't include `createReadStream`.
3
3
  import fs from "fs";
4
- import { BaseService } from "@/services/base";
5
- import { UploadedFile, FileUploadParameters, FileUploadData } from "@/types";
4
+ import { BaseService } from "../base";
5
+ import { UploadedFile, FileUploadParameters, FileUploadData } from "../..";
6
6
 
7
7
  export class FileService extends BaseService {
8
8
  /**
@@ -15,16 +15,14 @@ export class FileService extends BaseService {
15
15
  if (typeof input === "string") fileData = fs.createReadStream(input);
16
16
  else fileData = input;
17
17
 
18
- const { data } = await this.client.post<UploadedFile>(
19
- "/v2/upload",
20
- fileData,
21
- {
22
- headers: {
23
- "Content-Type": "application/octet-stream",
24
- },
25
- }
26
- );
27
-
18
+ const data = await this.fetchJson<UploadedFile>("/v2/upload", {
19
+ method: "POST",
20
+ body: fileData as BodyInit,
21
+ headers: {
22
+ "Content-Type": "application/octet-stream",
23
+ },
24
+ duplex: "half",
25
+ } as RequestInit);
28
26
  return data.upload_url;
29
27
  }
30
28
  }
@@ -1,10 +1,11 @@
1
- import { createAxiosClient } from "@/utils/axios";
2
- import { BaseServiceParams } from "@/types";
1
+ import { BaseServiceParams } from "..";
3
2
  import { LemurService } from "./lemur";
4
3
  import { RealtimeService, RealtimeServiceFactory } from "./realtime";
5
4
  import { TranscriptService } from "./transcripts";
6
5
  import { FileService } from "./files";
7
6
 
7
+ const defaultBaseUrl = "https://api.assemblyai.com";
8
+
8
9
  class AssemblyAI {
9
10
  /**
10
11
  * The files service.
@@ -31,12 +32,13 @@ class AssemblyAI {
31
32
  * @param params The parameters for the service, including the API key and base URL, if any.
32
33
  */
33
34
  constructor(params: BaseServiceParams) {
34
- params.baseUrl = params.baseUrl || "https://api.assemblyai.com";
35
- const client = createAxiosClient(params);
36
- this.files = new FileService(client);
37
- this.transcripts = new TranscriptService(client, this.files);
38
- this.lemur = new LemurService(client);
39
- this.realtime = new RealtimeServiceFactory(client, params);
35
+ params.baseUrl = params.baseUrl || defaultBaseUrl;
36
+ if (params.baseUrl && params.baseUrl.endsWith("/"))
37
+ params.baseUrl = params.baseUrl.slice(0, -1);
38
+ this.files = new FileService(params);
39
+ this.transcripts = new TranscriptService(params, this.files);
40
+ this.lemur = new LemurService(params);
41
+ this.realtime = new RealtimeServiceFactory(params);
40
42
  }
41
43
  }
42
44
 
@@ -8,54 +8,55 @@ import {
8
8
  LemurActionItemsResponse,
9
9
  LemurTaskResponse,
10
10
  PurgeLemurRequestDataResponse,
11
- } from "@/types";
12
- import { BaseService } from "@/services/base";
11
+ } from "../..";
12
+ import { BaseService } from "../base";
13
13
 
14
14
  export class LemurService extends BaseService {
15
- async summary(params: LemurSummaryParameters): Promise<LemurSummaryResponse> {
16
- const { data } = await this.client.post<LemurSummaryResponse>(
17
- "/lemur/v3/generate/summary",
18
- params
19
- );
20
- return data;
15
+ summary(params: LemurSummaryParameters): Promise<LemurSummaryResponse> {
16
+ return this.fetchJson<LemurSummaryResponse>("/lemur/v3/generate/summary", {
17
+ method: "POST",
18
+ body: JSON.stringify(params),
19
+ });
21
20
  }
22
21
 
23
- async questionAnswer(
22
+ questionAnswer(
24
23
  params: LemurQuestionAnswerParameters
25
24
  ): Promise<LemurQuestionAnswerResponse> {
26
- const { data } = await this.client.post<LemurQuestionAnswerResponse>(
25
+ return this.fetchJson<LemurQuestionAnswerResponse>(
27
26
  "/lemur/v3/generate/question-answer",
28
- params
27
+ {
28
+ method: "POST",
29
+ body: JSON.stringify(params),
30
+ }
29
31
  );
30
- return data;
31
32
  }
32
33
 
33
- async actionItems(
34
+ actionItems(
34
35
  params: LemurActionItemsParameters
35
36
  ): Promise<LemurActionItemsResponse> {
36
- const { data } = await this.client.post<LemurActionItemsResponse>(
37
+ return this.fetchJson<LemurActionItemsResponse>(
37
38
  "/lemur/v3/generate/action-items",
38
- params
39
+ {
40
+ method: "POST",
41
+ body: JSON.stringify(params),
42
+ }
39
43
  );
40
- return data;
41
44
  }
42
45
 
43
- async task(params: LemurTaskParameters): Promise<LemurTaskResponse> {
44
- const { data } = await this.client.post<LemurTaskResponse>(
45
- "/lemur/v3/generate/task",
46
- params
47
- );
48
- return data;
46
+ task(params: LemurTaskParameters): Promise<LemurTaskResponse> {
47
+ return this.fetchJson<LemurTaskResponse>("/lemur/v3/generate/task", {
48
+ method: "POST",
49
+ body: JSON.stringify(params),
50
+ });
49
51
  }
50
52
 
51
53
  /**
52
54
  * Delete the data for a previously submitted LeMUR request.
53
55
  * @param id ID of the LeMUR request
54
56
  */
55
- async purgeRequestData(id: string): Promise<PurgeLemurRequestDataResponse> {
56
- const { data } = await this.client.delete<PurgeLemurRequestDataResponse>(
57
- `/lemur/v3/${id}`
58
- );
59
- return data;
57
+ purgeRequestData(id: string): Promise<PurgeLemurRequestDataResponse> {
58
+ return this.fetchJson<PurgeLemurRequestDataResponse>(`/lemur/v3/${id}`, {
59
+ method: "DELETE",
60
+ });
60
61
  }
61
62
  }
@@ -3,30 +3,35 @@ import {
3
3
  RealtimeTokenParams,
4
4
  CreateRealtimeServiceParams,
5
5
  RealtimeServiceParams,
6
- } from "@/types";
7
- import { AxiosInstance } from "axios";
6
+ RealtimeTemporaryTokenResponse,
7
+ } from "../..";
8
8
  import { RealtimeService } from "./service";
9
+ import { BaseService } from "../base";
9
10
 
10
- export class RealtimeServiceFactory {
11
- constructor(
12
- private client: AxiosInstance,
13
- private params: BaseServiceParams
14
- ) {}
11
+ export class RealtimeServiceFactory extends BaseService {
12
+ private rtFactoryParams: BaseServiceParams;
13
+ constructor(params: BaseServiceParams) {
14
+ super(params);
15
+ this.rtFactoryParams = params;
16
+ }
15
17
 
16
18
  createService(params?: CreateRealtimeServiceParams): RealtimeService {
17
- if (!params) params = { apiKey: this.params.apiKey };
19
+ if (!params) params = { apiKey: this.rtFactoryParams.apiKey };
18
20
  else if (!("token" in params) && !params.apiKey) {
19
- params.apiKey = this.params.apiKey;
21
+ params.apiKey = this.rtFactoryParams.apiKey;
20
22
  }
21
23
 
22
24
  return new RealtimeService(params as RealtimeServiceParams);
23
25
  }
24
26
 
25
27
  async createTemporaryToken(params: RealtimeTokenParams) {
26
- const response = await this.client.post<{ token: string }>(
28
+ const data = await this.fetchJson<RealtimeTemporaryTokenResponse>(
27
29
  "/v2/realtime/token",
28
- params
30
+ {
31
+ method: "POST",
32
+ body: JSON.stringify(params),
33
+ }
29
34
  );
30
- return response.data.token;
35
+ return data.token;
31
36
  }
32
37
  }
@@ -1,2 +1,2 @@
1
- export * from "@/services/realtime/factory";
2
- export * from "@/services/realtime/service";
1
+ export * from "./factory";
2
+ export * from "./service";
@@ -8,13 +8,13 @@ import {
8
8
  PartialTranscript,
9
9
  FinalTranscript,
10
10
  SessionBeginsEventData,
11
- } from "@/types";
11
+ } from "../..";
12
12
  import {
13
13
  RealtimeError,
14
14
  RealtimeErrorMessages,
15
15
  RealtimeErrorType,
16
- } from "@/utils/errors";
17
- import { Writable } from "stream";
16
+ } from "../../utils/errors";
17
+ import Stream from "stream";
18
18
 
19
19
  const defaultRealtimeUrl = "wss://api.assemblyai.com/v2/realtime/ws";
20
20
 
@@ -32,7 +32,6 @@ export class RealtimeService {
32
32
  this.realtimeUrl = params.realtimeUrl ?? defaultRealtimeUrl;
33
33
  this.sampleRate = params.sampleRate ?? 16_000;
34
34
  this.wordBoost = params.wordBoost;
35
- this.realtimeUrl = params.realtimeUrl ?? defaultRealtimeUrl;
36
35
  if ("apiKey" in params) this.apiKey = params.apiKey;
37
36
  if ("token" in params) this.token = params.token;
38
37
 
@@ -162,8 +161,8 @@ export class RealtimeService {
162
161
  this.socket.send(JSON.stringify(payload));
163
162
  }
164
163
 
165
- stream(): Writable {
166
- const stream = new Writable({
164
+ stream(): NodeJS.WritableStream {
165
+ const stream = new Stream.Writable({
167
166
  write: (chunk: Buffer, encoding, next) => {
168
167
  this.sendAudio(chunk);
169
168
  next();
@@ -1,4 +1,4 @@
1
- import { BaseService } from "@/services/base";
1
+ import { BaseService } from "../base";
2
2
  import {
3
3
  ParagraphsResponse,
4
4
  SentencesResponse,
@@ -14,8 +14,9 @@ import {
14
14
  RedactedAudioResponse,
15
15
  TranscriptListParameters,
16
16
  WordSearchResponse,
17
- } from "@/types";
18
- import { AxiosInstance } from "axios";
17
+ BaseServiceParams,
18
+ PollingOptions,
19
+ } from "../..";
19
20
  import { FileService } from "../files";
20
21
 
21
22
  export class TranscriptService
@@ -26,8 +27,8 @@ export class TranscriptService
26
27
  Deletable<Transcript>,
27
28
  Listable<TranscriptList>
28
29
  {
29
- constructor(client: AxiosInstance, private files: FileService) {
30
- super(client);
30
+ constructor(params: BaseServiceParams, private files: FileService) {
31
+ super(params);
31
32
  }
32
33
 
33
34
  /**
@@ -46,19 +47,24 @@ export class TranscriptService
46
47
  params.audio_url = uploadUrl;
47
48
  }
48
49
 
49
- const res = await this.client.post<Transcript>("/v2/transcript", params);
50
+ const data = await this.fetchJson<Transcript>("/v2/transcript", {
51
+ method: "POST",
52
+ body: JSON.stringify(params),
53
+ });
50
54
 
51
55
  if (options?.poll ?? true) {
52
- return await this.poll(res.data.id, options);
56
+ return await this.waitUntilReady(data.id, options);
53
57
  }
54
58
 
55
- return res.data;
59
+ return data;
56
60
  }
57
61
 
58
- private async poll(
62
+ async waitUntilReady(
59
63
  transcriptId: string,
60
- options?: CreateTranscriptOptions
64
+ options?: PollingOptions
61
65
  ): Promise<Transcript> {
66
+ const pollingInterval = options?.pollingInterval ?? 3_000;
67
+ const pollingTimeout = options?.pollingTimeout ?? -1;
62
68
  const startTime = Date.now();
63
69
  // eslint-disable-next-line no-constant-condition
64
70
  while (true) {
@@ -66,14 +72,12 @@ export class TranscriptService
66
72
  if (transcript.status === "completed" || transcript.status === "error") {
67
73
  return transcript;
68
74
  } else if (
69
- Date.now() - startTime <
70
- (options?.pollingTimeout ?? 180_000)
75
+ pollingTimeout > 0 &&
76
+ Date.now() - startTime > pollingTimeout
71
77
  ) {
72
- await new Promise((resolve) =>
73
- setTimeout(resolve, options?.pollingInterval ?? 3_000)
74
- );
75
- } else {
76
78
  throw new Error("Polling timeout");
79
+ } else {
80
+ await new Promise((resolve) => setTimeout(resolve, pollingInterval));
77
81
  }
78
82
  }
79
83
  }
@@ -83,9 +87,8 @@ export class TranscriptService
83
87
  * @param id The identifier of the transcript.
84
88
  * @returns A promise that resolves to the transcript.
85
89
  */
86
- async get(id: string): Promise<Transcript> {
87
- const res = await this.client.get<Transcript>(`/v2/transcript/${id}`);
88
- return res.data;
90
+ get(id: string): Promise<Transcript> {
91
+ return this.fetchJson<Transcript>(`/v2/transcript/${id}`);
89
92
  }
90
93
 
91
94
  /**
@@ -96,15 +99,17 @@ export class TranscriptService
96
99
  parameters?: TranscriptListParameters | string
97
100
  ): Promise<TranscriptList> {
98
101
  let url = "/v2/transcript";
99
- let query: TranscriptListParameters | undefined;
100
102
  if (typeof parameters === "string") {
101
103
  url = parameters;
102
104
  } else if (parameters) {
103
- query = parameters;
105
+ url = `${url}?${new URLSearchParams(
106
+ Object.keys(parameters).map((key) => [
107
+ key,
108
+ parameters[key as keyof TranscriptListParameters]?.toString() || "",
109
+ ])
110
+ )}`;
104
111
  }
105
- const { data } = await this.client.get<TranscriptList>(url, {
106
- params: query,
107
- });
112
+ const data = await this.fetchJson<TranscriptList>(url);
108
113
  for (const transcriptListItem of data.transcripts) {
109
114
  transcriptListItem.created = new Date(transcriptListItem.created);
110
115
  if (transcriptListItem.completed) {
@@ -112,7 +117,7 @@ export class TranscriptService
112
117
  }
113
118
  }
114
119
 
115
- return data as unknown as TranscriptList;
120
+ return data;
116
121
  }
117
122
 
118
123
  /**
@@ -120,28 +125,22 @@ export class TranscriptService
120
125
  * @param id The identifier of the transcript.
121
126
  * @returns A promise that resolves to the transcript.
122
127
  */
123
- async delete(id: string): Promise<Transcript> {
124
- const res = await this.client.delete<Transcript>(`/v2/transcript/${id}`);
125
- return res.data;
128
+ delete(id: string): Promise<Transcript> {
129
+ return this.fetchJson(`/v2/transcript/${id}`, { method: "DELETE" });
126
130
  }
127
131
 
128
132
  /**
129
133
  * Search through the transcript for a specific set of keywords.
130
134
  * You can search for individual words, numbers, or phrases containing up to five words or numbers.
131
135
  * @param id The identifier of the transcript.
132
- * @param id Keywords to search for.
136
+ * @param words Keywords to search for.
133
137
  * @return A promise that resolves to the sentences.
134
138
  */
135
- async wordSearch(id: string, words: string[]): Promise<WordSearchResponse> {
136
- const { data } = await this.client.get<WordSearchResponse>(
137
- `/v2/transcript/${id}/word-search`,
138
- {
139
- params: {
140
- words: JSON.stringify(words),
141
- },
142
- }
139
+ wordSearch(id: string, words: string[]): Promise<WordSearchResponse> {
140
+ const params = new URLSearchParams({ words: words.join(",") });
141
+ return this.fetchJson<WordSearchResponse>(
142
+ `/v2/transcript/${id}/word-search?${params.toString()}`
143
143
  );
144
- return data;
145
144
  }
146
145
 
147
146
  /**
@@ -149,11 +148,8 @@ export class TranscriptService
149
148
  * @param id The identifier of the transcript.
150
149
  * @return A promise that resolves to the sentences.
151
150
  */
152
- async sentences(id: string): Promise<SentencesResponse> {
153
- const { data } = await this.client.get<SentencesResponse>(
154
- `/v2/transcript/${id}/sentences`
155
- );
156
- return data;
151
+ sentences(id: string): Promise<SentencesResponse> {
152
+ return this.fetchJson<SentencesResponse>(`/v2/transcript/${id}/sentences`);
157
153
  }
158
154
 
159
155
  /**
@@ -161,25 +157,32 @@ export class TranscriptService
161
157
  * @param id The identifier of the transcript.
162
158
  * @return A promise that resolves to the paragraphs.
163
159
  */
164
- async paragraphs(id: string): Promise<ParagraphsResponse> {
165
- const { data } = await this.client.get<ParagraphsResponse>(
160
+ paragraphs(id: string): Promise<ParagraphsResponse> {
161
+ return this.fetchJson<ParagraphsResponse>(
166
162
  `/v2/transcript/${id}/paragraphs`
167
163
  );
168
- return data;
169
164
  }
170
165
 
171
166
  /**
172
167
  * Retrieve subtitles of a transcript.
173
168
  * @param id The identifier of the transcript.
174
169
  * @param format The format of the subtitles.
170
+ * @param chars_per_caption The maximum number of characters per caption.
175
171
  * @return A promise that resolves to the subtitles text.
176
172
  */
177
- async subtitles(id: string, format: SubtitleFormat = "srt"): Promise<string> {
178
- const { data } = await this.client.get<string>(
179
- `/v2/transcript/${id}/${format}`
180
- );
181
-
182
- return data;
173
+ async subtitles(
174
+ id: string,
175
+ format: SubtitleFormat = "srt",
176
+ chars_per_caption?: number
177
+ ): Promise<string> {
178
+ let url = `/v2/transcript/${id}/${format}`;
179
+ if (chars_per_caption) {
180
+ const params = new URLSearchParams();
181
+ params.set("chars_per_caption", chars_per_caption.toString());
182
+ url += `?${params.toString()}`;
183
+ }
184
+ const response = await this.fetch(url);
185
+ return await response.text();
183
186
  }
184
187
 
185
188
  /**
@@ -187,11 +190,10 @@ export class TranscriptService
187
190
  * @param id The identifier of the transcript.
188
191
  * @return A promise that resolves to the subtitles text.
189
192
  */
190
- async redactions(id: string): Promise<RedactedAudioResponse> {
191
- const { data } = await this.client.get<RedactedAudioResponse>(
193
+ redactions(id: string): Promise<RedactedAudioResponse> {
194
+ return this.fetchJson<RedactedAudioResponse>(
192
195
  `/v2/transcript/${id}/redacted-audio`
193
196
  );
194
- return data;
195
197
  }
196
198
  }
197
199
 
@@ -14,19 +14,19 @@ type OneOf<T extends any[]> = T extends [infer Only]
14
14
  : never;
15
15
 
16
16
  export type AudioData = {
17
- /** @description Raw audio data, base64 encoded. This can be the raw data recorded directly from a microphone or read from an audio file. */
17
+ /** @description Base64 encoded raw audio data */
18
18
  audio_data: string;
19
19
  };
20
20
 
21
21
  export type FinalTranscript = RealtimeBaseTranscript & {
22
22
  /**
23
- * @description Describes the type of message.
23
+ * @description Describes the type of message
24
24
  * @constant
25
25
  */
26
26
  message_type: "FinalTranscript";
27
- /** @description Whether the text has been punctuated and cased. */
27
+ /** @description Whether the text is punctuated and cased */
28
28
  punctuated: boolean;
29
- /** @description Whether the text has been formatted (e.g. Dollar -> $) */
29
+ /** @description Whether the text is formatted, for example Dollar -> $ */
30
30
  text_formatted: boolean;
31
31
  };
32
32
 
@@ -39,32 +39,35 @@ export type MessageType =
39
39
 
40
40
  export type PartialTranscript = RealtimeBaseTranscript & {
41
41
  /**
42
- * @description Describes the type of message.
42
+ * @description Describes the type of message
43
43
  * @constant
44
44
  */
45
45
  message_type: "PartialTranscript";
46
46
  };
47
47
 
48
48
  export type RealtimeBaseMessage = {
49
- /** @description Describes the type of the message. */
49
+ /** @description Describes the type of the message */
50
50
  message_type: MessageType;
51
51
  };
52
52
 
53
53
  export type RealtimeBaseTranscript = {
54
- /** @description End time of audio sample relative to session start, in milliseconds. */
54
+ /** @description End time of audio sample relative to session start, in milliseconds */
55
55
  audio_end: number;
56
- /** @description Start time of audio sample relative to session start, in milliseconds. */
56
+ /** @description Start time of audio sample relative to session start, in milliseconds */
57
57
  audio_start: number;
58
58
  /**
59
59
  * Format: double
60
- * @description The confidence score of the entire transcription, between 0 and 1.
60
+ * @description The confidence score of the entire transcription, between 0 and 1
61
61
  */
62
62
  confidence: number;
63
- /** @description The timestamp for the partial transcript. */
63
+ /** @description The timestamp for the partial transcript */
64
64
  created: Date;
65
- /** @description The partial transcript for your audio. */
65
+ /** @description The partial transcript for your audio */
66
66
  text: string;
67
- /** @description An array of objects, with the information for each word in the transcription text. Includes the start/end time (in milliseconds) of the word, the confidence score of the word, and the text (i.e. the word itself). */
67
+ /**
68
+ * @description An array of objects, with the information for each word in the transcription text.
69
+ * 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.
70
+ */
68
71
  words: Word[];
69
72
  };
70
73
 
@@ -85,27 +88,27 @@ export type RealtimeTranscript = PartialTranscript | FinalTranscript;
85
88
  export type RealtimeTranscriptType = "PartialTranscript" | "FinalTranscript";
86
89
 
87
90
  export type SessionBegins = RealtimeBaseMessage & {
88
- /** @description Timestamp when this session will expire. */
91
+ /** @description Timestamp when this session will expire */
89
92
  expires_at: Date;
90
93
  /**
91
- * @description Describes the type of the message.
94
+ * @description Describes the type of the message
92
95
  * @constant
93
96
  */
94
97
  message_type: "SessionBegins";
95
- /** @description Unique identifier for the established session. */
98
+ /** @description Unique identifier for the established session */
96
99
  session_id: string;
97
100
  };
98
101
 
99
102
  export type SessionTerminated = RealtimeBaseMessage & {
100
103
  /**
101
- * @description Describes the type of the message.
104
+ * @description Describes the type of the message
102
105
  * @constant
103
106
  */
104
107
  message_type: "SessionTerminated";
105
108
  };
106
109
 
107
110
  export type TerminateSession = RealtimeBaseMessage & {
108
- /** @description A boolean value to communicate that you wish to end your real-time session forever. */
111
+ /** @description Set to true to end your real-time session forever */
109
112
  terminate_session: boolean;
110
113
  };
111
114
 
@@ -2,7 +2,8 @@ type FileUploadParameters = string | FileUploadData;
2
2
  type FileUploadData =
3
3
  | NodeJS.ReadableStream
4
4
  | ReadableStream
5
- | Buffer
5
+ | Blob
6
+ | BufferSource
6
7
  | ArrayBufferView
7
8
  | ArrayBufferLike
8
9
  | Uint8Array;
@@ -1,6 +1,6 @@
1
- export type * from "./files";
2
- export type * from "./transcripts";
3
- export type * from "./realtime";
4
- export type * from "./services";
5
- export type * from "./asyncapi.generated";
6
- export type * from "./openapi.generated";
1
+ export * from "./files";
2
+ export * from "./transcripts";
3
+ export * from "./realtime";
4
+ export * from "./services";
5
+ export * from "./asyncapi.generated";
6
+ export * from "./openapi.generated";