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/bun.mjs
CHANGED
|
@@ -17,7 +17,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
17
17
|
defaultUserAgentString += navigator.userAgent;
|
|
18
18
|
}
|
|
19
19
|
const defaultUserAgent = {
|
|
20
|
-
sdk: { name: "JavaScript", version: "4.6.
|
|
20
|
+
sdk: { name: "JavaScript", version: "4.6.2" },
|
|
21
21
|
};
|
|
22
22
|
if (typeof process !== "undefined") {
|
|
23
23
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -149,30 +149,42 @@ const { WritableStream } = typeof window !== "undefined"
|
|
|
149
149
|
|
|
150
150
|
const factory = (url, params) => new ws(url, params);
|
|
151
151
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
152
|
+
const RealtimeErrorType = {
|
|
153
|
+
BadSampleRate: 4000,
|
|
154
|
+
AuthFailed: 4001,
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated Use InsufficientFunds or FreeTierUser instead
|
|
157
|
+
*/
|
|
158
|
+
InsufficientFundsOrFreeAccount: 4002,
|
|
159
|
+
InsufficientFunds: 4002,
|
|
160
|
+
FreeTierUser: 4003,
|
|
161
|
+
NonexistentSessionId: 4004,
|
|
162
|
+
SessionExpired: 4008,
|
|
163
|
+
ClosedSession: 4010,
|
|
164
|
+
RateLimited: 4029,
|
|
165
|
+
UniqueSessionViolation: 4030,
|
|
166
|
+
SessionTimeout: 4031,
|
|
167
|
+
AudioTooShort: 4032,
|
|
168
|
+
AudioTooLong: 4033,
|
|
169
|
+
AudioTooSmallToTranscode: 4034,
|
|
170
|
+
/**
|
|
171
|
+
* @deprecated Don't use
|
|
172
|
+
*/
|
|
173
|
+
BadJson: 4100,
|
|
174
|
+
BadSchema: 4101,
|
|
175
|
+
TooManyStreams: 4102,
|
|
176
|
+
Reconnected: 4103,
|
|
177
|
+
/**
|
|
178
|
+
* @deprecated Don't use
|
|
179
|
+
*/
|
|
180
|
+
ReconnectAttemptsExhausted: 1013,
|
|
181
|
+
WordBoostParameterParsingFailed: 4104,
|
|
182
|
+
};
|
|
172
183
|
const RealtimeErrorMessages = {
|
|
173
184
|
[RealtimeErrorType.BadSampleRate]: "Sample rate must be a positive integer",
|
|
174
185
|
[RealtimeErrorType.AuthFailed]: "Not Authorized",
|
|
175
|
-
[RealtimeErrorType.
|
|
186
|
+
[RealtimeErrorType.InsufficientFunds]: "Insufficient funds",
|
|
187
|
+
[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.",
|
|
176
188
|
[RealtimeErrorType.NonexistentSessionId]: "Session ID does not exist",
|
|
177
189
|
[RealtimeErrorType.SessionExpired]: "Session has expired",
|
|
178
190
|
[RealtimeErrorType.ClosedSession]: "Session is closed",
|
|
@@ -181,11 +193,13 @@ const RealtimeErrorMessages = {
|
|
|
181
193
|
[RealtimeErrorType.SessionTimeout]: "Session Timeout",
|
|
182
194
|
[RealtimeErrorType.AudioTooShort]: "Audio too short",
|
|
183
195
|
[RealtimeErrorType.AudioTooLong]: "Audio too long",
|
|
196
|
+
[RealtimeErrorType.AudioTooSmallToTranscode]: "Audio too small to transcode",
|
|
184
197
|
[RealtimeErrorType.BadJson]: "Bad JSON",
|
|
185
198
|
[RealtimeErrorType.BadSchema]: "Bad schema",
|
|
186
199
|
[RealtimeErrorType.TooManyStreams]: "Too many streams",
|
|
187
|
-
[RealtimeErrorType.Reconnected]: "
|
|
200
|
+
[RealtimeErrorType.Reconnected]: "This session has been reconnected. This WebSocket is no longer valid.",
|
|
188
201
|
[RealtimeErrorType.ReconnectAttemptsExhausted]: "Reconnect attempts exhausted",
|
|
202
|
+
[RealtimeErrorType.WordBoostParameterParsingFailed]: "Could not parse word boost parameter",
|
|
189
203
|
};
|
|
190
204
|
class RealtimeError extends Error {
|
|
191
205
|
}
|
|
@@ -277,7 +291,7 @@ class RealtimeTranscriber {
|
|
|
277
291
|
};
|
|
278
292
|
this.socket.onclose = ({ code, reason }) => {
|
|
279
293
|
if (!reason) {
|
|
280
|
-
if (code in
|
|
294
|
+
if (code in RealtimeErrorMessages) {
|
|
281
295
|
reason = RealtimeErrorMessages[code];
|
|
282
296
|
}
|
|
283
297
|
}
|
|
@@ -460,7 +474,6 @@ class TranscriptService extends BaseService {
|
|
|
460
474
|
* @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
|
|
461
475
|
*/
|
|
462
476
|
async transcribe(params, options) {
|
|
463
|
-
deprecateConformer2(params);
|
|
464
477
|
const transcript = await this.submit(params);
|
|
465
478
|
return await this.waitUntilReady(transcript.id, options);
|
|
466
479
|
}
|
|
@@ -470,7 +483,6 @@ class TranscriptService extends BaseService {
|
|
|
470
483
|
* @returns A promise that resolves to the queued transcript.
|
|
471
484
|
*/
|
|
472
485
|
async submit(params) {
|
|
473
|
-
deprecateConformer2(params);
|
|
474
486
|
let audioUrl;
|
|
475
487
|
let transcriptParams = undefined;
|
|
476
488
|
if ("audio" in params) {
|
|
@@ -514,7 +526,6 @@ class TranscriptService extends BaseService {
|
|
|
514
526
|
* @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
|
|
515
527
|
*/
|
|
516
528
|
async create(params, options) {
|
|
517
|
-
deprecateConformer2(params);
|
|
518
529
|
const path = getPath(params.audio_url);
|
|
519
530
|
if (path !== null) {
|
|
520
531
|
const uploadUrl = await this.files.upload(path);
|
|
@@ -677,13 +688,6 @@ class TranscriptService extends BaseService {
|
|
|
677
688
|
};
|
|
678
689
|
}
|
|
679
690
|
}
|
|
680
|
-
function deprecateConformer2(params) {
|
|
681
|
-
if (!params)
|
|
682
|
-
return;
|
|
683
|
-
if (params.speech_model === "conformer-2") {
|
|
684
|
-
console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
691
|
|
|
688
692
|
const readFile = async (path) => Bun.file(path).stream();
|
|
689
693
|
|
package/dist/deno.mjs
CHANGED
|
@@ -17,7 +17,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
17
17
|
defaultUserAgentString += navigator.userAgent;
|
|
18
18
|
}
|
|
19
19
|
const defaultUserAgent = {
|
|
20
|
-
sdk: { name: "JavaScript", version: "4.6.
|
|
20
|
+
sdk: { name: "JavaScript", version: "4.6.2" },
|
|
21
21
|
};
|
|
22
22
|
if (typeof process !== "undefined") {
|
|
23
23
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -149,30 +149,42 @@ const { WritableStream } = typeof window !== "undefined"
|
|
|
149
149
|
|
|
150
150
|
const factory = (url, params) => new ws(url, params);
|
|
151
151
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
152
|
+
const RealtimeErrorType = {
|
|
153
|
+
BadSampleRate: 4000,
|
|
154
|
+
AuthFailed: 4001,
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated Use InsufficientFunds or FreeTierUser instead
|
|
157
|
+
*/
|
|
158
|
+
InsufficientFundsOrFreeAccount: 4002,
|
|
159
|
+
InsufficientFunds: 4002,
|
|
160
|
+
FreeTierUser: 4003,
|
|
161
|
+
NonexistentSessionId: 4004,
|
|
162
|
+
SessionExpired: 4008,
|
|
163
|
+
ClosedSession: 4010,
|
|
164
|
+
RateLimited: 4029,
|
|
165
|
+
UniqueSessionViolation: 4030,
|
|
166
|
+
SessionTimeout: 4031,
|
|
167
|
+
AudioTooShort: 4032,
|
|
168
|
+
AudioTooLong: 4033,
|
|
169
|
+
AudioTooSmallToTranscode: 4034,
|
|
170
|
+
/**
|
|
171
|
+
* @deprecated Don't use
|
|
172
|
+
*/
|
|
173
|
+
BadJson: 4100,
|
|
174
|
+
BadSchema: 4101,
|
|
175
|
+
TooManyStreams: 4102,
|
|
176
|
+
Reconnected: 4103,
|
|
177
|
+
/**
|
|
178
|
+
* @deprecated Don't use
|
|
179
|
+
*/
|
|
180
|
+
ReconnectAttemptsExhausted: 1013,
|
|
181
|
+
WordBoostParameterParsingFailed: 4104,
|
|
182
|
+
};
|
|
172
183
|
const RealtimeErrorMessages = {
|
|
173
184
|
[RealtimeErrorType.BadSampleRate]: "Sample rate must be a positive integer",
|
|
174
185
|
[RealtimeErrorType.AuthFailed]: "Not Authorized",
|
|
175
|
-
[RealtimeErrorType.
|
|
186
|
+
[RealtimeErrorType.InsufficientFunds]: "Insufficient funds",
|
|
187
|
+
[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.",
|
|
176
188
|
[RealtimeErrorType.NonexistentSessionId]: "Session ID does not exist",
|
|
177
189
|
[RealtimeErrorType.SessionExpired]: "Session has expired",
|
|
178
190
|
[RealtimeErrorType.ClosedSession]: "Session is closed",
|
|
@@ -181,11 +193,13 @@ const RealtimeErrorMessages = {
|
|
|
181
193
|
[RealtimeErrorType.SessionTimeout]: "Session Timeout",
|
|
182
194
|
[RealtimeErrorType.AudioTooShort]: "Audio too short",
|
|
183
195
|
[RealtimeErrorType.AudioTooLong]: "Audio too long",
|
|
196
|
+
[RealtimeErrorType.AudioTooSmallToTranscode]: "Audio too small to transcode",
|
|
184
197
|
[RealtimeErrorType.BadJson]: "Bad JSON",
|
|
185
198
|
[RealtimeErrorType.BadSchema]: "Bad schema",
|
|
186
199
|
[RealtimeErrorType.TooManyStreams]: "Too many streams",
|
|
187
|
-
[RealtimeErrorType.Reconnected]: "
|
|
200
|
+
[RealtimeErrorType.Reconnected]: "This session has been reconnected. This WebSocket is no longer valid.",
|
|
188
201
|
[RealtimeErrorType.ReconnectAttemptsExhausted]: "Reconnect attempts exhausted",
|
|
202
|
+
[RealtimeErrorType.WordBoostParameterParsingFailed]: "Could not parse word boost parameter",
|
|
189
203
|
};
|
|
190
204
|
class RealtimeError extends Error {
|
|
191
205
|
}
|
|
@@ -277,7 +291,7 @@ class RealtimeTranscriber {
|
|
|
277
291
|
};
|
|
278
292
|
this.socket.onclose = ({ code, reason }) => {
|
|
279
293
|
if (!reason) {
|
|
280
|
-
if (code in
|
|
294
|
+
if (code in RealtimeErrorMessages) {
|
|
281
295
|
reason = RealtimeErrorMessages[code];
|
|
282
296
|
}
|
|
283
297
|
}
|
|
@@ -460,7 +474,6 @@ class TranscriptService extends BaseService {
|
|
|
460
474
|
* @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
|
|
461
475
|
*/
|
|
462
476
|
async transcribe(params, options) {
|
|
463
|
-
deprecateConformer2(params);
|
|
464
477
|
const transcript = await this.submit(params);
|
|
465
478
|
return await this.waitUntilReady(transcript.id, options);
|
|
466
479
|
}
|
|
@@ -470,7 +483,6 @@ class TranscriptService extends BaseService {
|
|
|
470
483
|
* @returns A promise that resolves to the queued transcript.
|
|
471
484
|
*/
|
|
472
485
|
async submit(params) {
|
|
473
|
-
deprecateConformer2(params);
|
|
474
486
|
let audioUrl;
|
|
475
487
|
let transcriptParams = undefined;
|
|
476
488
|
if ("audio" in params) {
|
|
@@ -514,7 +526,6 @@ class TranscriptService extends BaseService {
|
|
|
514
526
|
* @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
|
|
515
527
|
*/
|
|
516
528
|
async create(params, options) {
|
|
517
|
-
deprecateConformer2(params);
|
|
518
529
|
const path = getPath(params.audio_url);
|
|
519
530
|
if (path !== null) {
|
|
520
531
|
const uploadUrl = await this.files.upload(path);
|
|
@@ -677,13 +688,6 @@ class TranscriptService extends BaseService {
|
|
|
677
688
|
};
|
|
678
689
|
}
|
|
679
690
|
}
|
|
680
|
-
function deprecateConformer2(params) {
|
|
681
|
-
if (!params)
|
|
682
|
-
return;
|
|
683
|
-
if (params.speech_model === "conformer-2") {
|
|
684
|
-
console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
691
|
|
|
688
692
|
const readFile = async (path) => (await Deno.open(path)).readable;
|
|
689
693
|
|
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.
|
|
66
|
+
sdk: { name: "JavaScript", version: "4.6.2" },
|
|
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
|
}
|
|
@@ -520,7 +534,6 @@ class TranscriptService extends BaseService {
|
|
|
520
534
|
*/
|
|
521
535
|
transcribe(params, options) {
|
|
522
536
|
return __awaiter(this, void 0, void 0, function* () {
|
|
523
|
-
deprecateConformer2(params);
|
|
524
537
|
const transcript = yield this.submit(params);
|
|
525
538
|
return yield this.waitUntilReady(transcript.id, options);
|
|
526
539
|
});
|
|
@@ -532,7 +545,6 @@ class TranscriptService extends BaseService {
|
|
|
532
545
|
*/
|
|
533
546
|
submit(params) {
|
|
534
547
|
return __awaiter(this, void 0, void 0, function* () {
|
|
535
|
-
deprecateConformer2(params);
|
|
536
548
|
let audioUrl;
|
|
537
549
|
let transcriptParams = undefined;
|
|
538
550
|
if ("audio" in params) {
|
|
@@ -579,7 +591,6 @@ class TranscriptService extends BaseService {
|
|
|
579
591
|
create(params, options) {
|
|
580
592
|
return __awaiter(this, void 0, void 0, function* () {
|
|
581
593
|
var _a;
|
|
582
|
-
deprecateConformer2(params);
|
|
583
594
|
const path = getPath(params.audio_url);
|
|
584
595
|
if (path !== null) {
|
|
585
596
|
const uploadUrl = yield this.files.upload(path);
|
|
@@ -755,13 +766,6 @@ class TranscriptService extends BaseService {
|
|
|
755
766
|
});
|
|
756
767
|
}
|
|
757
768
|
}
|
|
758
|
-
function deprecateConformer2(params) {
|
|
759
|
-
if (!params)
|
|
760
|
-
return;
|
|
761
|
-
if (params.speech_model === "conformer-2") {
|
|
762
|
-
console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
769
|
|
|
766
770
|
const readFile = function (
|
|
767
771
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
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.
|
|
64
|
+
sdk: { name: "JavaScript", version: "4.6.2" },
|
|
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
|
}
|
|
@@ -518,7 +532,6 @@ class TranscriptService extends BaseService {
|
|
|
518
532
|
*/
|
|
519
533
|
transcribe(params, options) {
|
|
520
534
|
return __awaiter(this, void 0, void 0, function* () {
|
|
521
|
-
deprecateConformer2(params);
|
|
522
535
|
const transcript = yield this.submit(params);
|
|
523
536
|
return yield this.waitUntilReady(transcript.id, options);
|
|
524
537
|
});
|
|
@@ -530,7 +543,6 @@ class TranscriptService extends BaseService {
|
|
|
530
543
|
*/
|
|
531
544
|
submit(params) {
|
|
532
545
|
return __awaiter(this, void 0, void 0, function* () {
|
|
533
|
-
deprecateConformer2(params);
|
|
534
546
|
let audioUrl;
|
|
535
547
|
let transcriptParams = undefined;
|
|
536
548
|
if ("audio" in params) {
|
|
@@ -577,7 +589,6 @@ class TranscriptService extends BaseService {
|
|
|
577
589
|
create(params, options) {
|
|
578
590
|
return __awaiter(this, void 0, void 0, function* () {
|
|
579
591
|
var _a;
|
|
580
|
-
deprecateConformer2(params);
|
|
581
592
|
const path = getPath(params.audio_url);
|
|
582
593
|
if (path !== null) {
|
|
583
594
|
const uploadUrl = yield this.files.upload(path);
|
|
@@ -753,13 +764,6 @@ class TranscriptService extends BaseService {
|
|
|
753
764
|
});
|
|
754
765
|
}
|
|
755
766
|
}
|
|
756
|
-
function deprecateConformer2(params) {
|
|
757
|
-
if (!params)
|
|
758
|
-
return;
|
|
759
|
-
if (params.speech_model === "conformer-2") {
|
|
760
|
-
console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
767
|
|
|
764
768
|
const readFile = function (
|
|
765
769
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|