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
package/dist/index.js CHANGED
@@ -1,26 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var axios = require('axios');
4
3
  var WebSocket = require('ws');
5
- var stream = require('stream');
4
+ var Stream = require('stream');
6
5
  var fs = require('fs');
7
6
 
8
- function createAxiosClient(params) {
9
- const client = axios.create({
10
- baseURL: params.baseUrl,
11
- headers: { Authorization: params.apiKey },
12
- });
13
- client.interceptors.response.use(undefined, throwApiError);
14
- return client;
15
- }
16
- function throwApiError(error) {
17
- var _a, _b;
18
- if (axios.isAxiosError(error) && ((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error)) {
19
- return Promise.reject(new Error(error.response.data.error));
20
- }
21
- return Promise.reject(error);
22
- }
23
-
24
7
  /******************************************************************************
25
8
  Copyright (c) Microsoft Corporation.
26
9
 
@@ -59,36 +42,70 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
59
42
  class BaseService {
60
43
  /**
61
44
  * Create a new service.
62
- * @param params The AxiosInstance to send HTTP requests to the API.
45
+ * @param params The parameters to use for the service.
63
46
  */
64
- constructor(client) {
65
- this.client = client;
47
+ constructor(params) {
48
+ this.params = params;
49
+ }
50
+ fetch(input, init) {
51
+ var _a;
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ init = init !== null && init !== void 0 ? init : {};
54
+ init.headers = (_a = init.headers) !== null && _a !== void 0 ? _a : {};
55
+ init.headers = Object.assign({ Authorization: this.params.apiKey, "Content-Type": "application/json" }, init.headers);
56
+ if (!input.startsWith("http"))
57
+ input = this.params.baseUrl + input;
58
+ const response = yield fetch(input, init);
59
+ if (response.status >= 400) {
60
+ let json;
61
+ const text = yield response.text();
62
+ if (text) {
63
+ try {
64
+ json = JSON.parse(text);
65
+ }
66
+ catch (_b) {
67
+ /* empty */
68
+ }
69
+ if (json === null || json === void 0 ? void 0 : json.error)
70
+ throw new Error(json.error);
71
+ throw new Error(text);
72
+ }
73
+ throw new Error(`HTTP Error: ${response.status} ${response.statusText}`);
74
+ }
75
+ return response;
76
+ });
77
+ }
78
+ fetchJson(input, init) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ const response = yield this.fetch(input, init);
81
+ return response.json();
82
+ });
66
83
  }
67
84
  }
68
85
 
69
86
  class LemurService extends BaseService {
70
87
  summary(params) {
71
- return __awaiter(this, void 0, void 0, function* () {
72
- const { data } = yield this.client.post("/lemur/v3/generate/summary", params);
73
- return data;
88
+ return this.fetchJson("/lemur/v3/generate/summary", {
89
+ method: "POST",
90
+ body: JSON.stringify(params),
74
91
  });
75
92
  }
76
93
  questionAnswer(params) {
77
- return __awaiter(this, void 0, void 0, function* () {
78
- const { data } = yield this.client.post("/lemur/v3/generate/question-answer", params);
79
- return data;
94
+ return this.fetchJson("/lemur/v3/generate/question-answer", {
95
+ method: "POST",
96
+ body: JSON.stringify(params),
80
97
  });
81
98
  }
82
99
  actionItems(params) {
83
- return __awaiter(this, void 0, void 0, function* () {
84
- const { data } = yield this.client.post("/lemur/v3/generate/action-items", params);
85
- return data;
100
+ return this.fetchJson("/lemur/v3/generate/action-items", {
101
+ method: "POST",
102
+ body: JSON.stringify(params),
86
103
  });
87
104
  }
88
105
  task(params) {
89
- return __awaiter(this, void 0, void 0, function* () {
90
- const { data } = yield this.client.post("/lemur/v3/generate/task", params);
91
- return data;
106
+ return this.fetchJson("/lemur/v3/generate/task", {
107
+ method: "POST",
108
+ body: JSON.stringify(params),
92
109
  });
93
110
  }
94
111
  /**
@@ -96,9 +113,8 @@ class LemurService extends BaseService {
96
113
  * @param id ID of the LeMUR request
97
114
  */
98
115
  purgeRequestData(id) {
99
- return __awaiter(this, void 0, void 0, function* () {
100
- const { data } = yield this.client.delete(`/lemur/v3/${id}`);
101
- return data;
116
+ return this.fetchJson(`/lemur/v3/${id}`, {
117
+ method: "DELETE",
102
118
  });
103
119
  }
104
120
  }
@@ -147,12 +163,11 @@ class RealtimeError extends Error {
147
163
  const defaultRealtimeUrl = "wss://api.assemblyai.com/v2/realtime/ws";
148
164
  class RealtimeService {
149
165
  constructor(params) {
150
- var _a, _b, _c;
166
+ var _a, _b;
151
167
  this.listeners = {};
152
168
  this.realtimeUrl = (_a = params.realtimeUrl) !== null && _a !== void 0 ? _a : defaultRealtimeUrl;
153
169
  this.sampleRate = (_b = params.sampleRate) !== null && _b !== void 0 ? _b : 16000;
154
170
  this.wordBoost = params.wordBoost;
155
- this.realtimeUrl = (_c = params.realtimeUrl) !== null && _c !== void 0 ? _c : defaultRealtimeUrl;
156
171
  if ("apiKey" in params)
157
172
  this.apiKey = params.apiKey;
158
173
  if ("token" in params)
@@ -260,13 +275,13 @@ class RealtimeService {
260
275
  this.socket.send(JSON.stringify(payload));
261
276
  }
262
277
  stream() {
263
- const stream$1 = new stream.Writable({
278
+ const stream = new Stream.Writable({
264
279
  write: (chunk, encoding, next) => {
265
280
  this.sendAudio(chunk);
266
281
  next();
267
282
  },
268
283
  });
269
- return stream$1;
284
+ return stream;
270
285
  }
271
286
  close(waitForSessionTermination = true) {
272
287
  return __awaiter(this, void 0, void 0, function* () {
@@ -293,30 +308,33 @@ class RealtimeService {
293
308
  }
294
309
  }
295
310
 
296
- class RealtimeServiceFactory {
297
- constructor(client, params) {
298
- this.client = client;
299
- this.params = params;
311
+ class RealtimeServiceFactory extends BaseService {
312
+ constructor(params) {
313
+ super(params);
314
+ this.rtFactoryParams = params;
300
315
  }
301
316
  createService(params) {
302
317
  if (!params)
303
- params = { apiKey: this.params.apiKey };
318
+ params = { apiKey: this.rtFactoryParams.apiKey };
304
319
  else if (!("token" in params) && !params.apiKey) {
305
- params.apiKey = this.params.apiKey;
320
+ params.apiKey = this.rtFactoryParams.apiKey;
306
321
  }
307
322
  return new RealtimeService(params);
308
323
  }
309
324
  createTemporaryToken(params) {
310
325
  return __awaiter(this, void 0, void 0, function* () {
311
- const response = yield this.client.post("/v2/realtime/token", params);
312
- return response.data.token;
326
+ const data = yield this.fetchJson("/v2/realtime/token", {
327
+ method: "POST",
328
+ body: JSON.stringify(params),
329
+ });
330
+ return data.token;
313
331
  });
314
332
  }
315
333
  }
316
334
 
317
335
  class TranscriptService extends BaseService {
318
- constructor(client, files) {
319
- super(client);
336
+ constructor(params, files) {
337
+ super(params);
320
338
  this.files = files;
321
339
  }
322
340
  /**
@@ -333,16 +351,21 @@ class TranscriptService extends BaseService {
333
351
  const uploadUrl = yield this.files.upload(path);
334
352
  params.audio_url = uploadUrl;
335
353
  }
336
- const res = yield this.client.post("/v2/transcript", params);
354
+ const data = yield this.fetchJson("/v2/transcript", {
355
+ method: "POST",
356
+ body: JSON.stringify(params),
357
+ });
337
358
  if ((_a = options === null || options === void 0 ? void 0 : options.poll) !== null && _a !== void 0 ? _a : true) {
338
- return yield this.poll(res.data.id, options);
359
+ return yield this.waitUntilReady(data.id, options);
339
360
  }
340
- return res.data;
361
+ return data;
341
362
  });
342
363
  }
343
- poll(transcriptId, options) {
344
- var _a;
364
+ waitUntilReady(transcriptId, options) {
365
+ var _a, _b;
345
366
  return __awaiter(this, void 0, void 0, function* () {
367
+ const pollingInterval = (_a = options === null || options === void 0 ? void 0 : options.pollingInterval) !== null && _a !== void 0 ? _a : 3000;
368
+ const pollingTimeout = (_b = options === null || options === void 0 ? void 0 : options.pollingTimeout) !== null && _b !== void 0 ? _b : -1;
346
369
  const startTime = Date.now();
347
370
  // eslint-disable-next-line no-constant-condition
348
371
  while (true) {
@@ -350,12 +373,12 @@ class TranscriptService extends BaseService {
350
373
  if (transcript.status === "completed" || transcript.status === "error") {
351
374
  return transcript;
352
375
  }
353
- else if (Date.now() - startTime <
354
- ((_a = options === null || options === void 0 ? void 0 : options.pollingTimeout) !== null && _a !== void 0 ? _a : 180000)) {
355
- yield new Promise((resolve) => { var _a; return setTimeout(resolve, (_a = options === null || options === void 0 ? void 0 : options.pollingInterval) !== null && _a !== void 0 ? _a : 3000); });
376
+ else if (pollingTimeout > 0 &&
377
+ Date.now() - startTime > pollingTimeout) {
378
+ throw new Error("Polling timeout");
356
379
  }
357
380
  else {
358
- throw new Error("Polling timeout");
381
+ yield new Promise((resolve) => setTimeout(resolve, pollingInterval));
359
382
  }
360
383
  }
361
384
  });
@@ -366,10 +389,7 @@ class TranscriptService extends BaseService {
366
389
  * @returns A promise that resolves to the transcript.
367
390
  */
368
391
  get(id) {
369
- return __awaiter(this, void 0, void 0, function* () {
370
- const res = yield this.client.get(`/v2/transcript/${id}`);
371
- return res.data;
372
- });
392
+ return this.fetchJson(`/v2/transcript/${id}`);
373
393
  }
374
394
  /**
375
395
  * Retrieves a page of transcript listings.
@@ -378,16 +398,19 @@ class TranscriptService extends BaseService {
378
398
  list(parameters) {
379
399
  return __awaiter(this, void 0, void 0, function* () {
380
400
  let url = "/v2/transcript";
381
- let query;
382
401
  if (typeof parameters === "string") {
383
402
  url = parameters;
384
403
  }
385
404
  else if (parameters) {
386
- query = parameters;
405
+ url = `${url}?${new URLSearchParams(Object.keys(parameters).map((key) => {
406
+ var _a;
407
+ return [
408
+ key,
409
+ ((_a = parameters[key]) === null || _a === void 0 ? void 0 : _a.toString()) || "",
410
+ ];
411
+ }))}`;
387
412
  }
388
- const { data } = yield this.client.get(url, {
389
- params: query,
390
- });
413
+ const data = yield this.fetchJson(url);
391
414
  for (const transcriptListItem of data.transcripts) {
392
415
  transcriptListItem.created = new Date(transcriptListItem.created);
393
416
  if (transcriptListItem.completed) {
@@ -403,27 +426,18 @@ class TranscriptService extends BaseService {
403
426
  * @returns A promise that resolves to the transcript.
404
427
  */
405
428
  delete(id) {
406
- return __awaiter(this, void 0, void 0, function* () {
407
- const res = yield this.client.delete(`/v2/transcript/${id}`);
408
- return res.data;
409
- });
429
+ return this.fetchJson(`/v2/transcript/${id}`, { method: "DELETE" });
410
430
  }
411
431
  /**
412
432
  * Search through the transcript for a specific set of keywords.
413
433
  * You can search for individual words, numbers, or phrases containing up to five words or numbers.
414
434
  * @param id The identifier of the transcript.
415
- * @param id Keywords to search for.
435
+ * @param words Keywords to search for.
416
436
  * @return A promise that resolves to the sentences.
417
437
  */
418
438
  wordSearch(id, words) {
419
- return __awaiter(this, void 0, void 0, function* () {
420
- const { data } = yield this.client.get(`/v2/transcript/${id}/word-search`, {
421
- params: {
422
- words: JSON.stringify(words),
423
- },
424
- });
425
- return data;
426
- });
439
+ const params = new URLSearchParams({ words: words.join(",") });
440
+ return this.fetchJson(`/v2/transcript/${id}/word-search?${params.toString()}`);
427
441
  }
428
442
  /**
429
443
  * Retrieve all sentences of a transcript.
@@ -431,10 +445,7 @@ class TranscriptService extends BaseService {
431
445
  * @return A promise that resolves to the sentences.
432
446
  */
433
447
  sentences(id) {
434
- return __awaiter(this, void 0, void 0, function* () {
435
- const { data } = yield this.client.get(`/v2/transcript/${id}/sentences`);
436
- return data;
437
- });
448
+ return this.fetchJson(`/v2/transcript/${id}/sentences`);
438
449
  }
439
450
  /**
440
451
  * Retrieve all paragraphs of a transcript.
@@ -442,21 +453,25 @@ class TranscriptService extends BaseService {
442
453
  * @return A promise that resolves to the paragraphs.
443
454
  */
444
455
  paragraphs(id) {
445
- return __awaiter(this, void 0, void 0, function* () {
446
- const { data } = yield this.client.get(`/v2/transcript/${id}/paragraphs`);
447
- return data;
448
- });
456
+ return this.fetchJson(`/v2/transcript/${id}/paragraphs`);
449
457
  }
450
458
  /**
451
459
  * Retrieve subtitles of a transcript.
452
460
  * @param id The identifier of the transcript.
453
461
  * @param format The format of the subtitles.
462
+ * @param chars_per_caption The maximum number of characters per caption.
454
463
  * @return A promise that resolves to the subtitles text.
455
464
  */
456
- subtitles(id, format = "srt") {
465
+ subtitles(id, format = "srt", chars_per_caption) {
457
466
  return __awaiter(this, void 0, void 0, function* () {
458
- const { data } = yield this.client.get(`/v2/transcript/${id}/${format}`);
459
- return data;
467
+ let url = `/v2/transcript/${id}/${format}`;
468
+ if (chars_per_caption) {
469
+ const params = new URLSearchParams();
470
+ params.set("chars_per_caption", chars_per_caption.toString());
471
+ url += `?${params.toString()}`;
472
+ }
473
+ const response = yield this.fetch(url);
474
+ return yield response.text();
460
475
  });
461
476
  }
462
477
  /**
@@ -465,10 +480,7 @@ class TranscriptService extends BaseService {
465
480
  * @return A promise that resolves to the subtitles text.
466
481
  */
467
482
  redactions(id) {
468
- return __awaiter(this, void 0, void 0, function* () {
469
- const { data } = yield this.client.get(`/v2/transcript/${id}/redacted-audio`);
470
- return data;
471
- });
483
+ return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
472
484
  }
473
485
  }
474
486
  function getPath(path) {
@@ -498,28 +510,33 @@ class FileService extends BaseService {
498
510
  fileData = fs.createReadStream(input);
499
511
  else
500
512
  fileData = input;
501
- const { data } = yield this.client.post("/v2/upload", fileData, {
513
+ const data = yield this.fetchJson("/v2/upload", {
514
+ method: "POST",
515
+ body: fileData,
502
516
  headers: {
503
517
  "Content-Type": "application/octet-stream",
504
518
  },
519
+ duplex: "half",
505
520
  });
506
521
  return data.upload_url;
507
522
  });
508
523
  }
509
524
  }
510
525
 
526
+ const defaultBaseUrl = "https://api.assemblyai.com";
511
527
  class AssemblyAI {
512
528
  /**
513
529
  * Create a new AssemblyAI client.
514
530
  * @param params The parameters for the service, including the API key and base URL, if any.
515
531
  */
516
532
  constructor(params) {
517
- params.baseUrl = params.baseUrl || "https://api.assemblyai.com";
518
- const client = createAxiosClient(params);
519
- this.files = new FileService(client);
520
- this.transcripts = new TranscriptService(client, this.files);
521
- this.lemur = new LemurService(client);
522
- this.realtime = new RealtimeServiceFactory(client, params);
533
+ params.baseUrl = params.baseUrl || defaultBaseUrl;
534
+ if (params.baseUrl && params.baseUrl.endsWith("/"))
535
+ params.baseUrl = params.baseUrl.slice(0, -1);
536
+ this.files = new FileService(params);
537
+ this.transcripts = new TranscriptService(params, this.files);
538
+ this.lemur = new LemurService(params);
539
+ this.realtime = new RealtimeServiceFactory(params);
523
540
  }
524
541
  }
525
542
 
@@ -1,12 +1,14 @@
1
- import { AxiosInstance } from "axios";
1
+ import { BaseServiceParams } from "..";
2
2
  /**
3
3
  * Base class for services that communicate with the API.
4
4
  */
5
5
  export declare abstract class BaseService {
6
- protected client: AxiosInstance;
6
+ private params;
7
7
  /**
8
8
  * Create a new service.
9
- * @param params The AxiosInstance to send HTTP requests to the API.
9
+ * @param params The parameters to use for the service.
10
10
  */
11
- constructor(client: AxiosInstance);
11
+ constructor(params: BaseServiceParams);
12
+ protected fetch(input: string, init?: RequestInit | undefined): Promise<Response>;
13
+ protected fetchJson<T>(input: string, init?: RequestInit | undefined): Promise<T>;
12
14
  }
@@ -1,5 +1,5 @@
1
- import { BaseService } from "@/services/base";
2
- import { FileUploadParameters } from "@/types";
1
+ import { BaseService } from "../base";
2
+ import { FileUploadParameters } from "../..";
3
3
  export declare class FileService extends BaseService {
4
4
  /**
5
5
  * Upload a local file to AssemblyAI.
@@ -1,4 +1,4 @@
1
- import { BaseServiceParams } from "@/types";
1
+ import { BaseServiceParams } from "..";
2
2
  import { LemurService } from "./lemur";
3
3
  import { RealtimeService, RealtimeServiceFactory } from "./realtime";
4
4
  import { TranscriptService } from "./transcripts";
@@ -1,5 +1,5 @@
1
- import { LemurSummaryParameters, LemurActionItemsParameters, LemurQuestionAnswerParameters, LemurTaskParameters, LemurSummaryResponse, LemurQuestionAnswerResponse, LemurActionItemsResponse, LemurTaskResponse, PurgeLemurRequestDataResponse } from "@/types";
2
- import { BaseService } from "@/services/base";
1
+ import { LemurSummaryParameters, LemurActionItemsParameters, LemurQuestionAnswerParameters, LemurTaskParameters, LemurSummaryResponse, LemurQuestionAnswerResponse, LemurActionItemsResponse, LemurTaskResponse, PurgeLemurRequestDataResponse } from "../..";
2
+ import { BaseService } from "../base";
3
3
  export declare class LemurService extends BaseService {
4
4
  summary(params: LemurSummaryParameters): Promise<LemurSummaryResponse>;
5
5
  questionAnswer(params: LemurQuestionAnswerParameters): Promise<LemurQuestionAnswerResponse>;
@@ -1,10 +1,9 @@
1
- import { BaseServiceParams, RealtimeTokenParams, CreateRealtimeServiceParams } from "@/types";
2
- import { AxiosInstance } from "axios";
1
+ import { BaseServiceParams, RealtimeTokenParams, CreateRealtimeServiceParams } from "../..";
3
2
  import { RealtimeService } from "./service";
4
- export declare class RealtimeServiceFactory {
5
- private client;
6
- private params;
7
- constructor(client: AxiosInstance, params: BaseServiceParams);
3
+ import { BaseService } from "../base";
4
+ export declare class RealtimeServiceFactory extends BaseService {
5
+ private rtFactoryParams;
6
+ constructor(params: BaseServiceParams);
8
7
  createService(params?: CreateRealtimeServiceParams): RealtimeService;
9
8
  createTemporaryToken(params: RealtimeTokenParams): Promise<string>;
10
9
  }
@@ -1,2 +1,2 @@
1
- export * from "@/services/realtime/factory";
2
- export * from "@/services/realtime/service";
1
+ export * from "./factory";
2
+ export * from "./service";
@@ -1,6 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { RealtimeServiceParams, RealtimeTranscript, PartialTranscript, FinalTranscript, SessionBeginsEventData } from "@/types";
3
- import { Writable } from "stream";
2
+ import { RealtimeServiceParams, RealtimeTranscript, PartialTranscript, FinalTranscript, SessionBeginsEventData } from "../..";
4
3
  export declare class RealtimeService {
5
4
  private realtimeUrl;
6
5
  private sampleRate;
@@ -20,6 +19,6 @@ export declare class RealtimeService {
20
19
  on(event: "close", listener: (code: number, reason: string) => void): void;
21
20
  connect(): Promise<SessionBeginsEventData>;
22
21
  sendAudio(audio: ArrayBuffer): void;
23
- stream(): Writable;
22
+ stream(): NodeJS.WritableStream;
24
23
  close(waitForSessionTermination?: boolean): Promise<void>;
25
24
  }
@@ -1,10 +1,9 @@
1
- import { BaseService } from "@/services/base";
2
- import { ParagraphsResponse, SentencesResponse, Transcript, TranscriptList, CreateTranscriptParameters, CreateTranscriptOptions, Createable, Deletable, Listable, Retrieveable, SubtitleFormat, RedactedAudioResponse, TranscriptListParameters, WordSearchResponse } from "@/types";
3
- import { AxiosInstance } from "axios";
1
+ import { BaseService } from "../base";
2
+ import { ParagraphsResponse, SentencesResponse, Transcript, TranscriptList, CreateTranscriptParameters, CreateTranscriptOptions, Createable, Deletable, Listable, Retrieveable, SubtitleFormat, RedactedAudioResponse, TranscriptListParameters, WordSearchResponse, BaseServiceParams, PollingOptions } from "../..";
4
3
  import { FileService } from "../files";
5
4
  export declare class TranscriptService extends BaseService implements Createable<Transcript, CreateTranscriptParameters, CreateTranscriptOptions>, Retrieveable<Transcript>, Deletable<Transcript>, Listable<TranscriptList> {
6
5
  private files;
7
- constructor(client: AxiosInstance, files: FileService);
6
+ constructor(params: BaseServiceParams, files: FileService);
8
7
  /**
9
8
  * Create a transcript.
10
9
  * @param params The parameters to create a transcript.
@@ -12,7 +11,7 @@ export declare class TranscriptService extends BaseService implements Createable
12
11
  * @returns A promise that resolves to the newly created transcript.
13
12
  */
14
13
  create(params: CreateTranscriptParameters, options?: CreateTranscriptOptions): Promise<Transcript>;
15
- private poll;
14
+ waitUntilReady(transcriptId: string, options?: PollingOptions): Promise<Transcript>;
16
15
  /**
17
16
  * Retrieve a transcript.
18
17
  * @param id The identifier of the transcript.
@@ -34,7 +33,7 @@ export declare class TranscriptService extends BaseService implements Createable
34
33
  * Search through the transcript for a specific set of keywords.
35
34
  * You can search for individual words, numbers, or phrases containing up to five words or numbers.
36
35
  * @param id The identifier of the transcript.
37
- * @param id Keywords to search for.
36
+ * @param words Keywords to search for.
38
37
  * @return A promise that resolves to the sentences.
39
38
  */
40
39
  wordSearch(id: string, words: string[]): Promise<WordSearchResponse>;
@@ -54,9 +53,10 @@ export declare class TranscriptService extends BaseService implements Createable
54
53
  * Retrieve subtitles of a transcript.
55
54
  * @param id The identifier of the transcript.
56
55
  * @param format The format of the subtitles.
56
+ * @param chars_per_caption The maximum number of characters per caption.
57
57
  * @return A promise that resolves to the subtitles text.
58
58
  */
59
- subtitles(id: string, format?: SubtitleFormat): Promise<string>;
59
+ subtitles(id: string, format?: SubtitleFormat, chars_per_caption?: number): Promise<string>;
60
60
  /**
61
61
  * Retrieve redactions of a transcript.
62
62
  * @param id The identifier of the transcript.
@@ -1,46 +1,49 @@
1
1
  export type AudioData = {
2
- /** @description Raw audio data, base64 encoded. This can be the raw data recorded directly from a microphone or read from an audio file. */
2
+ /** @description Base64 encoded raw audio data */
3
3
  audio_data: string;
4
4
  };
5
5
  export type FinalTranscript = RealtimeBaseTranscript & {
6
6
  /**
7
- * @description Describes the type of message.
7
+ * @description Describes the type of message
8
8
  * @constant
9
9
  */
10
10
  message_type: "FinalTranscript";
11
- /** @description Whether the text has been punctuated and cased. */
11
+ /** @description Whether the text is punctuated and cased */
12
12
  punctuated: boolean;
13
- /** @description Whether the text has been formatted (e.g. Dollar -> $) */
13
+ /** @description Whether the text is formatted, for example Dollar -> $ */
14
14
  text_formatted: boolean;
15
15
  };
16
16
  /** @enum {string} */
17
17
  export type MessageType = "SessionBegins" | "PartialTranscript" | "FinalTranscript" | "SessionTerminated";
18
18
  export type PartialTranscript = RealtimeBaseTranscript & {
19
19
  /**
20
- * @description Describes the type of message.
20
+ * @description Describes the type of message
21
21
  * @constant
22
22
  */
23
23
  message_type: "PartialTranscript";
24
24
  };
25
25
  export type RealtimeBaseMessage = {
26
- /** @description Describes the type of the message. */
26
+ /** @description Describes the type of the message */
27
27
  message_type: MessageType;
28
28
  };
29
29
  export type RealtimeBaseTranscript = {
30
- /** @description End time of audio sample relative to session start, in milliseconds. */
30
+ /** @description End time of audio sample relative to session start, in milliseconds */
31
31
  audio_end: number;
32
- /** @description Start time of audio sample relative to session start, in milliseconds. */
32
+ /** @description Start time of audio sample relative to session start, in milliseconds */
33
33
  audio_start: number;
34
34
  /**
35
35
  * Format: double
36
- * @description The confidence score of the entire transcription, between 0 and 1.
36
+ * @description The confidence score of the entire transcription, between 0 and 1
37
37
  */
38
38
  confidence: number;
39
- /** @description The timestamp for the partial transcript. */
39
+ /** @description The timestamp for the partial transcript */
40
40
  created: Date;
41
- /** @description The partial transcript for your audio. */
41
+ /** @description The partial transcript for your audio */
42
42
  text: string;
43
- /** @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). */
43
+ /**
44
+ * @description An array of objects, with the information for each word in the transcription text.
45
+ * 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.
46
+ */
44
47
  words: Word[];
45
48
  };
46
49
  export type RealtimeError = {
@@ -51,25 +54,25 @@ export type RealtimeTranscript = PartialTranscript | FinalTranscript;
51
54
  /** @enum {string} */
52
55
  export type RealtimeTranscriptType = "PartialTranscript" | "FinalTranscript";
53
56
  export type SessionBegins = RealtimeBaseMessage & {
54
- /** @description Timestamp when this session will expire. */
57
+ /** @description Timestamp when this session will expire */
55
58
  expires_at: Date;
56
59
  /**
57
- * @description Describes the type of the message.
60
+ * @description Describes the type of the message
58
61
  * @constant
59
62
  */
60
63
  message_type: "SessionBegins";
61
- /** @description Unique identifier for the established session. */
64
+ /** @description Unique identifier for the established session */
62
65
  session_id: string;
63
66
  };
64
67
  export type SessionTerminated = RealtimeBaseMessage & {
65
68
  /**
66
- * @description Describes the type of the message.
69
+ * @description Describes the type of the message
67
70
  * @constant
68
71
  */
69
72
  message_type: "SessionTerminated";
70
73
  };
71
74
  export type TerminateSession = RealtimeBaseMessage & {
72
- /** @description A boolean value to communicate that you wish to end your real-time session forever. */
75
+ /** @description Set to true to end your real-time session forever */
73
76
  terminate_session: boolean;
74
77
  };
75
78
  export type Word = {
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  type FileUploadParameters = string | FileUploadData;
4
- type FileUploadData = NodeJS.ReadableStream | ReadableStream | Buffer | ArrayBufferView | ArrayBufferLike | Uint8Array;
3
+ type FileUploadData = NodeJS.ReadableStream | ReadableStream | Blob | BufferSource | ArrayBufferView | ArrayBufferLike | Uint8Array;
5
4
  export type { FileUploadParameters, FileUploadData };
@@ -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";