assemblyai 4.6.1 → 4.7.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.
package/dist/index.cjs CHANGED
@@ -63,7 +63,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
63
63
  defaultUserAgentString += navigator.userAgent;
64
64
  }
65
65
  const defaultUserAgent = {
66
- sdk: { name: "JavaScript", version: "4.6.1" },
66
+ sdk: { name: "JavaScript", version: "4.7.0" },
67
67
  };
68
68
  if (typeof process !== "undefined") {
69
69
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -199,30 +199,42 @@ const { WritableStream } = typeof window !== "undefined"
199
199
 
200
200
  const factory = (url, params) => new ws(url, params);
201
201
 
202
- var RealtimeErrorType;
203
- (function (RealtimeErrorType) {
204
- RealtimeErrorType[RealtimeErrorType["BadSampleRate"] = 4000] = "BadSampleRate";
205
- RealtimeErrorType[RealtimeErrorType["AuthFailed"] = 4001] = "AuthFailed";
206
- // Both InsufficientFunds and FreeAccount error use 4002
207
- RealtimeErrorType[RealtimeErrorType["InsufficientFundsOrFreeAccount"] = 4002] = "InsufficientFundsOrFreeAccount";
208
- RealtimeErrorType[RealtimeErrorType["NonexistentSessionId"] = 4004] = "NonexistentSessionId";
209
- RealtimeErrorType[RealtimeErrorType["SessionExpired"] = 4008] = "SessionExpired";
210
- RealtimeErrorType[RealtimeErrorType["ClosedSession"] = 4010] = "ClosedSession";
211
- RealtimeErrorType[RealtimeErrorType["RateLimited"] = 4029] = "RateLimited";
212
- RealtimeErrorType[RealtimeErrorType["UniqueSessionViolation"] = 4030] = "UniqueSessionViolation";
213
- RealtimeErrorType[RealtimeErrorType["SessionTimeout"] = 4031] = "SessionTimeout";
214
- RealtimeErrorType[RealtimeErrorType["AudioTooShort"] = 4032] = "AudioTooShort";
215
- RealtimeErrorType[RealtimeErrorType["AudioTooLong"] = 4033] = "AudioTooLong";
216
- RealtimeErrorType[RealtimeErrorType["BadJson"] = 4100] = "BadJson";
217
- RealtimeErrorType[RealtimeErrorType["BadSchema"] = 4101] = "BadSchema";
218
- RealtimeErrorType[RealtimeErrorType["TooManyStreams"] = 4102] = "TooManyStreams";
219
- RealtimeErrorType[RealtimeErrorType["Reconnected"] = 4103] = "Reconnected";
220
- RealtimeErrorType[RealtimeErrorType["ReconnectAttemptsExhausted"] = 1013] = "ReconnectAttemptsExhausted";
221
- })(RealtimeErrorType || (RealtimeErrorType = {}));
202
+ const RealtimeErrorType = {
203
+ BadSampleRate: 4000,
204
+ AuthFailed: 4001,
205
+ /**
206
+ * @deprecated Use InsufficientFunds or FreeTierUser instead
207
+ */
208
+ InsufficientFundsOrFreeAccount: 4002,
209
+ InsufficientFunds: 4002,
210
+ FreeTierUser: 4003,
211
+ NonexistentSessionId: 4004,
212
+ SessionExpired: 4008,
213
+ ClosedSession: 4010,
214
+ RateLimited: 4029,
215
+ UniqueSessionViolation: 4030,
216
+ SessionTimeout: 4031,
217
+ AudioTooShort: 4032,
218
+ AudioTooLong: 4033,
219
+ AudioTooSmallToTranscode: 4034,
220
+ /**
221
+ * @deprecated Don't use
222
+ */
223
+ BadJson: 4100,
224
+ BadSchema: 4101,
225
+ TooManyStreams: 4102,
226
+ Reconnected: 4103,
227
+ /**
228
+ * @deprecated Don't use
229
+ */
230
+ ReconnectAttemptsExhausted: 1013,
231
+ WordBoostParameterParsingFailed: 4104,
232
+ };
222
233
  const RealtimeErrorMessages = {
223
234
  [RealtimeErrorType.BadSampleRate]: "Sample rate must be a positive integer",
224
235
  [RealtimeErrorType.AuthFailed]: "Not Authorized",
225
- [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.",
236
+ [RealtimeErrorType.InsufficientFunds]: "Insufficient funds",
237
+ [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.",
226
238
  [RealtimeErrorType.NonexistentSessionId]: "Session ID does not exist",
227
239
  [RealtimeErrorType.SessionExpired]: "Session has expired",
228
240
  [RealtimeErrorType.ClosedSession]: "Session is closed",
@@ -231,11 +243,13 @@ const RealtimeErrorMessages = {
231
243
  [RealtimeErrorType.SessionTimeout]: "Session Timeout",
232
244
  [RealtimeErrorType.AudioTooShort]: "Audio too short",
233
245
  [RealtimeErrorType.AudioTooLong]: "Audio too long",
246
+ [RealtimeErrorType.AudioTooSmallToTranscode]: "Audio too small to transcode",
234
247
  [RealtimeErrorType.BadJson]: "Bad JSON",
235
248
  [RealtimeErrorType.BadSchema]: "Bad schema",
236
249
  [RealtimeErrorType.TooManyStreams]: "Too many streams",
237
- [RealtimeErrorType.Reconnected]: "Reconnected",
250
+ [RealtimeErrorType.Reconnected]: "This session has been reconnected. This WebSocket is no longer valid.",
238
251
  [RealtimeErrorType.ReconnectAttemptsExhausted]: "Reconnect attempts exhausted",
252
+ [RealtimeErrorType.WordBoostParameterParsingFailed]: "Could not parse word boost parameter",
239
253
  };
240
254
  class RealtimeError extends Error {
241
255
  }
@@ -329,7 +343,7 @@ class RealtimeTranscriber {
329
343
  this.socket.onclose = ({ code, reason }) => {
330
344
  var _a, _b;
331
345
  if (!reason) {
332
- if (code in RealtimeErrorType) {
346
+ if (code in RealtimeErrorMessages) {
333
347
  reason = RealtimeErrorMessages[code];
334
348
  }
335
349
  }
package/dist/index.mjs CHANGED
@@ -61,7 +61,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
61
61
  defaultUserAgentString += navigator.userAgent;
62
62
  }
63
63
  const defaultUserAgent = {
64
- sdk: { name: "JavaScript", version: "4.6.1" },
64
+ sdk: { name: "JavaScript", version: "4.7.0" },
65
65
  };
66
66
  if (typeof process !== "undefined") {
67
67
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -197,30 +197,42 @@ const { WritableStream } = typeof window !== "undefined"
197
197
 
198
198
  const factory = (url, params) => new ws(url, params);
199
199
 
200
- var RealtimeErrorType;
201
- (function (RealtimeErrorType) {
202
- RealtimeErrorType[RealtimeErrorType["BadSampleRate"] = 4000] = "BadSampleRate";
203
- RealtimeErrorType[RealtimeErrorType["AuthFailed"] = 4001] = "AuthFailed";
204
- // Both InsufficientFunds and FreeAccount error use 4002
205
- RealtimeErrorType[RealtimeErrorType["InsufficientFundsOrFreeAccount"] = 4002] = "InsufficientFundsOrFreeAccount";
206
- RealtimeErrorType[RealtimeErrorType["NonexistentSessionId"] = 4004] = "NonexistentSessionId";
207
- RealtimeErrorType[RealtimeErrorType["SessionExpired"] = 4008] = "SessionExpired";
208
- RealtimeErrorType[RealtimeErrorType["ClosedSession"] = 4010] = "ClosedSession";
209
- RealtimeErrorType[RealtimeErrorType["RateLimited"] = 4029] = "RateLimited";
210
- RealtimeErrorType[RealtimeErrorType["UniqueSessionViolation"] = 4030] = "UniqueSessionViolation";
211
- RealtimeErrorType[RealtimeErrorType["SessionTimeout"] = 4031] = "SessionTimeout";
212
- RealtimeErrorType[RealtimeErrorType["AudioTooShort"] = 4032] = "AudioTooShort";
213
- RealtimeErrorType[RealtimeErrorType["AudioTooLong"] = 4033] = "AudioTooLong";
214
- RealtimeErrorType[RealtimeErrorType["BadJson"] = 4100] = "BadJson";
215
- RealtimeErrorType[RealtimeErrorType["BadSchema"] = 4101] = "BadSchema";
216
- RealtimeErrorType[RealtimeErrorType["TooManyStreams"] = 4102] = "TooManyStreams";
217
- RealtimeErrorType[RealtimeErrorType["Reconnected"] = 4103] = "Reconnected";
218
- RealtimeErrorType[RealtimeErrorType["ReconnectAttemptsExhausted"] = 1013] = "ReconnectAttemptsExhausted";
219
- })(RealtimeErrorType || (RealtimeErrorType = {}));
200
+ const RealtimeErrorType = {
201
+ BadSampleRate: 4000,
202
+ AuthFailed: 4001,
203
+ /**
204
+ * @deprecated Use InsufficientFunds or FreeTierUser instead
205
+ */
206
+ InsufficientFundsOrFreeAccount: 4002,
207
+ InsufficientFunds: 4002,
208
+ FreeTierUser: 4003,
209
+ NonexistentSessionId: 4004,
210
+ SessionExpired: 4008,
211
+ ClosedSession: 4010,
212
+ RateLimited: 4029,
213
+ UniqueSessionViolation: 4030,
214
+ SessionTimeout: 4031,
215
+ AudioTooShort: 4032,
216
+ AudioTooLong: 4033,
217
+ AudioTooSmallToTranscode: 4034,
218
+ /**
219
+ * @deprecated Don't use
220
+ */
221
+ BadJson: 4100,
222
+ BadSchema: 4101,
223
+ TooManyStreams: 4102,
224
+ Reconnected: 4103,
225
+ /**
226
+ * @deprecated Don't use
227
+ */
228
+ ReconnectAttemptsExhausted: 1013,
229
+ WordBoostParameterParsingFailed: 4104,
230
+ };
220
231
  const RealtimeErrorMessages = {
221
232
  [RealtimeErrorType.BadSampleRate]: "Sample rate must be a positive integer",
222
233
  [RealtimeErrorType.AuthFailed]: "Not Authorized",
223
- [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.",
234
+ [RealtimeErrorType.InsufficientFunds]: "Insufficient funds",
235
+ [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.",
224
236
  [RealtimeErrorType.NonexistentSessionId]: "Session ID does not exist",
225
237
  [RealtimeErrorType.SessionExpired]: "Session has expired",
226
238
  [RealtimeErrorType.ClosedSession]: "Session is closed",
@@ -229,11 +241,13 @@ const RealtimeErrorMessages = {
229
241
  [RealtimeErrorType.SessionTimeout]: "Session Timeout",
230
242
  [RealtimeErrorType.AudioTooShort]: "Audio too short",
231
243
  [RealtimeErrorType.AudioTooLong]: "Audio too long",
244
+ [RealtimeErrorType.AudioTooSmallToTranscode]: "Audio too small to transcode",
232
245
  [RealtimeErrorType.BadJson]: "Bad JSON",
233
246
  [RealtimeErrorType.BadSchema]: "Bad schema",
234
247
  [RealtimeErrorType.TooManyStreams]: "Too many streams",
235
- [RealtimeErrorType.Reconnected]: "Reconnected",
248
+ [RealtimeErrorType.Reconnected]: "This session has been reconnected. This WebSocket is no longer valid.",
236
249
  [RealtimeErrorType.ReconnectAttemptsExhausted]: "Reconnect attempts exhausted",
250
+ [RealtimeErrorType.WordBoostParameterParsingFailed]: "Could not parse word boost parameter",
237
251
  };
238
252
  class RealtimeError extends Error {
239
253
  }
@@ -327,7 +341,7 @@ class RealtimeTranscriber {
327
341
  this.socket.onclose = ({ code, reason }) => {
328
342
  var _a, _b;
329
343
  if (!reason) {
330
- if (code in RealtimeErrorType) {
344
+ if (code in RealtimeErrorMessages) {
331
345
  reason = RealtimeErrorMessages[code];
332
346
  }
333
347
  }
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.1" },
25
+ sdk: { name: "JavaScript", version: "4.7.0" },
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
  }
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.1" },
23
+ sdk: { name: "JavaScript", version: "4.7.0" },
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
  }
@@ -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
  }