assemblyai 3.0.1 → 3.1.1

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/README.md CHANGED
@@ -4,11 +4,11 @@
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/assemblyai)](https://www.npmjs.com/package/assemblyai)
6
6
  [![Test](https://github.com/AssemblyAI/assemblyai-node-sdk/actions/workflows/test.yml/badge.svg)](https://github.com/AssemblyAI/assemblyai-node-sdk/actions/workflows/test.yml)
7
- [![GitHub License](https://img.shields.io/github/license/AssemblyAI/assemblyai-node-sdk)](https://github.com/AssemblyAI/assemblyai-node-sdk/blob/master/LICENSE)
7
+ [![GitHub License](https://img.shields.io/github/license/AssemblyAI/assemblyai-node-sdk)](https://github.com/AssemblyAI/assemblyai-node-sdk/blob/main/LICENSE)
8
8
  [![AssemblyAI Twitter](https://img.shields.io/twitter/follow/AssemblyAI?label=%40AssemblyAI&style=social)](https://twitter.com/AssemblyAI)
9
9
  [![AssemblyAI YouTube](https://img.shields.io/youtube/channel/subscribers/UCtatfZMf-8EkIwASXM4ts0A)](https://www.youtube.com/@AssemblyAI)
10
10
  [![Discord](https://img.shields.io/discord/875120158014853141?logo=discord&label=Discord&link=https%3A%2F%2Fdiscord.com%2Fchannels%2F875120158014853141&style=social)
11
- ](https://discord.gg/5aQNZyq3)
11
+ ](https://assemblyai.com/discord)
12
12
 
13
13
  # AssemblyAI Node.js SDK
14
14
 
@@ -44,7 +44,7 @@ import { AssemblyAI } from "assemblyai";
44
44
 
45
45
  const client = new AssemblyAI({
46
46
  apiKey: process.env.ASSEMBLYAI_API_KEY,
47
- })
47
+ });
48
48
  ```
49
49
 
50
50
  You can now use the `client` object to interact with the AssemblyAI API.
@@ -54,34 +54,43 @@ You can now use the `client` object to interact with the AssemblyAI API.
54
54
  When you create a transcript, you can either pass in a URL to an audio file, or upload a file directly.
55
55
 
56
56
  ```javascript
57
- // Using a remote URL
58
- const transcript = await client.transcripts.create({
59
- audio_url: 'https://storage.googleapis.com/aai-web-samples/espn-bears.m4a',
60
- })
57
+ // Transcribe file at remote URL
58
+ let transcript = await client.transcripts.transcribe({
59
+ audio: "https://storage.googleapis.com/aai-web-samples/espn-bears.m4a",
60
+ });
61
+
62
+ // Upload a file via local path and transcribe
63
+ let transcript = await client.transcripts.transcribe({
64
+ audio: "./news.mp4",
65
+ });
61
66
  ```
62
67
 
68
+ > **Note**
69
+ > You can also pass streams and buffers to the `audio` property.
70
+
71
+ `transcribe` queues a transcription job and polls it until the `status` is `completed` or `error`.
72
+ You can configure the polling interval and polling timeout using these options:
73
+
63
74
  ```javascript
64
- // Uploading a file
65
- const transcript = await client.transcripts.create({
66
- audio_url: './news.mp4',
67
- })
75
+ let transcript = await client.transcripts.transcribe(
76
+ {
77
+ audio: "https://storage.googleapis.com/aai-web-samples/espn-bears.m4a",
78
+ },
79
+ {
80
+ // How frequently the transcript is polled in ms. Defaults to 3000.
81
+ pollingInterval: 1000,
82
+ // How long to wait in ms until the "Polling timeout" error is thrown. Defaults to infinite (-1).
83
+ pollingTimeout: 5000,
84
+ }
85
+ );
68
86
  ```
69
87
 
70
- By default, when you create a transcript, it'll be polled until the status is `completed` or `error`.
71
- You can configure whether to poll, the polling interval, and polling timeout using these options:
88
+ If you don't want to wait until the transcript is ready, you can use `submit`:
72
89
 
73
90
  ```javascript
74
- const transcript = await client.transcripts.create({
75
- audio_url: 'https://storage.googleapis.com/aai-web-samples/espn-bears.m4a',
76
- },
77
- {
78
- // Enable or disable polling. Defaults to true.
79
- poll: true,
80
- // How frequently the transcript is polled in ms. Defaults to 3000.
81
- pollingInterval: 1000,
82
- // How long to wait in ms until the "Polling timeout" error is thrown. Defaults to 180000.
83
- pollingTimeout: 5000,
84
- })
91
+ let transcript = await client.transcripts.submit({
92
+ audio: "https://storage.googleapis.com/aai-web-samples/espn-bears.m4a",
93
+ });
85
94
  ```
86
95
 
87
96
  ## Get a transcript
@@ -89,15 +98,26 @@ const transcript = await client.transcripts.create({
89
98
  This will return the transcript object in its current state. If the transcript is still processing, the `status` field will be `queued` or `processing`. Once the transcript is complete, the `status` field will be `completed`.
90
99
 
91
100
  ```javascript
92
- const transcript = await client.transcripts.get(transcript.id)
101
+ const transcript = await client.transcripts.get(transcript.id);
102
+ ```
103
+
104
+ If you created a transcript using `submit`, you can still poll until the transcript `status` is `completed` or `error` using `waitUntilReady`:
105
+
106
+ ```javascript
107
+ const transcript = await client.transcripts.waitUntilReady(transcript.id, {
108
+ // How frequently the transcript is polled in ms. Defaults to 3000.
109
+ pollingInterval: 1000,
110
+ // How long to wait in ms until the "Polling timeout" error is thrown. Defaults to infinite (-1).
111
+ pollingTimeout: 5000,
112
+ });
93
113
  ```
94
114
 
95
115
  ## List transcripts
96
116
 
97
- This will return a page of transcripts that you have transcript.
117
+ This will return a page of transcripts you created.
98
118
 
99
119
  ```javascript
100
- const page = await client.transcripts.list()
120
+ const page = await client.transcripts.list();
101
121
  ```
102
122
 
103
123
  You can also paginate over all pages.
@@ -105,15 +125,15 @@ You can also paginate over all pages.
105
125
  ```typescript
106
126
  let nextPageUrl: string | null = null;
107
127
  do {
108
- const page = await client.transcripts.list(nextPageUrl)
109
- nextPageUrl = page.page_details.next_url
110
- } while(nextPageUrl !== null)
128
+ const page = await client.transcripts.list(nextPageUrl);
129
+ nextPageUrl = page.page_details.next_url;
130
+ } while (nextPageUrl !== null);
111
131
  ```
112
132
 
113
133
  ## Delete a transcript
114
134
 
115
135
  ```javascript
116
- const res = await client.transcripts.delete(transcript.id)
136
+ const res = await client.transcripts.delete(transcript.id);
117
137
  ```
118
138
 
119
139
  ## Use LeMUR
@@ -121,42 +141,46 @@ const res = await client.transcripts.delete(transcript.id)
121
141
  Call [LeMUR endpoints](https://www.assemblyai.com/docs/API%20reference/lemur) to summarize, ask questions, generate action items, or run a custom task.
122
142
 
123
143
  Custom Summary:
144
+
124
145
  ```javascript
125
146
  const { response } = await client.lemur.summary({
126
- transcript_ids: ['0d295578-8c75-421a-885a-2c487f188927'],
127
- answer_format: 'one sentence',
147
+ transcript_ids: ["0d295578-8c75-421a-885a-2c487f188927"],
148
+ answer_format: "one sentence",
128
149
  context: {
129
- speakers: ['Alex', 'Bob'],
130
- }
131
- })
150
+ speakers: ["Alex", "Bob"],
151
+ },
152
+ });
132
153
  ```
133
154
 
134
155
  Question & Answer:
156
+
135
157
  ```javascript
136
158
  const { response } = await client.lemur.questionAnswer({
137
- transcript_ids: ['0d295578-8c75-421a-885a-2c487f188927'],
159
+ transcript_ids: ["0d295578-8c75-421a-885a-2c487f188927"],
138
160
  questions: [
139
161
  {
140
- question: 'What are they discussing?',
141
- answer_format: 'text',
142
- }
143
- ]
144
- })
162
+ question: "What are they discussing?",
163
+ answer_format: "text",
164
+ },
165
+ ],
166
+ });
145
167
  ```
146
168
 
147
169
  Action Items:
170
+
148
171
  ```javascript
149
172
  const { response } = await client.lemur.actionItems({
150
- transcript_ids: ['0d295578-8c75-421a-885a-2c487f188927'],
151
- })
173
+ transcript_ids: ["0d295578-8c75-421a-885a-2c487f188927"],
174
+ });
152
175
  ```
153
176
 
154
177
  Custom Task:
178
+
155
179
  ```javascript
156
180
  const { response } = await client.lemur.task({
157
- transcript_ids: ['0d295578-8c75-421a-885a-2c487f188927'],
158
- prompt: 'Write a haiku about this conversation.',
159
- })
181
+ transcript_ids: ["0d295578-8c75-421a-885a-2c487f188927"],
182
+ prompt: "Write a haiku about this conversation.",
183
+ });
160
184
  ```
161
185
 
162
186
  ## Transcribe in real time
@@ -183,7 +207,7 @@ You can also generate a temporary auth token for real-time.
183
207
  ```typescript
184
208
  const token = await client.realtime.createTemporaryToken({ expires_in = 60 });
185
209
  const rt = client.realtime.createService({
186
- token: token
210
+ token: token,
187
211
  });
188
212
  ```
189
213
 
@@ -193,6 +217,7 @@ const rt = client.realtime.createService({
193
217
 
194
218
  You can configure the following events.
195
219
 
220
+ <!-- prettier-ignore -->
196
221
  ```typescript
197
222
  rt.on("open", ({ sessionId, expiresAt }) => console.log('Session ID:', sessionId, 'Expires at:', expiresAt));
198
223
  rt.on("close", (code: number, reason: string) => console.log('Closed', code, reason));
@@ -216,6 +241,7 @@ getAudio((chunk) => {
216
241
  rt.sendAudio(chunk);
217
242
  });
218
243
  ```
244
+
219
245
  Or send audio data via a stream by piping to the realtime stream.
220
246
 
221
247
  ```typescript
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export type * from "./types";
1
+ export * from "./types";
2
2
  export * from "./services";
package/dist/index.esm.js CHANGED
@@ -19,6 +19,18 @@ PERFORMANCE OF THIS SOFTWARE.
19
19
  /* global Reflect, Promise, SuppressedError, Symbol */
20
20
 
21
21
 
22
+ function __rest(s, e) {
23
+ var t = {};
24
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
25
+ t[p] = s[p];
26
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
27
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
28
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
29
+ t[p[i]] = s[p[i]];
30
+ }
31
+ return t;
32
+ }
33
+
22
34
  function __awaiter(thisArg, _arguments, P, generator) {
23
35
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
24
36
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -335,11 +347,55 @@ class TranscriptService extends BaseService {
335
347
  super(params);
336
348
  this.files = files;
337
349
  }
350
+ /**
351
+ * Transcribe an audio file. This will create a transcript and wait until the transcript status is "completed" or "error".
352
+ * @param params The parameters to transcribe an audio file.
353
+ * @param options The options to transcribe an audio file.
354
+ * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
355
+ */
356
+ transcribe(params, options) {
357
+ return __awaiter(this, void 0, void 0, function* () {
358
+ const transcript = yield this.submit(params);
359
+ return yield this.waitUntilReady(transcript.id, options);
360
+ });
361
+ }
362
+ /**
363
+ * Submits a transcription job for an audio file. This will not wait until the transcript status is "completed" or "error".
364
+ * @param params The parameters to start the transcription of an audio file.
365
+ * @returns A promise that resolves to the queued transcript.
366
+ */
367
+ submit(params) {
368
+ return __awaiter(this, void 0, void 0, function* () {
369
+ const { audio } = params, createParams = __rest(params, ["audio"]);
370
+ let audioUrl;
371
+ if (typeof audio === "string") {
372
+ const path = getPath(audio);
373
+ if (path !== null) {
374
+ // audio is local path, upload local file
375
+ audioUrl = yield this.files.upload(path);
376
+ }
377
+ else {
378
+ // audio is not a local path, assume it's a URL
379
+ audioUrl = audio;
380
+ }
381
+ }
382
+ else {
383
+ // audio is of uploadable type
384
+ audioUrl = yield this.files.upload(audio);
385
+ }
386
+ const data = yield this.fetchJson("/v2/transcript", {
387
+ method: "POST",
388
+ body: JSON.stringify(Object.assign(Object.assign({}, createParams), { audio_url: audioUrl })),
389
+ });
390
+ return data;
391
+ });
392
+ }
338
393
  /**
339
394
  * Create a transcript.
340
395
  * @param params The parameters to create a transcript.
341
396
  * @param options The options used for creating the new transcript.
342
- * @returns A promise that resolves to the newly created transcript.
397
+ * @returns A promise that resolves to the transcript.
398
+ * @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
343
399
  */
344
400
  create(params, options) {
345
401
  var _a;
@@ -354,14 +410,22 @@ class TranscriptService extends BaseService {
354
410
  body: JSON.stringify(params),
355
411
  });
356
412
  if ((_a = options === null || options === void 0 ? void 0 : options.poll) !== null && _a !== void 0 ? _a : true) {
357
- return yield this.poll(data.id, options);
413
+ return yield this.waitUntilReady(data.id, options);
358
414
  }
359
415
  return data;
360
416
  });
361
417
  }
362
- poll(transcriptId, options) {
363
- var _a;
418
+ /**
419
+ * Wait until the transcript ready, either the status is "completed" or "error".
420
+ * @param transcriptId The ID of the transcript.
421
+ * @param options The options to wait until the transcript is ready.
422
+ * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
423
+ */
424
+ waitUntilReady(transcriptId, options) {
425
+ var _a, _b;
364
426
  return __awaiter(this, void 0, void 0, function* () {
427
+ const pollingInterval = (_a = options === null || options === void 0 ? void 0 : options.pollingInterval) !== null && _a !== void 0 ? _a : 3000;
428
+ const pollingTimeout = (_b = options === null || options === void 0 ? void 0 : options.pollingTimeout) !== null && _b !== void 0 ? _b : -1;
365
429
  const startTime = Date.now();
366
430
  // eslint-disable-next-line no-constant-condition
367
431
  while (true) {
@@ -369,12 +433,12 @@ class TranscriptService extends BaseService {
369
433
  if (transcript.status === "completed" || transcript.status === "error") {
370
434
  return transcript;
371
435
  }
372
- else if (Date.now() - startTime <
373
- ((_a = options === null || options === void 0 ? void 0 : options.pollingTimeout) !== null && _a !== void 0 ? _a : 180000)) {
374
- 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); });
436
+ else if (pollingTimeout > 0 &&
437
+ Date.now() - startTime > pollingTimeout) {
438
+ throw new Error("Polling timeout");
375
439
  }
376
440
  else {
377
- throw new Error("Polling timeout");
441
+ yield new Promise((resolve) => setTimeout(resolve, pollingInterval));
378
442
  }
379
443
  }
380
444
  });
@@ -432,7 +496,8 @@ class TranscriptService extends BaseService {
432
496
  * @return A promise that resolves to the sentences.
433
497
  */
434
498
  wordSearch(id, words) {
435
- return this.fetchJson(`/v2/transcript/${id}/word-search?words=${JSON.stringify(words)}`);
499
+ const params = new URLSearchParams({ words: words.join(",") });
500
+ return this.fetchJson(`/v2/transcript/${id}/word-search?${params.toString()}`);
436
501
  }
437
502
  /**
438
503
  * Retrieve all sentences of a transcript.
@@ -454,11 +519,18 @@ class TranscriptService extends BaseService {
454
519
  * Retrieve subtitles of a transcript.
455
520
  * @param id The identifier of the transcript.
456
521
  * @param format The format of the subtitles.
522
+ * @param chars_per_caption The maximum number of characters per caption.
457
523
  * @return A promise that resolves to the subtitles text.
458
524
  */
459
- subtitles(id, format = "srt") {
525
+ subtitles(id, format = "srt", chars_per_caption) {
460
526
  return __awaiter(this, void 0, void 0, function* () {
461
- const response = yield this.fetch(`/v2/transcript/${id}/${format}`);
527
+ let url = `/v2/transcript/${id}/${format}`;
528
+ if (chars_per_caption) {
529
+ const params = new URLSearchParams();
530
+ params.set("chars_per_caption", chars_per_caption.toString());
531
+ url += `?${params.toString()}`;
532
+ }
533
+ const response = yield this.fetch(url);
462
534
  return yield response.text();
463
535
  });
464
536
  }
package/dist/index.js CHANGED
@@ -21,6 +21,18 @@ PERFORMANCE OF THIS SOFTWARE.
21
21
  /* global Reflect, Promise, SuppressedError, Symbol */
22
22
 
23
23
 
24
+ function __rest(s, e) {
25
+ var t = {};
26
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
27
+ t[p] = s[p];
28
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
29
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
30
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
31
+ t[p[i]] = s[p[i]];
32
+ }
33
+ return t;
34
+ }
35
+
24
36
  function __awaiter(thisArg, _arguments, P, generator) {
25
37
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
26
38
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -337,11 +349,55 @@ class TranscriptService extends BaseService {
337
349
  super(params);
338
350
  this.files = files;
339
351
  }
352
+ /**
353
+ * Transcribe an audio file. This will create a transcript and wait until the transcript status is "completed" or "error".
354
+ * @param params The parameters to transcribe an audio file.
355
+ * @param options The options to transcribe an audio file.
356
+ * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
357
+ */
358
+ transcribe(params, options) {
359
+ return __awaiter(this, void 0, void 0, function* () {
360
+ const transcript = yield this.submit(params);
361
+ return yield this.waitUntilReady(transcript.id, options);
362
+ });
363
+ }
364
+ /**
365
+ * Submits a transcription job for an audio file. This will not wait until the transcript status is "completed" or "error".
366
+ * @param params The parameters to start the transcription of an audio file.
367
+ * @returns A promise that resolves to the queued transcript.
368
+ */
369
+ submit(params) {
370
+ return __awaiter(this, void 0, void 0, function* () {
371
+ const { audio } = params, createParams = __rest(params, ["audio"]);
372
+ let audioUrl;
373
+ if (typeof audio === "string") {
374
+ const path = getPath(audio);
375
+ if (path !== null) {
376
+ // audio is local path, upload local file
377
+ audioUrl = yield this.files.upload(path);
378
+ }
379
+ else {
380
+ // audio is not a local path, assume it's a URL
381
+ audioUrl = audio;
382
+ }
383
+ }
384
+ else {
385
+ // audio is of uploadable type
386
+ audioUrl = yield this.files.upload(audio);
387
+ }
388
+ const data = yield this.fetchJson("/v2/transcript", {
389
+ method: "POST",
390
+ body: JSON.stringify(Object.assign(Object.assign({}, createParams), { audio_url: audioUrl })),
391
+ });
392
+ return data;
393
+ });
394
+ }
340
395
  /**
341
396
  * Create a transcript.
342
397
  * @param params The parameters to create a transcript.
343
398
  * @param options The options used for creating the new transcript.
344
- * @returns A promise that resolves to the newly created transcript.
399
+ * @returns A promise that resolves to the transcript.
400
+ * @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
345
401
  */
346
402
  create(params, options) {
347
403
  var _a;
@@ -356,14 +412,22 @@ class TranscriptService extends BaseService {
356
412
  body: JSON.stringify(params),
357
413
  });
358
414
  if ((_a = options === null || options === void 0 ? void 0 : options.poll) !== null && _a !== void 0 ? _a : true) {
359
- return yield this.poll(data.id, options);
415
+ return yield this.waitUntilReady(data.id, options);
360
416
  }
361
417
  return data;
362
418
  });
363
419
  }
364
- poll(transcriptId, options) {
365
- var _a;
420
+ /**
421
+ * Wait until the transcript ready, either the status is "completed" or "error".
422
+ * @param transcriptId The ID of the transcript.
423
+ * @param options The options to wait until the transcript is ready.
424
+ * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
425
+ */
426
+ waitUntilReady(transcriptId, options) {
427
+ var _a, _b;
366
428
  return __awaiter(this, void 0, void 0, function* () {
429
+ const pollingInterval = (_a = options === null || options === void 0 ? void 0 : options.pollingInterval) !== null && _a !== void 0 ? _a : 3000;
430
+ const pollingTimeout = (_b = options === null || options === void 0 ? void 0 : options.pollingTimeout) !== null && _b !== void 0 ? _b : -1;
367
431
  const startTime = Date.now();
368
432
  // eslint-disable-next-line no-constant-condition
369
433
  while (true) {
@@ -371,12 +435,12 @@ class TranscriptService extends BaseService {
371
435
  if (transcript.status === "completed" || transcript.status === "error") {
372
436
  return transcript;
373
437
  }
374
- else if (Date.now() - startTime <
375
- ((_a = options === null || options === void 0 ? void 0 : options.pollingTimeout) !== null && _a !== void 0 ? _a : 180000)) {
376
- 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); });
438
+ else if (pollingTimeout > 0 &&
439
+ Date.now() - startTime > pollingTimeout) {
440
+ throw new Error("Polling timeout");
377
441
  }
378
442
  else {
379
- throw new Error("Polling timeout");
443
+ yield new Promise((resolve) => setTimeout(resolve, pollingInterval));
380
444
  }
381
445
  }
382
446
  });
@@ -434,7 +498,8 @@ class TranscriptService extends BaseService {
434
498
  * @return A promise that resolves to the sentences.
435
499
  */
436
500
  wordSearch(id, words) {
437
- return this.fetchJson(`/v2/transcript/${id}/word-search?words=${JSON.stringify(words)}`);
501
+ const params = new URLSearchParams({ words: words.join(",") });
502
+ return this.fetchJson(`/v2/transcript/${id}/word-search?${params.toString()}`);
438
503
  }
439
504
  /**
440
505
  * Retrieve all sentences of a transcript.
@@ -456,11 +521,18 @@ class TranscriptService extends BaseService {
456
521
  * Retrieve subtitles of a transcript.
457
522
  * @param id The identifier of the transcript.
458
523
  * @param format The format of the subtitles.
524
+ * @param chars_per_caption The maximum number of characters per caption.
459
525
  * @return A promise that resolves to the subtitles text.
460
526
  */
461
- subtitles(id, format = "srt") {
527
+ subtitles(id, format = "srt", chars_per_caption) {
462
528
  return __awaiter(this, void 0, void 0, function* () {
463
- const response = yield this.fetch(`/v2/transcript/${id}/${format}`);
529
+ let url = `/v2/transcript/${id}/${format}`;
530
+ if (chars_per_caption) {
531
+ const params = new URLSearchParams();
532
+ params.set("chars_per_caption", chars_per_caption.toString());
533
+ url += `?${params.toString()}`;
534
+ }
535
+ const response = yield this.fetch(url);
464
536
  return yield response.text();
465
537
  });
466
538
  }
@@ -1,10 +1,10 @@
1
1
  import { BaseService } from "../base";
2
- import { FileUploadParameters } from "../..";
2
+ import { FileUploadParams } from "../..";
3
3
  export declare class FileService extends BaseService {
4
4
  /**
5
5
  * Upload a local file to AssemblyAI.
6
6
  * @param input The local file path to upload, or a stream or buffer of the file to upload.
7
7
  * @return A promise that resolves to the uploaded file URL.
8
8
  */
9
- upload(input: FileUploadParameters): Promise<string>;
9
+ upload(input: FileUploadParams): Promise<string>;
10
10
  }
@@ -1,10 +1,10 @@
1
- import { LemurSummaryParameters, LemurActionItemsParameters, LemurQuestionAnswerParameters, LemurTaskParameters, LemurSummaryResponse, LemurQuestionAnswerResponse, LemurActionItemsResponse, LemurTaskResponse, PurgeLemurRequestDataResponse } from "../..";
1
+ import { LemurSummaryParams, LemurActionItemsParams, LemurQuestionAnswerParams, LemurTaskParams, LemurSummaryResponse, LemurQuestionAnswerResponse, LemurActionItemsResponse, LemurTaskResponse, PurgeLemurRequestDataResponse } from "../..";
2
2
  import { BaseService } from "../base";
3
3
  export declare class LemurService extends BaseService {
4
- summary(params: LemurSummaryParameters): Promise<LemurSummaryResponse>;
5
- questionAnswer(params: LemurQuestionAnswerParameters): Promise<LemurQuestionAnswerResponse>;
6
- actionItems(params: LemurActionItemsParameters): Promise<LemurActionItemsResponse>;
7
- task(params: LemurTaskParameters): Promise<LemurTaskResponse>;
4
+ summary(params: LemurSummaryParams): Promise<LemurSummaryResponse>;
5
+ questionAnswer(params: LemurQuestionAnswerParams): Promise<LemurQuestionAnswerResponse>;
6
+ actionItems(params: LemurActionItemsParams): Promise<LemurActionItemsResponse>;
7
+ task(params: LemurTaskParams): Promise<LemurTaskResponse>;
8
8
  /**
9
9
  * Delete the data for a previously submitted LeMUR request.
10
10
  * @param id ID of the LeMUR request
@@ -1,17 +1,37 @@
1
1
  import { BaseService } from "../base";
2
- import { ParagraphsResponse, SentencesResponse, Transcript, TranscriptList, CreateTranscriptParameters, CreateTranscriptOptions, Createable, Deletable, Listable, Retrieveable, SubtitleFormat, RedactedAudioResponse, TranscriptListParameters, WordSearchResponse, BaseServiceParams } from "../..";
2
+ import { ParagraphsResponse, SentencesResponse, Transcript, TranscriptList, TranscriptParams, CreateTranscriptOptions, Createable, Deletable, Listable, Retrieveable, SubtitleFormat, RedactedAudioResponse, ListTranscriptParams, WordSearchResponse, BaseServiceParams, PollingOptions, TranscribeParams, TranscribeOptions, SubmitParams } from "../..";
3
3
  import { FileService } from "../files";
4
- export declare class TranscriptService extends BaseService implements Createable<Transcript, CreateTranscriptParameters, CreateTranscriptOptions>, Retrieveable<Transcript>, Deletable<Transcript>, Listable<TranscriptList> {
4
+ export declare class TranscriptService extends BaseService implements Createable<Transcript, TranscriptParams, CreateTranscriptOptions>, Retrieveable<Transcript>, Deletable<Transcript>, Listable<TranscriptList> {
5
5
  private files;
6
6
  constructor(params: BaseServiceParams, files: FileService);
7
+ /**
8
+ * Transcribe an audio file. This will create a transcript and wait until the transcript status is "completed" or "error".
9
+ * @param params The parameters to transcribe an audio file.
10
+ * @param options The options to transcribe an audio file.
11
+ * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
12
+ */
13
+ transcribe(params: TranscribeParams, options?: TranscribeOptions): Promise<Transcript>;
14
+ /**
15
+ * Submits a transcription job for an audio file. This will not wait until the transcript status is "completed" or "error".
16
+ * @param params The parameters to start the transcription of an audio file.
17
+ * @returns A promise that resolves to the queued transcript.
18
+ */
19
+ submit(params: SubmitParams): Promise<Transcript>;
7
20
  /**
8
21
  * Create a transcript.
9
22
  * @param params The parameters to create a transcript.
10
23
  * @param options The options used for creating the new transcript.
11
- * @returns A promise that resolves to the newly created transcript.
24
+ * @returns A promise that resolves to the transcript.
25
+ * @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
26
+ */
27
+ create(params: TranscriptParams, options?: CreateTranscriptOptions): Promise<Transcript>;
28
+ /**
29
+ * Wait until the transcript ready, either the status is "completed" or "error".
30
+ * @param transcriptId The ID of the transcript.
31
+ * @param options The options to wait until the transcript is ready.
32
+ * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
12
33
  */
13
- create(params: CreateTranscriptParameters, options?: CreateTranscriptOptions): Promise<Transcript>;
14
- private poll;
34
+ waitUntilReady(transcriptId: string, options?: PollingOptions): Promise<Transcript>;
15
35
  /**
16
36
  * Retrieve a transcript.
17
37
  * @param id The identifier of the transcript.
@@ -22,7 +42,7 @@ export declare class TranscriptService extends BaseService implements Createable
22
42
  * Retrieves a page of transcript listings.
23
43
  * @param parameters The parameters to filter the transcript list by, or the URL to retrieve the transcript list from.
24
44
  */
25
- list(parameters?: TranscriptListParameters | string): Promise<TranscriptList>;
45
+ list(parameters?: ListTranscriptParams | string): Promise<TranscriptList>;
26
46
  /**
27
47
  * Delete a transcript
28
48
  * @param id The identifier of the transcript.
@@ -53,9 +73,10 @@ export declare class TranscriptService extends BaseService implements Createable
53
73
  * Retrieve subtitles of a transcript.
54
74
  * @param id The identifier of the transcript.
55
75
  * @param format The format of the subtitles.
76
+ * @param chars_per_caption The maximum number of characters per caption.
56
77
  * @return A promise that resolves to the subtitles text.
57
78
  */
58
- subtitles(id: string, format?: SubtitleFormat): Promise<string>;
79
+ subtitles(id: string, format?: SubtitleFormat, chars_per_caption?: number): Promise<string>;
59
80
  /**
60
81
  * Retrieve redactions of a transcript.
61
82
  * @param id The identifier of the transcript.