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.
package/dist/node.cjs CHANGED
@@ -22,7 +22,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
22
22
  defaultUserAgentString += navigator.userAgent;
23
23
  }
24
24
  const defaultUserAgent = {
25
- sdk: { name: "JavaScript", version: "4.6.0" },
25
+ sdk: { name: "JavaScript", version: "4.6.2" },
26
26
  };
27
27
  if (typeof process !== "undefined") {
28
28
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -148,30 +148,42 @@ class LemurService extends BaseService {
148
148
 
149
149
  const factory = (url, params) => new ws(url, params);
150
150
 
151
- var RealtimeErrorType;
152
- (function (RealtimeErrorType) {
153
- RealtimeErrorType[RealtimeErrorType["BadSampleRate"] = 4000] = "BadSampleRate";
154
- RealtimeErrorType[RealtimeErrorType["AuthFailed"] = 4001] = "AuthFailed";
155
- // Both InsufficientFunds and FreeAccount error use 4002
156
- RealtimeErrorType[RealtimeErrorType["InsufficientFundsOrFreeAccount"] = 4002] = "InsufficientFundsOrFreeAccount";
157
- RealtimeErrorType[RealtimeErrorType["NonexistentSessionId"] = 4004] = "NonexistentSessionId";
158
- RealtimeErrorType[RealtimeErrorType["SessionExpired"] = 4008] = "SessionExpired";
159
- RealtimeErrorType[RealtimeErrorType["ClosedSession"] = 4010] = "ClosedSession";
160
- RealtimeErrorType[RealtimeErrorType["RateLimited"] = 4029] = "RateLimited";
161
- RealtimeErrorType[RealtimeErrorType["UniqueSessionViolation"] = 4030] = "UniqueSessionViolation";
162
- RealtimeErrorType[RealtimeErrorType["SessionTimeout"] = 4031] = "SessionTimeout";
163
- RealtimeErrorType[RealtimeErrorType["AudioTooShort"] = 4032] = "AudioTooShort";
164
- RealtimeErrorType[RealtimeErrorType["AudioTooLong"] = 4033] = "AudioTooLong";
165
- RealtimeErrorType[RealtimeErrorType["BadJson"] = 4100] = "BadJson";
166
- RealtimeErrorType[RealtimeErrorType["BadSchema"] = 4101] = "BadSchema";
167
- RealtimeErrorType[RealtimeErrorType["TooManyStreams"] = 4102] = "TooManyStreams";
168
- RealtimeErrorType[RealtimeErrorType["Reconnected"] = 4103] = "Reconnected";
169
- RealtimeErrorType[RealtimeErrorType["ReconnectAttemptsExhausted"] = 1013] = "ReconnectAttemptsExhausted";
170
- })(RealtimeErrorType || (RealtimeErrorType = {}));
151
+ const RealtimeErrorType = {
152
+ BadSampleRate: 4000,
153
+ AuthFailed: 4001,
154
+ /**
155
+ * @deprecated Use InsufficientFunds or FreeTierUser instead
156
+ */
157
+ InsufficientFundsOrFreeAccount: 4002,
158
+ InsufficientFunds: 4002,
159
+ FreeTierUser: 4003,
160
+ NonexistentSessionId: 4004,
161
+ SessionExpired: 4008,
162
+ ClosedSession: 4010,
163
+ RateLimited: 4029,
164
+ UniqueSessionViolation: 4030,
165
+ SessionTimeout: 4031,
166
+ AudioTooShort: 4032,
167
+ AudioTooLong: 4033,
168
+ AudioTooSmallToTranscode: 4034,
169
+ /**
170
+ * @deprecated Don't use
171
+ */
172
+ BadJson: 4100,
173
+ BadSchema: 4101,
174
+ TooManyStreams: 4102,
175
+ Reconnected: 4103,
176
+ /**
177
+ * @deprecated Don't use
178
+ */
179
+ ReconnectAttemptsExhausted: 1013,
180
+ WordBoostParameterParsingFailed: 4104,
181
+ };
171
182
  const RealtimeErrorMessages = {
172
183
  [RealtimeErrorType.BadSampleRate]: "Sample rate must be a positive integer",
173
184
  [RealtimeErrorType.AuthFailed]: "Not Authorized",
174
- [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.",
185
+ [RealtimeErrorType.InsufficientFunds]: "Insufficient funds",
186
+ [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.",
175
187
  [RealtimeErrorType.NonexistentSessionId]: "Session ID does not exist",
176
188
  [RealtimeErrorType.SessionExpired]: "Session has expired",
177
189
  [RealtimeErrorType.ClosedSession]: "Session is closed",
@@ -180,11 +192,13 @@ const RealtimeErrorMessages = {
180
192
  [RealtimeErrorType.SessionTimeout]: "Session Timeout",
181
193
  [RealtimeErrorType.AudioTooShort]: "Audio too short",
182
194
  [RealtimeErrorType.AudioTooLong]: "Audio too long",
195
+ [RealtimeErrorType.AudioTooSmallToTranscode]: "Audio too small to transcode",
183
196
  [RealtimeErrorType.BadJson]: "Bad JSON",
184
197
  [RealtimeErrorType.BadSchema]: "Bad schema",
185
198
  [RealtimeErrorType.TooManyStreams]: "Too many streams",
186
- [RealtimeErrorType.Reconnected]: "Reconnected",
199
+ [RealtimeErrorType.Reconnected]: "This session has been reconnected. This WebSocket is no longer valid.",
187
200
  [RealtimeErrorType.ReconnectAttemptsExhausted]: "Reconnect attempts exhausted",
201
+ [RealtimeErrorType.WordBoostParameterParsingFailed]: "Could not parse word boost parameter",
188
202
  };
189
203
  class RealtimeError extends Error {
190
204
  }
@@ -276,7 +290,7 @@ class RealtimeTranscriber {
276
290
  };
277
291
  this.socket.onclose = ({ code, reason }) => {
278
292
  if (!reason) {
279
- if (code in RealtimeErrorType) {
293
+ if (code in RealtimeErrorMessages) {
280
294
  reason = RealtimeErrorMessages[code];
281
295
  }
282
296
  }
@@ -459,7 +473,6 @@ class TranscriptService extends BaseService {
459
473
  * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
460
474
  */
461
475
  async transcribe(params, options) {
462
- deprecateConformer2(params);
463
476
  const transcript = await this.submit(params);
464
477
  return await this.waitUntilReady(transcript.id, options);
465
478
  }
@@ -469,7 +482,6 @@ class TranscriptService extends BaseService {
469
482
  * @returns A promise that resolves to the queued transcript.
470
483
  */
471
484
  async submit(params) {
472
- deprecateConformer2(params);
473
485
  let audioUrl;
474
486
  let transcriptParams = undefined;
475
487
  if ("audio" in params) {
@@ -513,7 +525,6 @@ class TranscriptService extends BaseService {
513
525
  * @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
514
526
  */
515
527
  async create(params, options) {
516
- deprecateConformer2(params);
517
528
  const path = getPath(params.audio_url);
518
529
  if (path !== null) {
519
530
  const uploadUrl = await this.files.upload(path);
@@ -676,13 +687,6 @@ class TranscriptService extends BaseService {
676
687
  };
677
688
  }
678
689
  }
679
- function deprecateConformer2(params) {
680
- if (!params)
681
- return;
682
- if (params.speech_model === "conformer-2") {
683
- console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
684
- }
685
- }
686
690
 
687
691
  const readFile = async (path) => stream.Readable.toWeb(fs.createReadStream(path));
688
692
 
package/dist/node.mjs CHANGED
@@ -20,7 +20,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
20
20
  defaultUserAgentString += navigator.userAgent;
21
21
  }
22
22
  const defaultUserAgent = {
23
- sdk: { name: "JavaScript", version: "4.6.0" },
23
+ sdk: { name: "JavaScript", version: "4.6.2" },
24
24
  };
25
25
  if (typeof process !== "undefined") {
26
26
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -146,30 +146,42 @@ class LemurService extends BaseService {
146
146
 
147
147
  const factory = (url, params) => new ws(url, params);
148
148
 
149
- var RealtimeErrorType;
150
- (function (RealtimeErrorType) {
151
- RealtimeErrorType[RealtimeErrorType["BadSampleRate"] = 4000] = "BadSampleRate";
152
- RealtimeErrorType[RealtimeErrorType["AuthFailed"] = 4001] = "AuthFailed";
153
- // Both InsufficientFunds and FreeAccount error use 4002
154
- RealtimeErrorType[RealtimeErrorType["InsufficientFundsOrFreeAccount"] = 4002] = "InsufficientFundsOrFreeAccount";
155
- RealtimeErrorType[RealtimeErrorType["NonexistentSessionId"] = 4004] = "NonexistentSessionId";
156
- RealtimeErrorType[RealtimeErrorType["SessionExpired"] = 4008] = "SessionExpired";
157
- RealtimeErrorType[RealtimeErrorType["ClosedSession"] = 4010] = "ClosedSession";
158
- RealtimeErrorType[RealtimeErrorType["RateLimited"] = 4029] = "RateLimited";
159
- RealtimeErrorType[RealtimeErrorType["UniqueSessionViolation"] = 4030] = "UniqueSessionViolation";
160
- RealtimeErrorType[RealtimeErrorType["SessionTimeout"] = 4031] = "SessionTimeout";
161
- RealtimeErrorType[RealtimeErrorType["AudioTooShort"] = 4032] = "AudioTooShort";
162
- RealtimeErrorType[RealtimeErrorType["AudioTooLong"] = 4033] = "AudioTooLong";
163
- RealtimeErrorType[RealtimeErrorType["BadJson"] = 4100] = "BadJson";
164
- RealtimeErrorType[RealtimeErrorType["BadSchema"] = 4101] = "BadSchema";
165
- RealtimeErrorType[RealtimeErrorType["TooManyStreams"] = 4102] = "TooManyStreams";
166
- RealtimeErrorType[RealtimeErrorType["Reconnected"] = 4103] = "Reconnected";
167
- RealtimeErrorType[RealtimeErrorType["ReconnectAttemptsExhausted"] = 1013] = "ReconnectAttemptsExhausted";
168
- })(RealtimeErrorType || (RealtimeErrorType = {}));
149
+ const RealtimeErrorType = {
150
+ BadSampleRate: 4000,
151
+ AuthFailed: 4001,
152
+ /**
153
+ * @deprecated Use InsufficientFunds or FreeTierUser instead
154
+ */
155
+ InsufficientFundsOrFreeAccount: 4002,
156
+ InsufficientFunds: 4002,
157
+ FreeTierUser: 4003,
158
+ NonexistentSessionId: 4004,
159
+ SessionExpired: 4008,
160
+ ClosedSession: 4010,
161
+ RateLimited: 4029,
162
+ UniqueSessionViolation: 4030,
163
+ SessionTimeout: 4031,
164
+ AudioTooShort: 4032,
165
+ AudioTooLong: 4033,
166
+ AudioTooSmallToTranscode: 4034,
167
+ /**
168
+ * @deprecated Don't use
169
+ */
170
+ BadJson: 4100,
171
+ BadSchema: 4101,
172
+ TooManyStreams: 4102,
173
+ Reconnected: 4103,
174
+ /**
175
+ * @deprecated Don't use
176
+ */
177
+ ReconnectAttemptsExhausted: 1013,
178
+ WordBoostParameterParsingFailed: 4104,
179
+ };
169
180
  const RealtimeErrorMessages = {
170
181
  [RealtimeErrorType.BadSampleRate]: "Sample rate must be a positive integer",
171
182
  [RealtimeErrorType.AuthFailed]: "Not Authorized",
172
- [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.",
183
+ [RealtimeErrorType.InsufficientFunds]: "Insufficient funds",
184
+ [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.",
173
185
  [RealtimeErrorType.NonexistentSessionId]: "Session ID does not exist",
174
186
  [RealtimeErrorType.SessionExpired]: "Session has expired",
175
187
  [RealtimeErrorType.ClosedSession]: "Session is closed",
@@ -178,11 +190,13 @@ const RealtimeErrorMessages = {
178
190
  [RealtimeErrorType.SessionTimeout]: "Session Timeout",
179
191
  [RealtimeErrorType.AudioTooShort]: "Audio too short",
180
192
  [RealtimeErrorType.AudioTooLong]: "Audio too long",
193
+ [RealtimeErrorType.AudioTooSmallToTranscode]: "Audio too small to transcode",
181
194
  [RealtimeErrorType.BadJson]: "Bad JSON",
182
195
  [RealtimeErrorType.BadSchema]: "Bad schema",
183
196
  [RealtimeErrorType.TooManyStreams]: "Too many streams",
184
- [RealtimeErrorType.Reconnected]: "Reconnected",
197
+ [RealtimeErrorType.Reconnected]: "This session has been reconnected. This WebSocket is no longer valid.",
185
198
  [RealtimeErrorType.ReconnectAttemptsExhausted]: "Reconnect attempts exhausted",
199
+ [RealtimeErrorType.WordBoostParameterParsingFailed]: "Could not parse word boost parameter",
186
200
  };
187
201
  class RealtimeError extends Error {
188
202
  }
@@ -274,7 +288,7 @@ class RealtimeTranscriber {
274
288
  };
275
289
  this.socket.onclose = ({ code, reason }) => {
276
290
  if (!reason) {
277
- if (code in RealtimeErrorType) {
291
+ if (code in RealtimeErrorMessages) {
278
292
  reason = RealtimeErrorMessages[code];
279
293
  }
280
294
  }
@@ -457,7 +471,6 @@ class TranscriptService extends BaseService {
457
471
  * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
458
472
  */
459
473
  async transcribe(params, options) {
460
- deprecateConformer2(params);
461
474
  const transcript = await this.submit(params);
462
475
  return await this.waitUntilReady(transcript.id, options);
463
476
  }
@@ -467,7 +480,6 @@ class TranscriptService extends BaseService {
467
480
  * @returns A promise that resolves to the queued transcript.
468
481
  */
469
482
  async submit(params) {
470
- deprecateConformer2(params);
471
483
  let audioUrl;
472
484
  let transcriptParams = undefined;
473
485
  if ("audio" in params) {
@@ -511,7 +523,6 @@ class TranscriptService extends BaseService {
511
523
  * @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
512
524
  */
513
525
  async create(params, options) {
514
- deprecateConformer2(params);
515
526
  const path = getPath(params.audio_url);
516
527
  if (path !== null) {
517
528
  const uploadUrl = await this.files.upload(path);
@@ -674,13 +685,6 @@ class TranscriptService extends BaseService {
674
685
  };
675
686
  }
676
687
  }
677
- function deprecateConformer2(params) {
678
- if (!params)
679
- return;
680
- if (params.speech_model === "conformer-2") {
681
- console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
682
- }
683
- }
684
688
 
685
689
  const readFile = async (path) => Readable.toWeb(createReadStream(path));
686
690
 
@@ -12,30 +12,42 @@ const factory = (url, params) => {
12
12
  return new PolyfillWebSocket(url);
13
13
  };
14
14
 
15
- var RealtimeErrorType;
16
- (function (RealtimeErrorType) {
17
- RealtimeErrorType[RealtimeErrorType["BadSampleRate"] = 4000] = "BadSampleRate";
18
- RealtimeErrorType[RealtimeErrorType["AuthFailed"] = 4001] = "AuthFailed";
19
- // Both InsufficientFunds and FreeAccount error use 4002
20
- RealtimeErrorType[RealtimeErrorType["InsufficientFundsOrFreeAccount"] = 4002] = "InsufficientFundsOrFreeAccount";
21
- RealtimeErrorType[RealtimeErrorType["NonexistentSessionId"] = 4004] = "NonexistentSessionId";
22
- RealtimeErrorType[RealtimeErrorType["SessionExpired"] = 4008] = "SessionExpired";
23
- RealtimeErrorType[RealtimeErrorType["ClosedSession"] = 4010] = "ClosedSession";
24
- RealtimeErrorType[RealtimeErrorType["RateLimited"] = 4029] = "RateLimited";
25
- RealtimeErrorType[RealtimeErrorType["UniqueSessionViolation"] = 4030] = "UniqueSessionViolation";
26
- RealtimeErrorType[RealtimeErrorType["SessionTimeout"] = 4031] = "SessionTimeout";
27
- RealtimeErrorType[RealtimeErrorType["AudioTooShort"] = 4032] = "AudioTooShort";
28
- RealtimeErrorType[RealtimeErrorType["AudioTooLong"] = 4033] = "AudioTooLong";
29
- RealtimeErrorType[RealtimeErrorType["BadJson"] = 4100] = "BadJson";
30
- RealtimeErrorType[RealtimeErrorType["BadSchema"] = 4101] = "BadSchema";
31
- RealtimeErrorType[RealtimeErrorType["TooManyStreams"] = 4102] = "TooManyStreams";
32
- RealtimeErrorType[RealtimeErrorType["Reconnected"] = 4103] = "Reconnected";
33
- RealtimeErrorType[RealtimeErrorType["ReconnectAttemptsExhausted"] = 1013] = "ReconnectAttemptsExhausted";
34
- })(RealtimeErrorType || (RealtimeErrorType = {}));
15
+ const RealtimeErrorType = {
16
+ BadSampleRate: 4000,
17
+ AuthFailed: 4001,
18
+ /**
19
+ * @deprecated Use InsufficientFunds or FreeTierUser instead
20
+ */
21
+ InsufficientFundsOrFreeAccount: 4002,
22
+ InsufficientFunds: 4002,
23
+ FreeTierUser: 4003,
24
+ NonexistentSessionId: 4004,
25
+ SessionExpired: 4008,
26
+ ClosedSession: 4010,
27
+ RateLimited: 4029,
28
+ UniqueSessionViolation: 4030,
29
+ SessionTimeout: 4031,
30
+ AudioTooShort: 4032,
31
+ AudioTooLong: 4033,
32
+ AudioTooSmallToTranscode: 4034,
33
+ /**
34
+ * @deprecated Don't use
35
+ */
36
+ BadJson: 4100,
37
+ BadSchema: 4101,
38
+ TooManyStreams: 4102,
39
+ Reconnected: 4103,
40
+ /**
41
+ * @deprecated Don't use
42
+ */
43
+ ReconnectAttemptsExhausted: 1013,
44
+ WordBoostParameterParsingFailed: 4104,
45
+ };
35
46
  const RealtimeErrorMessages = {
36
47
  [RealtimeErrorType.BadSampleRate]: "Sample rate must be a positive integer",
37
48
  [RealtimeErrorType.AuthFailed]: "Not Authorized",
38
- [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.",
49
+ [RealtimeErrorType.InsufficientFunds]: "Insufficient funds",
50
+ [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.",
39
51
  [RealtimeErrorType.NonexistentSessionId]: "Session ID does not exist",
40
52
  [RealtimeErrorType.SessionExpired]: "Session has expired",
41
53
  [RealtimeErrorType.ClosedSession]: "Session is closed",
@@ -44,11 +56,13 @@ const RealtimeErrorMessages = {
44
56
  [RealtimeErrorType.SessionTimeout]: "Session Timeout",
45
57
  [RealtimeErrorType.AudioTooShort]: "Audio too short",
46
58
  [RealtimeErrorType.AudioTooLong]: "Audio too long",
59
+ [RealtimeErrorType.AudioTooSmallToTranscode]: "Audio too small to transcode",
47
60
  [RealtimeErrorType.BadJson]: "Bad JSON",
48
61
  [RealtimeErrorType.BadSchema]: "Bad schema",
49
62
  [RealtimeErrorType.TooManyStreams]: "Too many streams",
50
- [RealtimeErrorType.Reconnected]: "Reconnected",
63
+ [RealtimeErrorType.Reconnected]: "This session has been reconnected. This WebSocket is no longer valid.",
51
64
  [RealtimeErrorType.ReconnectAttemptsExhausted]: "Reconnect attempts exhausted",
65
+ [RealtimeErrorType.WordBoostParameterParsingFailed]: "Could not parse word boost parameter",
52
66
  };
53
67
  class RealtimeError extends Error {
54
68
  }
@@ -140,7 +154,7 @@ class RealtimeTranscriber {
140
154
  };
141
155
  this.socket.onclose = ({ code, reason }) => {
142
156
  if (!reason) {
143
- if (code in RealtimeErrorType) {
157
+ if (code in RealtimeErrorMessages) {
144
158
  reason = RealtimeErrorMessages[code];
145
159
  }
146
160
  }
@@ -42,30 +42,42 @@ const { WritableStream } = typeof window !== "undefined"
42
42
 
43
43
  const factory = (url, params) => new ws(url, params);
44
44
 
45
- var RealtimeErrorType;
46
- (function (RealtimeErrorType) {
47
- RealtimeErrorType[RealtimeErrorType["BadSampleRate"] = 4000] = "BadSampleRate";
48
- RealtimeErrorType[RealtimeErrorType["AuthFailed"] = 4001] = "AuthFailed";
49
- // Both InsufficientFunds and FreeAccount error use 4002
50
- RealtimeErrorType[RealtimeErrorType["InsufficientFundsOrFreeAccount"] = 4002] = "InsufficientFundsOrFreeAccount";
51
- RealtimeErrorType[RealtimeErrorType["NonexistentSessionId"] = 4004] = "NonexistentSessionId";
52
- RealtimeErrorType[RealtimeErrorType["SessionExpired"] = 4008] = "SessionExpired";
53
- RealtimeErrorType[RealtimeErrorType["ClosedSession"] = 4010] = "ClosedSession";
54
- RealtimeErrorType[RealtimeErrorType["RateLimited"] = 4029] = "RateLimited";
55
- RealtimeErrorType[RealtimeErrorType["UniqueSessionViolation"] = 4030] = "UniqueSessionViolation";
56
- RealtimeErrorType[RealtimeErrorType["SessionTimeout"] = 4031] = "SessionTimeout";
57
- RealtimeErrorType[RealtimeErrorType["AudioTooShort"] = 4032] = "AudioTooShort";
58
- RealtimeErrorType[RealtimeErrorType["AudioTooLong"] = 4033] = "AudioTooLong";
59
- RealtimeErrorType[RealtimeErrorType["BadJson"] = 4100] = "BadJson";
60
- RealtimeErrorType[RealtimeErrorType["BadSchema"] = 4101] = "BadSchema";
61
- RealtimeErrorType[RealtimeErrorType["TooManyStreams"] = 4102] = "TooManyStreams";
62
- RealtimeErrorType[RealtimeErrorType["Reconnected"] = 4103] = "Reconnected";
63
- RealtimeErrorType[RealtimeErrorType["ReconnectAttemptsExhausted"] = 1013] = "ReconnectAttemptsExhausted";
64
- })(RealtimeErrorType || (RealtimeErrorType = {}));
45
+ const RealtimeErrorType = {
46
+ BadSampleRate: 4000,
47
+ AuthFailed: 4001,
48
+ /**
49
+ * @deprecated Use InsufficientFunds or FreeTierUser instead
50
+ */
51
+ InsufficientFundsOrFreeAccount: 4002,
52
+ InsufficientFunds: 4002,
53
+ FreeTierUser: 4003,
54
+ NonexistentSessionId: 4004,
55
+ SessionExpired: 4008,
56
+ ClosedSession: 4010,
57
+ RateLimited: 4029,
58
+ UniqueSessionViolation: 4030,
59
+ SessionTimeout: 4031,
60
+ AudioTooShort: 4032,
61
+ AudioTooLong: 4033,
62
+ AudioTooSmallToTranscode: 4034,
63
+ /**
64
+ * @deprecated Don't use
65
+ */
66
+ BadJson: 4100,
67
+ BadSchema: 4101,
68
+ TooManyStreams: 4102,
69
+ Reconnected: 4103,
70
+ /**
71
+ * @deprecated Don't use
72
+ */
73
+ ReconnectAttemptsExhausted: 1013,
74
+ WordBoostParameterParsingFailed: 4104,
75
+ };
65
76
  const RealtimeErrorMessages = {
66
77
  [RealtimeErrorType.BadSampleRate]: "Sample rate must be a positive integer",
67
78
  [RealtimeErrorType.AuthFailed]: "Not Authorized",
68
- [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.",
79
+ [RealtimeErrorType.InsufficientFunds]: "Insufficient funds",
80
+ [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.",
69
81
  [RealtimeErrorType.NonexistentSessionId]: "Session ID does not exist",
70
82
  [RealtimeErrorType.SessionExpired]: "Session has expired",
71
83
  [RealtimeErrorType.ClosedSession]: "Session is closed",
@@ -74,11 +86,13 @@ const RealtimeErrorMessages = {
74
86
  [RealtimeErrorType.SessionTimeout]: "Session Timeout",
75
87
  [RealtimeErrorType.AudioTooShort]: "Audio too short",
76
88
  [RealtimeErrorType.AudioTooLong]: "Audio too long",
89
+ [RealtimeErrorType.AudioTooSmallToTranscode]: "Audio too small to transcode",
77
90
  [RealtimeErrorType.BadJson]: "Bad JSON",
78
91
  [RealtimeErrorType.BadSchema]: "Bad schema",
79
92
  [RealtimeErrorType.TooManyStreams]: "Too many streams",
80
- [RealtimeErrorType.Reconnected]: "Reconnected",
93
+ [RealtimeErrorType.Reconnected]: "This session has been reconnected. This WebSocket is no longer valid.",
81
94
  [RealtimeErrorType.ReconnectAttemptsExhausted]: "Reconnect attempts exhausted",
95
+ [RealtimeErrorType.WordBoostParameterParsingFailed]: "Could not parse word boost parameter",
82
96
  };
83
97
  class RealtimeError extends Error {
84
98
  }
@@ -172,7 +186,7 @@ class RealtimeTranscriber {
172
186
  this.socket.onclose = ({ code, reason }) => {
173
187
  var _a, _b;
174
188
  if (!reason) {
175
- if (code in RealtimeErrorType) {
189
+ if (code in RealtimeErrorMessages) {
176
190
  reason = RealtimeErrorMessages[code];
177
191
  }
178
192
  }
@@ -40,30 +40,42 @@ const { WritableStream } = typeof window !== "undefined"
40
40
 
41
41
  const factory = (url, params) => new ws(url, params);
42
42
 
43
- var RealtimeErrorType;
44
- (function (RealtimeErrorType) {
45
- RealtimeErrorType[RealtimeErrorType["BadSampleRate"] = 4000] = "BadSampleRate";
46
- RealtimeErrorType[RealtimeErrorType["AuthFailed"] = 4001] = "AuthFailed";
47
- // Both InsufficientFunds and FreeAccount error use 4002
48
- RealtimeErrorType[RealtimeErrorType["InsufficientFundsOrFreeAccount"] = 4002] = "InsufficientFundsOrFreeAccount";
49
- RealtimeErrorType[RealtimeErrorType["NonexistentSessionId"] = 4004] = "NonexistentSessionId";
50
- RealtimeErrorType[RealtimeErrorType["SessionExpired"] = 4008] = "SessionExpired";
51
- RealtimeErrorType[RealtimeErrorType["ClosedSession"] = 4010] = "ClosedSession";
52
- RealtimeErrorType[RealtimeErrorType["RateLimited"] = 4029] = "RateLimited";
53
- RealtimeErrorType[RealtimeErrorType["UniqueSessionViolation"] = 4030] = "UniqueSessionViolation";
54
- RealtimeErrorType[RealtimeErrorType["SessionTimeout"] = 4031] = "SessionTimeout";
55
- RealtimeErrorType[RealtimeErrorType["AudioTooShort"] = 4032] = "AudioTooShort";
56
- RealtimeErrorType[RealtimeErrorType["AudioTooLong"] = 4033] = "AudioTooLong";
57
- RealtimeErrorType[RealtimeErrorType["BadJson"] = 4100] = "BadJson";
58
- RealtimeErrorType[RealtimeErrorType["BadSchema"] = 4101] = "BadSchema";
59
- RealtimeErrorType[RealtimeErrorType["TooManyStreams"] = 4102] = "TooManyStreams";
60
- RealtimeErrorType[RealtimeErrorType["Reconnected"] = 4103] = "Reconnected";
61
- RealtimeErrorType[RealtimeErrorType["ReconnectAttemptsExhausted"] = 1013] = "ReconnectAttemptsExhausted";
62
- })(RealtimeErrorType || (RealtimeErrorType = {}));
43
+ const RealtimeErrorType = {
44
+ BadSampleRate: 4000,
45
+ AuthFailed: 4001,
46
+ /**
47
+ * @deprecated Use InsufficientFunds or FreeTierUser instead
48
+ */
49
+ InsufficientFundsOrFreeAccount: 4002,
50
+ InsufficientFunds: 4002,
51
+ FreeTierUser: 4003,
52
+ NonexistentSessionId: 4004,
53
+ SessionExpired: 4008,
54
+ ClosedSession: 4010,
55
+ RateLimited: 4029,
56
+ UniqueSessionViolation: 4030,
57
+ SessionTimeout: 4031,
58
+ AudioTooShort: 4032,
59
+ AudioTooLong: 4033,
60
+ AudioTooSmallToTranscode: 4034,
61
+ /**
62
+ * @deprecated Don't use
63
+ */
64
+ BadJson: 4100,
65
+ BadSchema: 4101,
66
+ TooManyStreams: 4102,
67
+ Reconnected: 4103,
68
+ /**
69
+ * @deprecated Don't use
70
+ */
71
+ ReconnectAttemptsExhausted: 1013,
72
+ WordBoostParameterParsingFailed: 4104,
73
+ };
63
74
  const RealtimeErrorMessages = {
64
75
  [RealtimeErrorType.BadSampleRate]: "Sample rate must be a positive integer",
65
76
  [RealtimeErrorType.AuthFailed]: "Not Authorized",
66
- [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.",
77
+ [RealtimeErrorType.InsufficientFunds]: "Insufficient funds",
78
+ [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.",
67
79
  [RealtimeErrorType.NonexistentSessionId]: "Session ID does not exist",
68
80
  [RealtimeErrorType.SessionExpired]: "Session has expired",
69
81
  [RealtimeErrorType.ClosedSession]: "Session is closed",
@@ -72,11 +84,13 @@ const RealtimeErrorMessages = {
72
84
  [RealtimeErrorType.SessionTimeout]: "Session Timeout",
73
85
  [RealtimeErrorType.AudioTooShort]: "Audio too short",
74
86
  [RealtimeErrorType.AudioTooLong]: "Audio too long",
87
+ [RealtimeErrorType.AudioTooSmallToTranscode]: "Audio too small to transcode",
75
88
  [RealtimeErrorType.BadJson]: "Bad JSON",
76
89
  [RealtimeErrorType.BadSchema]: "Bad schema",
77
90
  [RealtimeErrorType.TooManyStreams]: "Too many streams",
78
- [RealtimeErrorType.Reconnected]: "Reconnected",
91
+ [RealtimeErrorType.Reconnected]: "This session has been reconnected. This WebSocket is no longer valid.",
79
92
  [RealtimeErrorType.ReconnectAttemptsExhausted]: "Reconnect attempts exhausted",
93
+ [RealtimeErrorType.WordBoostParameterParsingFailed]: "Could not parse word boost parameter",
80
94
  };
81
95
  class RealtimeError extends Error {
82
96
  }
@@ -170,7 +184,7 @@ class RealtimeTranscriber {
170
184
  this.socket.onclose = ({ code, reason }) => {
171
185
  var _a, _b;
172
186
  if (!reason) {
173
- if (code in RealtimeErrorType) {
187
+ if (code in RealtimeErrorMessages) {
174
188
  reason = RealtimeErrorMessages[code];
175
189
  }
176
190
  }