assemblyai 4.6.0 → 4.7.0-alpha

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.
@@ -529,12 +529,7 @@ export type LemurActionItemsParams = LemurBaseParams & {
529
529
  * }
530
530
  * ```
531
531
  */
532
- export type LemurActionItemsResponse = LemurBaseResponse & {
533
- /**
534
- * The response generated by LeMUR
535
- */
536
- response: string;
537
- };
532
+ export type LemurActionItemsResponse = LemurStringResponse;
538
533
  /**
539
534
  * @example
540
535
  * ```js
@@ -731,7 +726,26 @@ export type LemurQuestionAnswerResponse = LemurBaseResponse & {
731
726
  */
732
727
  response: LemurQuestionAnswer[];
733
728
  };
734
- export type LemurResponse = LemurTaskResponse | LemurSummaryResponse | LemurQuestionAnswerResponse | LemurActionItemsResponse;
729
+ export type LemurResponse = LemurStringResponse | LemurQuestionAnswerResponse;
730
+ /**
731
+ * @example
732
+ * ```js
733
+ * {
734
+ * "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e",
735
+ * "response": "Based on the transcript, the following locations were mentioned as being affected by wildfire smoke from Canada:\n\n- Maine\n- Maryland\n- Minnesota\n- Mid Atlantic region\n- Northeast region\n- New York City\n- Baltimore\n",
736
+ * "usage": {
737
+ * "input_tokens": 27,
738
+ * "output_tokens": 3
739
+ * }
740
+ * }
741
+ * ```
742
+ */
743
+ export type LemurStringResponse = {
744
+ /**
745
+ * The response generated by LeMUR.
746
+ */
747
+ response: string;
748
+ } & LemurBaseResponse;
735
749
  /**
736
750
  * @example
737
751
  * ```js
@@ -765,12 +779,7 @@ export type LemurSummaryParams = LemurBaseParams & {
765
779
  * }
766
780
  * ```
767
781
  */
768
- export type LemurSummaryResponse = LemurBaseResponse & {
769
- /**
770
- * The response generated by LeMUR
771
- */
772
- response: string;
773
- };
782
+ export type LemurSummaryResponse = LemurStringResponse;
774
783
  /**
775
784
  * @example
776
785
  * ```js
@@ -805,12 +814,7 @@ export type LemurTaskParams = {
805
814
  * }
806
815
  * ```
807
816
  */
808
- export type LemurTaskResponse = {
809
- /**
810
- * The response generated by LeMUR.
811
- */
812
- response: string;
813
- } & LemurBaseResponse;
817
+ export type LemurTaskResponse = LemurStringResponse;
814
818
  /**
815
819
  * The usage numbers for the LeMUR request
816
820
  */
@@ -1222,7 +1226,7 @@ export type SeverityScoreSummary = {
1222
1226
  /**
1223
1227
  * The speech model to use for the transcription.
1224
1228
  */
1225
- export type SpeechModel = "best" | "nano" | "conformer-2";
1229
+ export type SpeechModel = "best" | "nano";
1226
1230
  /**
1227
1231
  * The replacement logic for detected PII, can be "entity_name" or "hash". See {@link https://www.assemblyai.com/docs/models/pii-redaction | PII redaction } for more details.
1228
1232
  */
@@ -2235,6 +2239,16 @@ export type Transcript = {
2235
2239
  * The default value is 'en_us'.
2236
2240
  */
2237
2241
  language_code?: LiteralUnion<TranscriptLanguageCode, string>;
2242
+ /**
2243
+ * The confidence score for the detected language, between 0.0 (low confidence) and 1.0 (high confidence)
2244
+ */
2245
+ language_confidence: number | null;
2246
+ /**
2247
+ * The confidence threshold for the automatically detected language.
2248
+ * An error will be returned if the langauge confidence is below this threshold.
2249
+ * Defaults to 0.
2250
+ */
2251
+ language_confidence_threshold: number | null;
2238
2252
  /**
2239
2253
  * Whether {@link https://www.assemblyai.com/docs/models/speech-recognition#automatic-language-detection | Automatic language detection } is enabled, either true or false
2240
2254
  */
@@ -2370,7 +2384,7 @@ export type Transcript = {
2370
2384
  words?: TranscriptWord[] | null;
2371
2385
  };
2372
2386
  /**
2373
- * The word boost parameter value
2387
+ * How much to boost specified words
2374
2388
  */
2375
2389
  export type TranscriptBoostParam = "low" | "default" | "high";
2376
2390
  /**
@@ -2544,7 +2558,7 @@ export type TranscriptOptionalParams = {
2544
2558
  */
2545
2559
  auto_highlights?: boolean;
2546
2560
  /**
2547
- * The word boost parameter value
2561
+ * How much to boost specified words
2548
2562
  */
2549
2563
  boost_param?: TranscriptBoostParam;
2550
2564
  /**
@@ -2592,6 +2606,12 @@ export type TranscriptOptionalParams = {
2592
2606
  * The default value is 'en_us'.
2593
2607
  */
2594
2608
  language_code?: LiteralUnion<TranscriptLanguageCode, string> | null;
2609
+ /**
2610
+ * The confidence threshold for the automatically detected language.
2611
+ * An error will be returned if the langauge confidence is below this threshold.
2612
+ * Defaults to 0.
2613
+ */
2614
+ language_confidence_threshold?: number;
2595
2615
  /**
2596
2616
  * Enable {@link https://www.assemblyai.com/docs/models/speech-recognition#automatic-language-detection | Automatic language detection }, either true or false.
2597
2617
  */
@@ -2635,7 +2655,7 @@ export type TranscriptOptionalParams = {
2635
2655
  */
2636
2656
  speakers_expected?: number | null;
2637
2657
  /**
2638
- * The speech model to use for the transcription. When `null`, the default model is used.
2658
+ * The speech model to use for the transcription. When `null`, the "best" model is used.
2639
2659
  * @defaultValue null
2640
2660
  */
2641
2661
  speech_model?: SpeechModel | null;
@@ -1,22 +1,36 @@
1
- declare enum RealtimeErrorType {
2
- BadSampleRate = 4000,
3
- AuthFailed = 4001,
4
- InsufficientFundsOrFreeAccount = 4002,
5
- NonexistentSessionId = 4004,
6
- SessionExpired = 4008,
7
- ClosedSession = 4010,
8
- RateLimited = 4029,
9
- UniqueSessionViolation = 4030,
10
- SessionTimeout = 4031,
11
- AudioTooShort = 4032,
12
- AudioTooLong = 4033,
13
- BadJson = 4100,
14
- BadSchema = 4101,
15
- TooManyStreams = 4102,
16
- Reconnected = 4103,
17
- ReconnectAttemptsExhausted = 1013
18
- }
19
- declare const RealtimeErrorMessages: Record<RealtimeErrorType, string>;
1
+ declare const RealtimeErrorType: {
2
+ readonly BadSampleRate: 4000;
3
+ readonly AuthFailed: 4001;
4
+ /**
5
+ * @deprecated Use InsufficientFunds or FreeTierUser instead
6
+ */
7
+ readonly InsufficientFundsOrFreeAccount: 4002;
8
+ readonly InsufficientFunds: 4002;
9
+ readonly FreeTierUser: 4003;
10
+ readonly NonexistentSessionId: 4004;
11
+ readonly SessionExpired: 4008;
12
+ readonly ClosedSession: 4010;
13
+ readonly RateLimited: 4029;
14
+ readonly UniqueSessionViolation: 4030;
15
+ readonly SessionTimeout: 4031;
16
+ readonly AudioTooShort: 4032;
17
+ readonly AudioTooLong: 4033;
18
+ readonly AudioTooSmallToTranscode: 4034;
19
+ /**
20
+ * @deprecated Don't use
21
+ */
22
+ readonly BadJson: 4100;
23
+ readonly BadSchema: 4101;
24
+ readonly TooManyStreams: 4102;
25
+ readonly Reconnected: 4103;
26
+ /**
27
+ * @deprecated Don't use
28
+ */
29
+ readonly ReconnectAttemptsExhausted: 1013;
30
+ readonly WordBoostParameterParsingFailed: 4104;
31
+ };
32
+ type RealtimeErrorTypeCodes = (typeof RealtimeErrorType)[keyof typeof RealtimeErrorType];
33
+ declare const RealtimeErrorMessages: Record<RealtimeErrorTypeCodes, string>;
20
34
  declare class RealtimeError extends Error {
21
35
  }
22
- export { RealtimeError, RealtimeErrorType, RealtimeErrorMessages };
36
+ export { RealtimeError, RealtimeErrorType, RealtimeErrorTypeCodes, RealtimeErrorMessages, };
package/dist/workerd.mjs CHANGED
@@ -15,7 +15,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
15
15
  defaultUserAgentString += navigator.userAgent;
16
16
  }
17
17
  const defaultUserAgent = {
18
- sdk: { name: "JavaScript", version: "4.6.0" },
18
+ sdk: { name: "JavaScript", version: "4.6.2" },
19
19
  };
20
20
  if (typeof process !== "undefined") {
21
21
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -147,30 +147,42 @@ const { WritableStream } = typeof window !== "undefined"
147
147
 
148
148
  const factory = (url, params) => new ws(url, params);
149
149
 
150
- var RealtimeErrorType;
151
- (function (RealtimeErrorType) {
152
- RealtimeErrorType[RealtimeErrorType["BadSampleRate"] = 4000] = "BadSampleRate";
153
- RealtimeErrorType[RealtimeErrorType["AuthFailed"] = 4001] = "AuthFailed";
154
- // Both InsufficientFunds and FreeAccount error use 4002
155
- RealtimeErrorType[RealtimeErrorType["InsufficientFundsOrFreeAccount"] = 4002] = "InsufficientFundsOrFreeAccount";
156
- RealtimeErrorType[RealtimeErrorType["NonexistentSessionId"] = 4004] = "NonexistentSessionId";
157
- RealtimeErrorType[RealtimeErrorType["SessionExpired"] = 4008] = "SessionExpired";
158
- RealtimeErrorType[RealtimeErrorType["ClosedSession"] = 4010] = "ClosedSession";
159
- RealtimeErrorType[RealtimeErrorType["RateLimited"] = 4029] = "RateLimited";
160
- RealtimeErrorType[RealtimeErrorType["UniqueSessionViolation"] = 4030] = "UniqueSessionViolation";
161
- RealtimeErrorType[RealtimeErrorType["SessionTimeout"] = 4031] = "SessionTimeout";
162
- RealtimeErrorType[RealtimeErrorType["AudioTooShort"] = 4032] = "AudioTooShort";
163
- RealtimeErrorType[RealtimeErrorType["AudioTooLong"] = 4033] = "AudioTooLong";
164
- RealtimeErrorType[RealtimeErrorType["BadJson"] = 4100] = "BadJson";
165
- RealtimeErrorType[RealtimeErrorType["BadSchema"] = 4101] = "BadSchema";
166
- RealtimeErrorType[RealtimeErrorType["TooManyStreams"] = 4102] = "TooManyStreams";
167
- RealtimeErrorType[RealtimeErrorType["Reconnected"] = 4103] = "Reconnected";
168
- RealtimeErrorType[RealtimeErrorType["ReconnectAttemptsExhausted"] = 1013] = "ReconnectAttemptsExhausted";
169
- })(RealtimeErrorType || (RealtimeErrorType = {}));
150
+ const RealtimeErrorType = {
151
+ BadSampleRate: 4000,
152
+ AuthFailed: 4001,
153
+ /**
154
+ * @deprecated Use InsufficientFunds or FreeTierUser instead
155
+ */
156
+ InsufficientFundsOrFreeAccount: 4002,
157
+ InsufficientFunds: 4002,
158
+ FreeTierUser: 4003,
159
+ NonexistentSessionId: 4004,
160
+ SessionExpired: 4008,
161
+ ClosedSession: 4010,
162
+ RateLimited: 4029,
163
+ UniqueSessionViolation: 4030,
164
+ SessionTimeout: 4031,
165
+ AudioTooShort: 4032,
166
+ AudioTooLong: 4033,
167
+ AudioTooSmallToTranscode: 4034,
168
+ /**
169
+ * @deprecated Don't use
170
+ */
171
+ BadJson: 4100,
172
+ BadSchema: 4101,
173
+ TooManyStreams: 4102,
174
+ Reconnected: 4103,
175
+ /**
176
+ * @deprecated Don't use
177
+ */
178
+ ReconnectAttemptsExhausted: 1013,
179
+ WordBoostParameterParsingFailed: 4104,
180
+ };
170
181
  const RealtimeErrorMessages = {
171
182
  [RealtimeErrorType.BadSampleRate]: "Sample rate must be a positive integer",
172
183
  [RealtimeErrorType.AuthFailed]: "Not Authorized",
173
- [RealtimeErrorType.InsufficientFundsOrFreeAccount]: "Insufficient funds or you are using a free account. This feature is paid-only and requires you to add a credit card. Please visit https://assemblyai.com/dashboard/ to add a credit card to your account.",
184
+ [RealtimeErrorType.InsufficientFunds]: "Insufficient funds",
185
+ [RealtimeErrorType.FreeTierUser]: "This feature is paid-only and requires you to add a credit card. Please visit https://app.assemblyai.com/ to add a credit card to your account.",
174
186
  [RealtimeErrorType.NonexistentSessionId]: "Session ID does not exist",
175
187
  [RealtimeErrorType.SessionExpired]: "Session has expired",
176
188
  [RealtimeErrorType.ClosedSession]: "Session is closed",
@@ -179,11 +191,13 @@ const RealtimeErrorMessages = {
179
191
  [RealtimeErrorType.SessionTimeout]: "Session Timeout",
180
192
  [RealtimeErrorType.AudioTooShort]: "Audio too short",
181
193
  [RealtimeErrorType.AudioTooLong]: "Audio too long",
194
+ [RealtimeErrorType.AudioTooSmallToTranscode]: "Audio too small to transcode",
182
195
  [RealtimeErrorType.BadJson]: "Bad JSON",
183
196
  [RealtimeErrorType.BadSchema]: "Bad schema",
184
197
  [RealtimeErrorType.TooManyStreams]: "Too many streams",
185
- [RealtimeErrorType.Reconnected]: "Reconnected",
198
+ [RealtimeErrorType.Reconnected]: "This session has been reconnected. This WebSocket is no longer valid.",
186
199
  [RealtimeErrorType.ReconnectAttemptsExhausted]: "Reconnect attempts exhausted",
200
+ [RealtimeErrorType.WordBoostParameterParsingFailed]: "Could not parse word boost parameter",
187
201
  };
188
202
  class RealtimeError extends Error {
189
203
  }
@@ -275,7 +289,7 @@ class RealtimeTranscriber {
275
289
  };
276
290
  this.socket.onclose = ({ code, reason }) => {
277
291
  if (!reason) {
278
- if (code in RealtimeErrorType) {
292
+ if (code in RealtimeErrorMessages) {
279
293
  reason = RealtimeErrorMessages[code];
280
294
  }
281
295
  }
@@ -458,7 +472,6 @@ class TranscriptService extends BaseService {
458
472
  * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
459
473
  */
460
474
  async transcribe(params, options) {
461
- deprecateConformer2(params);
462
475
  const transcript = await this.submit(params);
463
476
  return await this.waitUntilReady(transcript.id, options);
464
477
  }
@@ -468,7 +481,6 @@ class TranscriptService extends BaseService {
468
481
  * @returns A promise that resolves to the queued transcript.
469
482
  */
470
483
  async submit(params) {
471
- deprecateConformer2(params);
472
484
  let audioUrl;
473
485
  let transcriptParams = undefined;
474
486
  if ("audio" in params) {
@@ -512,7 +524,6 @@ class TranscriptService extends BaseService {
512
524
  * @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
513
525
  */
514
526
  async create(params, options) {
515
- deprecateConformer2(params);
516
527
  const path = getPath(params.audio_url);
517
528
  if (path !== null) {
518
529
  const uploadUrl = await this.files.upload(path);
@@ -675,13 +686,6 @@ class TranscriptService extends BaseService {
675
686
  };
676
687
  }
677
688
  }
678
- function deprecateConformer2(params) {
679
- if (!params)
680
- return;
681
- if (params.speech_model === "conformer-2") {
682
- console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
683
- }
684
- }
685
689
 
686
690
  const readFile = async function (
687
691
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assemblyai",
3
- "version": "4.6.0",
3
+ "version": "4.7.0-alpha",
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"
@@ -71,7 +71,7 @@
71
71
  "url": "git+https://github.com/AssemblyAI/assemblyai-node-sdk.git"
72
72
  },
73
73
  "publishConfig": {
74
- "tag": "latest",
74
+ "tag": "alpha",
75
75
  "access": "public",
76
76
  "registry": "https://registry.npmjs.org/"
77
77
  },
@@ -17,11 +17,8 @@ import {
17
17
  AudioData,
18
18
  SessionInformation,
19
19
  } from "../..";
20
- import {
21
- RealtimeError,
22
- RealtimeErrorMessages,
23
- RealtimeErrorType,
24
- } from "../../utils/errors";
20
+ import { RealtimeError, RealtimeErrorMessages } from "../../utils/errors";
21
+ import { RealtimeErrorTypeCodes } from "../../utils/errors/realtime";
25
22
 
26
23
  const defaultRealtimeUrl = "wss://api.assemblyai.com/v2/realtime/ws";
27
24
  const forceEndOfUtteranceMessage = `{"force_end_utterance":true}`;
@@ -213,8 +210,8 @@ export class RealtimeTranscriber {
213
210
 
214
211
  this.socket!.onclose = ({ code, reason }: CloseEvent) => {
215
212
  if (!reason) {
216
- if (code in RealtimeErrorType) {
217
- reason = RealtimeErrorMessages[code as RealtimeErrorType];
213
+ if (code in RealtimeErrorMessages) {
214
+ reason = RealtimeErrorMessages[code as RealtimeErrorTypeCodes];
218
215
  }
219
216
  }
220
217
  this.listeners.close?.(code, reason);
@@ -15,7 +15,6 @@ import {
15
15
  TranscribeParams,
16
16
  TranscribeOptions,
17
17
  SubmitParams,
18
- SpeechModel,
19
18
  RedactedAudioFile,
20
19
  } from "../..";
21
20
  import { FileService } from "../files";
@@ -39,7 +38,6 @@ export class TranscriptService extends BaseService {
39
38
  params: TranscribeParams,
40
39
  options?: TranscribeOptions,
41
40
  ): Promise<Transcript> {
42
- deprecateConformer2(params);
43
41
  const transcript = await this.submit(params);
44
42
  return await this.waitUntilReady(transcript.id, options);
45
43
  }
@@ -50,7 +48,6 @@ export class TranscriptService extends BaseService {
50
48
  * @returns A promise that resolves to the queued transcript.
51
49
  */
52
50
  async submit(params: SubmitParams): Promise<Transcript> {
53
- deprecateConformer2(params);
54
51
  let audioUrl;
55
52
  let transcriptParams: TranscriptParams | undefined = undefined;
56
53
  if ("audio" in params) {
@@ -95,7 +92,6 @@ export class TranscriptService extends BaseService {
95
92
  params: TranscriptParams,
96
93
  options?: CreateTranscriptOptions,
97
94
  ): Promise<Transcript> {
98
- deprecateConformer2(params);
99
95
  const path = getPath(params.audio_url);
100
96
  if (path !== null) {
101
97
  const uploadUrl = await this.files.upload(path);
@@ -287,12 +283,3 @@ export class TranscriptService extends BaseService {
287
283
  };
288
284
  }
289
285
  }
290
-
291
- function deprecateConformer2(params: { speech_model?: SpeechModel | null }) {
292
- if (!params) return;
293
- if (params.speech_model === "conformer-2") {
294
- console.warn(
295
- "The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.",
296
- );
297
- }
298
- }
@@ -596,12 +596,7 @@ export type LemurActionItemsParams = LemurBaseParams & {
596
596
  * }
597
597
  * ```
598
598
  */
599
- export type LemurActionItemsResponse = LemurBaseResponse & {
600
- /**
601
- * The response generated by LeMUR
602
- */
603
- response: string;
604
- };
599
+ export type LemurActionItemsResponse = LemurStringResponse;
605
600
 
606
601
  /**
607
602
  * @example
@@ -820,11 +815,27 @@ export type LemurQuestionAnswerResponse = LemurBaseResponse & {
820
815
  response: LemurQuestionAnswer[];
821
816
  };
822
817
 
823
- export type LemurResponse =
824
- | LemurTaskResponse
825
- | LemurSummaryResponse
826
- | LemurQuestionAnswerResponse
827
- | LemurActionItemsResponse;
818
+ export type LemurResponse = LemurStringResponse | LemurQuestionAnswerResponse;
819
+
820
+ /**
821
+ * @example
822
+ * ```js
823
+ * {
824
+ * "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e",
825
+ * "response": "Based on the transcript, the following locations were mentioned as being affected by wildfire smoke from Canada:\n\n- Maine\n- Maryland\n- Minnesota\n- Mid Atlantic region\n- Northeast region\n- New York City\n- Baltimore\n",
826
+ * "usage": {
827
+ * "input_tokens": 27,
828
+ * "output_tokens": 3
829
+ * }
830
+ * }
831
+ * ```
832
+ */
833
+ export type LemurStringResponse = {
834
+ /**
835
+ * The response generated by LeMUR.
836
+ */
837
+ response: string;
838
+ } & LemurBaseResponse;
828
839
 
829
840
  /**
830
841
  * @example
@@ -860,12 +871,7 @@ export type LemurSummaryParams = LemurBaseParams & {
860
871
  * }
861
872
  * ```
862
873
  */
863
- export type LemurSummaryResponse = LemurBaseResponse & {
864
- /**
865
- * The response generated by LeMUR
866
- */
867
- response: string;
868
- };
874
+ export type LemurSummaryResponse = LemurStringResponse;
869
875
 
870
876
  /**
871
877
  * @example
@@ -902,12 +908,7 @@ export type LemurTaskParams = {
902
908
  * }
903
909
  * ```
904
910
  */
905
- export type LemurTaskResponse = {
906
- /**
907
- * The response generated by LeMUR.
908
- */
909
- response: string;
910
- } & LemurBaseResponse;
911
+ export type LemurTaskResponse = LemurStringResponse;
911
912
 
912
913
  /**
913
914
  * The usage numbers for the LeMUR request
@@ -1379,7 +1380,7 @@ export type SeverityScoreSummary = {
1379
1380
  /**
1380
1381
  * The speech model to use for the transcription.
1381
1382
  */
1382
- export type SpeechModel = "best" | "nano" | "conformer-2";
1383
+ export type SpeechModel = "best" | "nano";
1383
1384
 
1384
1385
  /**
1385
1386
  * The replacement logic for detected PII, can be "entity_name" or "hash". See {@link https://www.assemblyai.com/docs/models/pii-redaction | PII redaction } for more details.
@@ -2405,6 +2406,16 @@ export type Transcript = {
2405
2406
  * The default value is 'en_us'.
2406
2407
  */
2407
2408
  language_code?: LiteralUnion<TranscriptLanguageCode, string>;
2409
+ /**
2410
+ * The confidence score for the detected language, between 0.0 (low confidence) and 1.0 (high confidence)
2411
+ */
2412
+ language_confidence: number | null;
2413
+ /**
2414
+ * The confidence threshold for the automatically detected language.
2415
+ * An error will be returned if the langauge confidence is below this threshold.
2416
+ * Defaults to 0.
2417
+ */
2418
+ language_confidence_threshold: number | null;
2408
2419
  /**
2409
2420
  * Whether {@link https://www.assemblyai.com/docs/models/speech-recognition#automatic-language-detection | Automatic language detection } is enabled, either true or false
2410
2421
  */
@@ -2541,7 +2552,7 @@ export type Transcript = {
2541
2552
  };
2542
2553
 
2543
2554
  /**
2544
- * The word boost parameter value
2555
+ * How much to boost specified words
2545
2556
  */
2546
2557
  export type TranscriptBoostParam = "low" | "default" | "high";
2547
2558
 
@@ -2822,7 +2833,7 @@ export type TranscriptOptionalParams = {
2822
2833
  */
2823
2834
  auto_highlights?: boolean;
2824
2835
  /**
2825
- * The word boost parameter value
2836
+ * How much to boost specified words
2826
2837
  */
2827
2838
  boost_param?: TranscriptBoostParam;
2828
2839
  /**
@@ -2870,6 +2881,12 @@ export type TranscriptOptionalParams = {
2870
2881
  * The default value is 'en_us'.
2871
2882
  */
2872
2883
  language_code?: LiteralUnion<TranscriptLanguageCode, string> | null;
2884
+ /**
2885
+ * The confidence threshold for the automatically detected language.
2886
+ * An error will be returned if the langauge confidence is below this threshold.
2887
+ * Defaults to 0.
2888
+ */
2889
+ language_confidence_threshold?: number;
2873
2890
  /**
2874
2891
  * Enable {@link https://www.assemblyai.com/docs/models/speech-recognition#automatic-language-detection | Automatic language detection }, either true or false.
2875
2892
  */
@@ -2913,7 +2930,7 @@ export type TranscriptOptionalParams = {
2913
2930
  */
2914
2931
  speakers_expected?: number | null;
2915
2932
  /**
2916
- * The speech model to use for the transcription. When `null`, the default model is used.
2933
+ * The speech model to use for the transcription. When `null`, the "best" model is used.
2917
2934
  * @defaultValue null
2918
2935
  */
2919
2936
  speech_model?: SpeechModel | null;
@@ -1,28 +1,44 @@
1
- enum RealtimeErrorType {
2
- BadSampleRate = 4000,
3
- AuthFailed = 4001,
4
- // Both InsufficientFunds and FreeAccount error use 4002
5
- InsufficientFundsOrFreeAccount = 4002,
6
- NonexistentSessionId = 4004,
7
- SessionExpired = 4008,
8
- ClosedSession = 4010,
9
- RateLimited = 4029,
10
- UniqueSessionViolation = 4030,
11
- SessionTimeout = 4031,
12
- AudioTooShort = 4032,
13
- AudioTooLong = 4033,
14
- BadJson = 4100,
15
- BadSchema = 4101,
16
- TooManyStreams = 4102,
17
- Reconnected = 4103,
18
- ReconnectAttemptsExhausted = 1013,
19
- }
1
+ const RealtimeErrorType = {
2
+ BadSampleRate: 4000,
3
+ AuthFailed: 4001,
4
+ /**
5
+ * @deprecated Use InsufficientFunds or FreeTierUser instead
6
+ */
7
+ InsufficientFundsOrFreeAccount: 4002,
8
+ InsufficientFunds: 4002,
9
+ FreeTierUser: 4003,
10
+ NonexistentSessionId: 4004,
11
+ SessionExpired: 4008,
12
+ ClosedSession: 4010,
13
+ RateLimited: 4029,
14
+ UniqueSessionViolation: 4030,
15
+ SessionTimeout: 4031,
16
+ AudioTooShort: 4032,
17
+ AudioTooLong: 4033,
18
+ AudioTooSmallToTranscode: 4034,
19
+ /**
20
+ * @deprecated Don't use
21
+ */
22
+ BadJson: 4100,
23
+ BadSchema: 4101,
24
+ TooManyStreams: 4102,
25
+ Reconnected: 4103,
26
+ /**
27
+ * @deprecated Don't use
28
+ */
29
+ ReconnectAttemptsExhausted: 1013,
30
+ WordBoostParameterParsingFailed: 4104,
31
+ } as const;
20
32
 
21
- const RealtimeErrorMessages: Record<RealtimeErrorType, string> = {
33
+ type RealtimeErrorTypeCodes =
34
+ (typeof RealtimeErrorType)[keyof typeof RealtimeErrorType];
35
+
36
+ const RealtimeErrorMessages: Record<RealtimeErrorTypeCodes, string> = {
22
37
  [RealtimeErrorType.BadSampleRate]: "Sample rate must be a positive integer",
23
38
  [RealtimeErrorType.AuthFailed]: "Not Authorized",
24
- [RealtimeErrorType.InsufficientFundsOrFreeAccount]:
25
- "Insufficient funds or you are using a free account. This feature is paid-only and requires you to add a credit card. Please visit https://assemblyai.com/dashboard/ to add a credit card to your account.",
39
+ [RealtimeErrorType.InsufficientFunds]: "Insufficient funds",
40
+ [RealtimeErrorType.FreeTierUser]:
41
+ "This feature is paid-only and requires you to add a credit card. Please visit https://app.assemblyai.com/ to add a credit card to your account.",
26
42
  [RealtimeErrorType.NonexistentSessionId]: "Session ID does not exist",
27
43
  [RealtimeErrorType.SessionExpired]: "Session has expired",
28
44
  [RealtimeErrorType.ClosedSession]: "Session is closed",
@@ -31,14 +47,23 @@ const RealtimeErrorMessages: Record<RealtimeErrorType, string> = {
31
47
  [RealtimeErrorType.SessionTimeout]: "Session Timeout",
32
48
  [RealtimeErrorType.AudioTooShort]: "Audio too short",
33
49
  [RealtimeErrorType.AudioTooLong]: "Audio too long",
50
+ [RealtimeErrorType.AudioTooSmallToTranscode]: "Audio too small to transcode",
34
51
  [RealtimeErrorType.BadJson]: "Bad JSON",
35
52
  [RealtimeErrorType.BadSchema]: "Bad schema",
36
53
  [RealtimeErrorType.TooManyStreams]: "Too many streams",
37
- [RealtimeErrorType.Reconnected]: "Reconnected",
54
+ [RealtimeErrorType.Reconnected]:
55
+ "This session has been reconnected. This WebSocket is no longer valid.",
38
56
  [RealtimeErrorType.ReconnectAttemptsExhausted]:
39
57
  "Reconnect attempts exhausted",
58
+ [RealtimeErrorType.WordBoostParameterParsingFailed]:
59
+ "Could not parse word boost parameter",
40
60
  };
41
61
 
42
62
  class RealtimeError extends Error {}
43
63
 
44
- export { RealtimeError, RealtimeErrorType, RealtimeErrorMessages };
64
+ export {
65
+ RealtimeError,
66
+ RealtimeErrorType,
67
+ RealtimeErrorTypeCodes,
68
+ RealtimeErrorMessages,
69
+ };