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/CHANGELOG.md +10 -0
- package/README.internal.md +100 -0
- package/dist/assemblyai.streaming.umd.js +37 -23
- package/dist/assemblyai.streaming.umd.min.js +1 -1
- package/dist/assemblyai.umd.js +38 -34
- package/dist/assemblyai.umd.min.js +1 -1
- package/dist/browser.mjs +38 -34
- package/dist/bun.mjs +38 -34
- package/dist/deno.mjs +38 -34
- package/dist/index.cjs +38 -34
- package/dist/index.mjs +38 -34
- package/dist/node.cjs +38 -34
- package/dist/node.mjs +38 -34
- 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 +43 -23
- package/dist/utils/errors/realtime.d.ts +34 -20
- package/dist/workerd.mjs +38 -34
- package/package.json +2 -2
- package/src/services/realtime/service.ts +4 -7
- package/src/services/transcripts/index.ts +0 -13
- package/src/types/openapi.generated.ts +44 -27
- package/src/utils/errors/realtime.ts +49 -24
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.
|
|
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
|
-
|
|
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
|
}
|
|
@@ -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.
|
|
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
|
-
|
|
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
|
}
|
|
@@ -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
|
-
|
|
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
|
}
|
package/dist/streaming.mjs
CHANGED
|
@@ -40,30 +40,42 @@ const { WritableStream } = typeof window !== "undefined"
|
|
|
40
40
|
|
|
41
41
|
const factory = (url, params) => new ws(url, params);
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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.
|
|
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]: "
|
|
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
|
|
187
|
+
if (code in RealtimeErrorMessages) {
|
|
174
188
|
reason = RealtimeErrorMessages[code];
|
|
175
189
|
}
|
|
176
190
|
}
|