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/CHANGELOG.md +17 -0
- package/dist/assemblyai.streaming.umd.js +37 -23
- package/dist/assemblyai.streaming.umd.min.js +1 -1
- package/dist/assemblyai.umd.js +38 -24
- package/dist/assemblyai.umd.min.js +1 -1
- package/dist/browser.mjs +38 -24
- package/dist/bun.mjs +38 -24
- package/dist/deno.mjs +38 -24
- package/dist/index.cjs +38 -24
- package/dist/index.mjs +38 -24
- package/dist/node.cjs +38 -24
- package/dist/node.mjs +38 -24
- package/dist/streaming.browser.mjs +37 -23
- package/dist/streaming.cjs +37 -23
- package/dist/streaming.mjs +37 -23
- package/dist/types/openapi.generated.d.ts +19 -3
- package/dist/utils/errors/realtime.d.ts +34 -20
- package/dist/workerd.mjs +38 -24
- package/package.json +1 -1
- package/src/services/realtime/service.ts +4 -7
- package/src/types/openapi.generated.ts +19 -3
- package/src/utils/errors/realtime.ts +49 -24
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.
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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.
|
|
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]: "
|
|
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
|
|
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.
|
|
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
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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.
|
|
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]: "
|
|
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
|
|
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.
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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.
|
|
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]: "
|
|
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
|
|
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.
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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.
|
|
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]: "
|
|
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
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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.
|
|
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]: "
|
|
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
|
|
157
|
+
if (code in RealtimeErrorMessages) {
|
|
144
158
|
reason = RealtimeErrorMessages[code];
|
|
145
159
|
}
|
|
146
160
|
}
|
package/dist/streaming.cjs
CHANGED
|
@@ -42,30 +42,42 @@ const { WritableStream } = typeof window !== "undefined"
|
|
|
42
42
|
|
|
43
43
|
const factory = (url, params) => new ws(url, params);
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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.
|
|
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]: "
|
|
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
|
|
189
|
+
if (code in RealtimeErrorMessages) {
|
|
176
190
|
reason = RealtimeErrorMessages[code];
|
|
177
191
|
}
|
|
178
192
|
}
|