assemblyai 4.4.0 → 4.5.0-beta.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 +14 -2
- package/dist/assemblyai.umd.js +15 -24
- package/dist/assemblyai.umd.min.js +1 -1
- package/dist/browser.mjs +614 -0
- package/dist/bun.mjs +9 -10
- package/dist/deno.mjs +9 -10
- package/dist/index.cjs +10 -10
- package/dist/index.mjs +10 -10
- package/dist/node.cjs +9 -10
- package/dist/node.mjs +9 -10
- package/dist/polyfills/websocket/browser.d.ts +3 -0
- package/dist/polyfills/websocket/default.d.ts +3 -0
- package/dist/polyfills/websocket/index.d.ts +27 -0
- package/dist/services/realtime/service.d.ts +0 -1
- package/dist/types/realtime/index.d.ts +4 -2
- package/package.json +8 -12
- package/src/polyfills/websocket/browser.ts +18 -0
- package/src/polyfills/websocket/default.ts +8 -0
- package/src/polyfills/websocket/index.ts +41 -0
- package/src/services/realtime/service.ts +18 -20
- package/src/types/realtime/index.ts +4 -2
- package/src/polyfills/ws/browser.mjs +0 -15
- package/src/polyfills/ws/index.cjs +0 -1
- package/src/polyfills/ws/index.d.ts +0 -2
- package/src/polyfills/ws/index.mjs +0 -2
package/dist/deno.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ws from 'ws';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Base class for services that communicate with the API.
|
|
@@ -88,6 +88,8 @@ const { WritableStream } = typeof window !== "undefined"
|
|
|
88
88
|
? global
|
|
89
89
|
: globalThis;
|
|
90
90
|
|
|
91
|
+
const factory = (url, params) => new ws(url, params);
|
|
92
|
+
|
|
91
93
|
var RealtimeErrorType;
|
|
92
94
|
(function (RealtimeErrorType) {
|
|
93
95
|
RealtimeErrorType[RealtimeErrorType["BadSampleRate"] = 4000] = "BadSampleRate";
|
|
@@ -140,7 +142,6 @@ class RealtimeTranscriber {
|
|
|
140
142
|
this.wordBoost = params.wordBoost;
|
|
141
143
|
this.encoding = params.encoding;
|
|
142
144
|
this.endUtteranceSilenceThreshold = params.endUtteranceSilenceThreshold;
|
|
143
|
-
this.enableExtraSessionInformation = params.enableExtraSessionInformation;
|
|
144
145
|
this.disablePartialTranscripts = params.disablePartialTranscripts;
|
|
145
146
|
if ("token" in params && params.token)
|
|
146
147
|
this.token = params.token;
|
|
@@ -166,9 +167,7 @@ class RealtimeTranscriber {
|
|
|
166
167
|
if (this.encoding) {
|
|
167
168
|
searchParams.set("encoding", this.encoding);
|
|
168
169
|
}
|
|
169
|
-
|
|
170
|
-
searchParams.set("enable_extra_session_information", this.enableExtraSessionInformation.toString());
|
|
171
|
-
}
|
|
170
|
+
searchParams.set("enable_extra_session_information", "true");
|
|
172
171
|
if (this.disablePartialTranscripts) {
|
|
173
172
|
searchParams.set("disable_partial_transcripts", this.disablePartialTranscripts.toString());
|
|
174
173
|
}
|
|
@@ -186,10 +185,10 @@ class RealtimeTranscriber {
|
|
|
186
185
|
}
|
|
187
186
|
const url = this.connectionUrl();
|
|
188
187
|
if (this.token) {
|
|
189
|
-
this.socket =
|
|
188
|
+
this.socket = factory(url.toString());
|
|
190
189
|
}
|
|
191
190
|
else {
|
|
192
|
-
this.socket =
|
|
191
|
+
this.socket = factory(url.toString(), {
|
|
193
192
|
headers: { Authorization: this.apiKey },
|
|
194
193
|
});
|
|
195
194
|
}
|
|
@@ -282,14 +281,14 @@ class RealtimeTranscriber {
|
|
|
282
281
|
this.send(`{"end_utterance_silence_threshold":${threshold}}`);
|
|
283
282
|
}
|
|
284
283
|
send(data) {
|
|
285
|
-
if (!this.socket || this.socket.readyState !==
|
|
284
|
+
if (!this.socket || this.socket.readyState !== this.socket.OPEN) {
|
|
286
285
|
throw new Error("Socket is not open for communication");
|
|
287
286
|
}
|
|
288
287
|
this.socket.send(data);
|
|
289
288
|
}
|
|
290
289
|
async close(waitForSessionTermination = true) {
|
|
291
290
|
if (this.socket) {
|
|
292
|
-
if (this.socket.readyState ===
|
|
291
|
+
if (this.socket.readyState === this.socket.OPEN) {
|
|
293
292
|
if (waitForSessionTermination) {
|
|
294
293
|
const sessionTerminatedPromise = new Promise((resolve) => {
|
|
295
294
|
this.sessionTerminatedResolve = resolve;
|
|
@@ -301,7 +300,7 @@ class RealtimeTranscriber {
|
|
|
301
300
|
this.socket.send(terminateSessionMessage);
|
|
302
301
|
}
|
|
303
302
|
}
|
|
304
|
-
if (
|
|
303
|
+
if (this.socket?.removeAllListeners)
|
|
305
304
|
this.socket.removeAllListeners();
|
|
306
305
|
this.socket.close();
|
|
307
306
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var ws = require('ws');
|
|
4
4
|
|
|
5
5
|
/******************************************************************************
|
|
6
6
|
Copyright (c) Microsoft Corporation.
|
|
@@ -135,6 +135,8 @@ const { WritableStream } = typeof window !== "undefined"
|
|
|
135
135
|
? global
|
|
136
136
|
: globalThis;
|
|
137
137
|
|
|
138
|
+
const factory = (url, params) => new ws(url, params);
|
|
139
|
+
|
|
138
140
|
var RealtimeErrorType;
|
|
139
141
|
(function (RealtimeErrorType) {
|
|
140
142
|
RealtimeErrorType[RealtimeErrorType["BadSampleRate"] = 4000] = "BadSampleRate";
|
|
@@ -188,7 +190,6 @@ class RealtimeTranscriber {
|
|
|
188
190
|
this.wordBoost = params.wordBoost;
|
|
189
191
|
this.encoding = params.encoding;
|
|
190
192
|
this.endUtteranceSilenceThreshold = params.endUtteranceSilenceThreshold;
|
|
191
|
-
this.enableExtraSessionInformation = params.enableExtraSessionInformation;
|
|
192
193
|
this.disablePartialTranscripts = params.disablePartialTranscripts;
|
|
193
194
|
if ("token" in params && params.token)
|
|
194
195
|
this.token = params.token;
|
|
@@ -214,9 +215,7 @@ class RealtimeTranscriber {
|
|
|
214
215
|
if (this.encoding) {
|
|
215
216
|
searchParams.set("encoding", this.encoding);
|
|
216
217
|
}
|
|
217
|
-
|
|
218
|
-
searchParams.set("enable_extra_session_information", this.enableExtraSessionInformation.toString());
|
|
219
|
-
}
|
|
218
|
+
searchParams.set("enable_extra_session_information", "true");
|
|
220
219
|
if (this.disablePartialTranscripts) {
|
|
221
220
|
searchParams.set("disable_partial_transcripts", this.disablePartialTranscripts.toString());
|
|
222
221
|
}
|
|
@@ -234,10 +233,10 @@ class RealtimeTranscriber {
|
|
|
234
233
|
}
|
|
235
234
|
const url = this.connectionUrl();
|
|
236
235
|
if (this.token) {
|
|
237
|
-
this.socket =
|
|
236
|
+
this.socket = factory(url.toString());
|
|
238
237
|
}
|
|
239
238
|
else {
|
|
240
|
-
this.socket =
|
|
239
|
+
this.socket = factory(url.toString(), {
|
|
241
240
|
headers: { Authorization: this.apiKey },
|
|
242
241
|
});
|
|
243
242
|
}
|
|
@@ -333,15 +332,16 @@ class RealtimeTranscriber {
|
|
|
333
332
|
this.send(`{"end_utterance_silence_threshold":${threshold}}`);
|
|
334
333
|
}
|
|
335
334
|
send(data) {
|
|
336
|
-
if (!this.socket || this.socket.readyState !==
|
|
335
|
+
if (!this.socket || this.socket.readyState !== this.socket.OPEN) {
|
|
337
336
|
throw new Error("Socket is not open for communication");
|
|
338
337
|
}
|
|
339
338
|
this.socket.send(data);
|
|
340
339
|
}
|
|
341
340
|
close() {
|
|
342
341
|
return __awaiter(this, arguments, void 0, function* (waitForSessionTermination = true) {
|
|
342
|
+
var _a;
|
|
343
343
|
if (this.socket) {
|
|
344
|
-
if (this.socket.readyState ===
|
|
344
|
+
if (this.socket.readyState === this.socket.OPEN) {
|
|
345
345
|
if (waitForSessionTermination) {
|
|
346
346
|
const sessionTerminatedPromise = new Promise((resolve) => {
|
|
347
347
|
this.sessionTerminatedResolve = resolve;
|
|
@@ -353,7 +353,7 @@ class RealtimeTranscriber {
|
|
|
353
353
|
this.socket.send(terminateSessionMessage);
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
|
-
if (
|
|
356
|
+
if ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.removeAllListeners)
|
|
357
357
|
this.socket.removeAllListeners();
|
|
358
358
|
this.socket.close();
|
|
359
359
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ws from 'ws';
|
|
2
2
|
|
|
3
3
|
/******************************************************************************
|
|
4
4
|
Copyright (c) Microsoft Corporation.
|
|
@@ -133,6 +133,8 @@ const { WritableStream } = typeof window !== "undefined"
|
|
|
133
133
|
? global
|
|
134
134
|
: globalThis;
|
|
135
135
|
|
|
136
|
+
const factory = (url, params) => new ws(url, params);
|
|
137
|
+
|
|
136
138
|
var RealtimeErrorType;
|
|
137
139
|
(function (RealtimeErrorType) {
|
|
138
140
|
RealtimeErrorType[RealtimeErrorType["BadSampleRate"] = 4000] = "BadSampleRate";
|
|
@@ -186,7 +188,6 @@ class RealtimeTranscriber {
|
|
|
186
188
|
this.wordBoost = params.wordBoost;
|
|
187
189
|
this.encoding = params.encoding;
|
|
188
190
|
this.endUtteranceSilenceThreshold = params.endUtteranceSilenceThreshold;
|
|
189
|
-
this.enableExtraSessionInformation = params.enableExtraSessionInformation;
|
|
190
191
|
this.disablePartialTranscripts = params.disablePartialTranscripts;
|
|
191
192
|
if ("token" in params && params.token)
|
|
192
193
|
this.token = params.token;
|
|
@@ -212,9 +213,7 @@ class RealtimeTranscriber {
|
|
|
212
213
|
if (this.encoding) {
|
|
213
214
|
searchParams.set("encoding", this.encoding);
|
|
214
215
|
}
|
|
215
|
-
|
|
216
|
-
searchParams.set("enable_extra_session_information", this.enableExtraSessionInformation.toString());
|
|
217
|
-
}
|
|
216
|
+
searchParams.set("enable_extra_session_information", "true");
|
|
218
217
|
if (this.disablePartialTranscripts) {
|
|
219
218
|
searchParams.set("disable_partial_transcripts", this.disablePartialTranscripts.toString());
|
|
220
219
|
}
|
|
@@ -232,10 +231,10 @@ class RealtimeTranscriber {
|
|
|
232
231
|
}
|
|
233
232
|
const url = this.connectionUrl();
|
|
234
233
|
if (this.token) {
|
|
235
|
-
this.socket =
|
|
234
|
+
this.socket = factory(url.toString());
|
|
236
235
|
}
|
|
237
236
|
else {
|
|
238
|
-
this.socket =
|
|
237
|
+
this.socket = factory(url.toString(), {
|
|
239
238
|
headers: { Authorization: this.apiKey },
|
|
240
239
|
});
|
|
241
240
|
}
|
|
@@ -331,15 +330,16 @@ class RealtimeTranscriber {
|
|
|
331
330
|
this.send(`{"end_utterance_silence_threshold":${threshold}}`);
|
|
332
331
|
}
|
|
333
332
|
send(data) {
|
|
334
|
-
if (!this.socket || this.socket.readyState !==
|
|
333
|
+
if (!this.socket || this.socket.readyState !== this.socket.OPEN) {
|
|
335
334
|
throw new Error("Socket is not open for communication");
|
|
336
335
|
}
|
|
337
336
|
this.socket.send(data);
|
|
338
337
|
}
|
|
339
338
|
close() {
|
|
340
339
|
return __awaiter(this, arguments, void 0, function* (waitForSessionTermination = true) {
|
|
340
|
+
var _a;
|
|
341
341
|
if (this.socket) {
|
|
342
|
-
if (this.socket.readyState ===
|
|
342
|
+
if (this.socket.readyState === this.socket.OPEN) {
|
|
343
343
|
if (waitForSessionTermination) {
|
|
344
344
|
const sessionTerminatedPromise = new Promise((resolve) => {
|
|
345
345
|
this.sessionTerminatedResolve = resolve;
|
|
@@ -351,7 +351,7 @@ class RealtimeTranscriber {
|
|
|
351
351
|
this.socket.send(terminateSessionMessage);
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
|
-
if (
|
|
354
|
+
if ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.removeAllListeners)
|
|
355
355
|
this.socket.removeAllListeners();
|
|
356
356
|
this.socket.close();
|
|
357
357
|
}
|
package/dist/node.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var web = require('stream/web');
|
|
4
|
-
var
|
|
4
|
+
var ws = require('ws');
|
|
5
5
|
var fs = require('fs');
|
|
6
6
|
var stream = require('stream');
|
|
7
7
|
|
|
@@ -87,6 +87,8 @@ class LemurService extends BaseService {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
const factory = (url, params) => new ws(url, params);
|
|
91
|
+
|
|
90
92
|
var RealtimeErrorType;
|
|
91
93
|
(function (RealtimeErrorType) {
|
|
92
94
|
RealtimeErrorType[RealtimeErrorType["BadSampleRate"] = 4000] = "BadSampleRate";
|
|
@@ -139,7 +141,6 @@ class RealtimeTranscriber {
|
|
|
139
141
|
this.wordBoost = params.wordBoost;
|
|
140
142
|
this.encoding = params.encoding;
|
|
141
143
|
this.endUtteranceSilenceThreshold = params.endUtteranceSilenceThreshold;
|
|
142
|
-
this.enableExtraSessionInformation = params.enableExtraSessionInformation;
|
|
143
144
|
this.disablePartialTranscripts = params.disablePartialTranscripts;
|
|
144
145
|
if ("token" in params && params.token)
|
|
145
146
|
this.token = params.token;
|
|
@@ -165,9 +166,7 @@ class RealtimeTranscriber {
|
|
|
165
166
|
if (this.encoding) {
|
|
166
167
|
searchParams.set("encoding", this.encoding);
|
|
167
168
|
}
|
|
168
|
-
|
|
169
|
-
searchParams.set("enable_extra_session_information", this.enableExtraSessionInformation.toString());
|
|
170
|
-
}
|
|
169
|
+
searchParams.set("enable_extra_session_information", "true");
|
|
171
170
|
if (this.disablePartialTranscripts) {
|
|
172
171
|
searchParams.set("disable_partial_transcripts", this.disablePartialTranscripts.toString());
|
|
173
172
|
}
|
|
@@ -185,10 +184,10 @@ class RealtimeTranscriber {
|
|
|
185
184
|
}
|
|
186
185
|
const url = this.connectionUrl();
|
|
187
186
|
if (this.token) {
|
|
188
|
-
this.socket =
|
|
187
|
+
this.socket = factory(url.toString());
|
|
189
188
|
}
|
|
190
189
|
else {
|
|
191
|
-
this.socket =
|
|
190
|
+
this.socket = factory(url.toString(), {
|
|
192
191
|
headers: { Authorization: this.apiKey },
|
|
193
192
|
});
|
|
194
193
|
}
|
|
@@ -281,14 +280,14 @@ class RealtimeTranscriber {
|
|
|
281
280
|
this.send(`{"end_utterance_silence_threshold":${threshold}}`);
|
|
282
281
|
}
|
|
283
282
|
send(data) {
|
|
284
|
-
if (!this.socket || this.socket.readyState !==
|
|
283
|
+
if (!this.socket || this.socket.readyState !== this.socket.OPEN) {
|
|
285
284
|
throw new Error("Socket is not open for communication");
|
|
286
285
|
}
|
|
287
286
|
this.socket.send(data);
|
|
288
287
|
}
|
|
289
288
|
async close(waitForSessionTermination = true) {
|
|
290
289
|
if (this.socket) {
|
|
291
|
-
if (this.socket.readyState ===
|
|
290
|
+
if (this.socket.readyState === this.socket.OPEN) {
|
|
292
291
|
if (waitForSessionTermination) {
|
|
293
292
|
const sessionTerminatedPromise = new Promise((resolve) => {
|
|
294
293
|
this.sessionTerminatedResolve = resolve;
|
|
@@ -300,7 +299,7 @@ class RealtimeTranscriber {
|
|
|
300
299
|
this.socket.send(terminateSessionMessage);
|
|
301
300
|
}
|
|
302
301
|
}
|
|
303
|
-
if (
|
|
302
|
+
if (this.socket?.removeAllListeners)
|
|
304
303
|
this.socket.removeAllListeners();
|
|
305
304
|
this.socket.close();
|
|
306
305
|
}
|
package/dist/node.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WritableStream } from 'stream/web';
|
|
2
|
-
import
|
|
2
|
+
import ws from 'ws';
|
|
3
3
|
import { createReadStream } from 'fs';
|
|
4
4
|
import { Readable } from 'stream';
|
|
5
5
|
|
|
@@ -85,6 +85,8 @@ class LemurService extends BaseService {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
const factory = (url, params) => new ws(url, params);
|
|
89
|
+
|
|
88
90
|
var RealtimeErrorType;
|
|
89
91
|
(function (RealtimeErrorType) {
|
|
90
92
|
RealtimeErrorType[RealtimeErrorType["BadSampleRate"] = 4000] = "BadSampleRate";
|
|
@@ -137,7 +139,6 @@ class RealtimeTranscriber {
|
|
|
137
139
|
this.wordBoost = params.wordBoost;
|
|
138
140
|
this.encoding = params.encoding;
|
|
139
141
|
this.endUtteranceSilenceThreshold = params.endUtteranceSilenceThreshold;
|
|
140
|
-
this.enableExtraSessionInformation = params.enableExtraSessionInformation;
|
|
141
142
|
this.disablePartialTranscripts = params.disablePartialTranscripts;
|
|
142
143
|
if ("token" in params && params.token)
|
|
143
144
|
this.token = params.token;
|
|
@@ -163,9 +164,7 @@ class RealtimeTranscriber {
|
|
|
163
164
|
if (this.encoding) {
|
|
164
165
|
searchParams.set("encoding", this.encoding);
|
|
165
166
|
}
|
|
166
|
-
|
|
167
|
-
searchParams.set("enable_extra_session_information", this.enableExtraSessionInformation.toString());
|
|
168
|
-
}
|
|
167
|
+
searchParams.set("enable_extra_session_information", "true");
|
|
169
168
|
if (this.disablePartialTranscripts) {
|
|
170
169
|
searchParams.set("disable_partial_transcripts", this.disablePartialTranscripts.toString());
|
|
171
170
|
}
|
|
@@ -183,10 +182,10 @@ class RealtimeTranscriber {
|
|
|
183
182
|
}
|
|
184
183
|
const url = this.connectionUrl();
|
|
185
184
|
if (this.token) {
|
|
186
|
-
this.socket =
|
|
185
|
+
this.socket = factory(url.toString());
|
|
187
186
|
}
|
|
188
187
|
else {
|
|
189
|
-
this.socket =
|
|
188
|
+
this.socket = factory(url.toString(), {
|
|
190
189
|
headers: { Authorization: this.apiKey },
|
|
191
190
|
});
|
|
192
191
|
}
|
|
@@ -279,14 +278,14 @@ class RealtimeTranscriber {
|
|
|
279
278
|
this.send(`{"end_utterance_silence_threshold":${threshold}}`);
|
|
280
279
|
}
|
|
281
280
|
send(data) {
|
|
282
|
-
if (!this.socket || this.socket.readyState !==
|
|
281
|
+
if (!this.socket || this.socket.readyState !== this.socket.OPEN) {
|
|
283
282
|
throw new Error("Socket is not open for communication");
|
|
284
283
|
}
|
|
285
284
|
this.socket.send(data);
|
|
286
285
|
}
|
|
287
286
|
async close(waitForSessionTermination = true) {
|
|
288
287
|
if (this.socket) {
|
|
289
|
-
if (this.socket.readyState ===
|
|
288
|
+
if (this.socket.readyState === this.socket.OPEN) {
|
|
290
289
|
if (waitForSessionTermination) {
|
|
291
290
|
const sessionTerminatedPromise = new Promise((resolve) => {
|
|
292
291
|
this.sessionTerminatedResolve = resolve;
|
|
@@ -298,7 +297,7 @@ class RealtimeTranscriber {
|
|
|
298
297
|
this.socket.send(terminateSessionMessage);
|
|
299
298
|
}
|
|
300
299
|
}
|
|
301
|
-
if (
|
|
300
|
+
if (this.socket?.removeAllListeners)
|
|
302
301
|
this.socket.removeAllListeners();
|
|
303
302
|
this.socket.close();
|
|
304
303
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import ws, { Event, ErrorEvent, CloseEvent, MessageEvent } from "ws";
|
|
3
|
+
export type PolyfillWebSocket = {
|
|
4
|
+
OPEN: typeof ws.OPEN;
|
|
5
|
+
binaryType: string;
|
|
6
|
+
onopen: ((event: Event) => void) | null;
|
|
7
|
+
onerror: ((event: ErrorEvent) => void) | null;
|
|
8
|
+
onclose: ((event: CloseEvent) => void) | null;
|
|
9
|
+
onmessage: ((event: MessageEvent) => void) | null;
|
|
10
|
+
readonly readyState: typeof ws.CONNECTING | typeof ws.OPEN | typeof ws.CLOSING | typeof ws.CLOSED;
|
|
11
|
+
removeAllListeners?: () => void;
|
|
12
|
+
send(data: string | number | Buffer | DataView | ArrayBufferView | Uint8Array | ArrayBuffer | SharedArrayBuffer | readonly unknown[] | readonly number[] | {
|
|
13
|
+
valueOf(): ArrayBuffer;
|
|
14
|
+
} | {
|
|
15
|
+
valueOf(): SharedArrayBuffer;
|
|
16
|
+
} | {
|
|
17
|
+
valueOf(): Uint8Array;
|
|
18
|
+
} | {
|
|
19
|
+
valueOf(): readonly number[];
|
|
20
|
+
} | {
|
|
21
|
+
valueOf(): string;
|
|
22
|
+
} | {
|
|
23
|
+
[Symbol.toPrimitive](hint: string): string;
|
|
24
|
+
}): unknown;
|
|
25
|
+
close(): unknown;
|
|
26
|
+
};
|
|
27
|
+
export type PolyfillWebSocketFactory = (url: string, params?: unknown) => PolyfillWebSocket;
|
|
@@ -29,7 +29,8 @@ type CreateRealtimeTranscriberParams = {
|
|
|
29
29
|
/**
|
|
30
30
|
* Enable extra session information.
|
|
31
31
|
* Set to `true` to receive the `session_information` message before the session ends. Defaults to `false`.
|
|
32
|
-
* @defaultValue
|
|
32
|
+
* @defaultValue true
|
|
33
|
+
* @deprecated This parameter is now ignored and will be removed. Session information will always be sent.
|
|
33
34
|
*/
|
|
34
35
|
enableExtraSessionInformation?: boolean;
|
|
35
36
|
} & ({
|
|
@@ -78,7 +79,8 @@ type RealtimeTranscriberParams = {
|
|
|
78
79
|
/**
|
|
79
80
|
* Enable extra session information.
|
|
80
81
|
* Set to `true` to receive the `session_information` message before the session ends. Defaults to `false`.
|
|
81
|
-
* @defaultValue
|
|
82
|
+
* @defaultValue true
|
|
83
|
+
* @deprecated This parameter is now ignored and will be removed. Session information will always be sent.
|
|
82
84
|
*/
|
|
83
85
|
enableExtraSessionInformation?: boolean;
|
|
84
86
|
} & ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assemblyai",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0-beta.0",
|
|
4
4
|
"description": "The AssemblyAI JavaScript SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async and real-time transcription, as well as the latest LeMUR models.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"default": "./dist/deno.mjs"
|
|
18
18
|
},
|
|
19
19
|
"workerd": "./dist/index.mjs",
|
|
20
|
-
"browser": "./dist/
|
|
20
|
+
"browser": "./dist/browser.mjs",
|
|
21
21
|
"node": {
|
|
22
22
|
"types": "./dist/index.d.ts",
|
|
23
23
|
"import": "./dist/node.mjs",
|
|
@@ -40,14 +40,10 @@
|
|
|
40
40
|
"node": "./src/polyfills/streams/node.ts",
|
|
41
41
|
"default": "./src/polyfills/streams/index.ts"
|
|
42
42
|
},
|
|
43
|
-
"#
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"default":
|
|
47
|
-
"types": "./src/polyfills/ws/index.d.ts",
|
|
48
|
-
"import": "./src/polyfills/ws/index.mjs",
|
|
49
|
-
"require": "./src/polyfills/ws/index.cjs"
|
|
50
|
-
}
|
|
43
|
+
"#websocket": {
|
|
44
|
+
"browser": "./src/polyfills/websocket/browser.ts",
|
|
45
|
+
"node": "./src/polyfills/websocket/default.ts",
|
|
46
|
+
"default": "./src/polyfills/websocket/default.ts"
|
|
51
47
|
}
|
|
52
48
|
},
|
|
53
49
|
"type": "commonjs",
|
|
@@ -61,7 +57,7 @@
|
|
|
61
57
|
"url": "git+https://github.com/AssemblyAI/assemblyai-node-sdk.git"
|
|
62
58
|
},
|
|
63
59
|
"publishConfig": {
|
|
64
|
-
"tag": "
|
|
60
|
+
"tag": "beta",
|
|
65
61
|
"access": "public",
|
|
66
62
|
"registry": "https://registry.npmjs.org/"
|
|
67
63
|
},
|
|
@@ -70,7 +66,7 @@
|
|
|
70
66
|
"clean": "rimraf dist/* && rimraf temp/* && rimraf temp-docs/*",
|
|
71
67
|
"lint": "eslint -c .eslintrc.json '{src,tests}/**/*.{js,ts}' && publint && tsc --noEmit -p tsconfig.json",
|
|
72
68
|
"test": "pnpm run test:unit && pnpm run test:integration",
|
|
73
|
-
"test:unit": "jest --config jest.unit.config.js",
|
|
69
|
+
"test:unit": "jest --config jest.unit.config.js --testTimeout 1000",
|
|
74
70
|
"test:integration": "jest --config jest.integration.config.js --testTimeout 360000",
|
|
75
71
|
"format": "prettier '**/*' --write",
|
|
76
72
|
"generate:types": "tsx ./scripts/generate-types.ts && prettier 'src/types/*.generated.ts' --write",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PolyfillWebSocketFactory, PolyfillWebSocket } from ".";
|
|
2
|
+
export { PolyfillWebSocket } from ".";
|
|
3
|
+
|
|
4
|
+
const PolyfillWebSocket =
|
|
5
|
+
WebSocket ?? global?.WebSocket ?? window?.WebSocket ?? self?.WebSocket;
|
|
6
|
+
|
|
7
|
+
export const factory: PolyfillWebSocketFactory = (
|
|
8
|
+
url: string,
|
|
9
|
+
params?: unknown,
|
|
10
|
+
) => {
|
|
11
|
+
if (params) {
|
|
12
|
+
return new PolyfillWebSocket(
|
|
13
|
+
url,
|
|
14
|
+
params as string | string[],
|
|
15
|
+
) as unknown as PolyfillWebSocket;
|
|
16
|
+
}
|
|
17
|
+
return new PolyfillWebSocket(url) as unknown as PolyfillWebSocket;
|
|
18
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import ws from "ws";
|
|
2
|
+
import { PolyfillWebSocket, PolyfillWebSocketFactory } from ".";
|
|
3
|
+
export { PolyfillWebSocket } from ".";
|
|
4
|
+
|
|
5
|
+
export const factory: PolyfillWebSocketFactory = (
|
|
6
|
+
url: string,
|
|
7
|
+
params?: unknown,
|
|
8
|
+
) => new ws(url, params as ws.ClientOptions) as unknown as PolyfillWebSocket;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import ws, { Event, ErrorEvent, CloseEvent, MessageEvent } from "ws";
|
|
2
|
+
|
|
3
|
+
export type PolyfillWebSocket = {
|
|
4
|
+
OPEN: typeof ws.OPEN;
|
|
5
|
+
binaryType: string;
|
|
6
|
+
onopen: ((event: Event) => void) | null;
|
|
7
|
+
onerror: ((event: ErrorEvent) => void) | null;
|
|
8
|
+
onclose: ((event: CloseEvent) => void) | null;
|
|
9
|
+
onmessage: ((event: MessageEvent) => void) | null;
|
|
10
|
+
readonly readyState:
|
|
11
|
+
| typeof ws.CONNECTING
|
|
12
|
+
| typeof ws.OPEN
|
|
13
|
+
| typeof ws.CLOSING
|
|
14
|
+
| typeof ws.CLOSED;
|
|
15
|
+
removeAllListeners?: () => void;
|
|
16
|
+
send(
|
|
17
|
+
data:
|
|
18
|
+
| string
|
|
19
|
+
| number
|
|
20
|
+
| Buffer
|
|
21
|
+
| DataView
|
|
22
|
+
| ArrayBufferView
|
|
23
|
+
| Uint8Array
|
|
24
|
+
| ArrayBuffer
|
|
25
|
+
| SharedArrayBuffer
|
|
26
|
+
| readonly unknown[]
|
|
27
|
+
| readonly number[]
|
|
28
|
+
| { valueOf(): ArrayBuffer }
|
|
29
|
+
| { valueOf(): SharedArrayBuffer }
|
|
30
|
+
| { valueOf(): Uint8Array }
|
|
31
|
+
| { valueOf(): readonly number[] }
|
|
32
|
+
| { valueOf(): string }
|
|
33
|
+
| { [Symbol.toPrimitive](hint: string): string },
|
|
34
|
+
): unknown;
|
|
35
|
+
close(): unknown;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type PolyfillWebSocketFactory = (
|
|
39
|
+
url: string,
|
|
40
|
+
params?: unknown,
|
|
41
|
+
) => PolyfillWebSocket;
|