assemblyai 4.34.0 → 4.34.5
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/README.md +22 -0
- package/dist/assemblyai.streaming.umd.js +20 -5
- package/dist/assemblyai.streaming.umd.min.js +1 -1
- package/dist/assemblyai.umd.js +20 -5
- package/dist/assemblyai.umd.min.js +1 -1
- package/dist/browser.mjs +17 -2
- package/dist/bun.mjs +17 -2
- package/dist/deno.mjs +17 -2
- package/dist/index.cjs +20 -5
- package/dist/index.mjs +20 -5
- package/dist/node.cjs +17 -2
- package/dist/node.mjs +17 -2
- package/dist/services/streaming/service.d.ts +2 -1
- package/dist/streaming.browser.mjs +17 -2
- package/dist/streaming.cjs +19 -4
- package/dist/streaming.mjs +19 -4
- package/dist/types/streaming/index.d.ts +32 -4
- package/dist/workerd.mjs +17 -2
- package/package.json +1 -1
- package/src/services/streaming/service.ts +24 -1
- package/src/types/streaming/index.ts +35 -1
package/dist/deno.mjs
CHANGED
|
@@ -30,7 +30,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
30
30
|
defaultUserAgentString += navigator.userAgent;
|
|
31
31
|
}
|
|
32
32
|
const defaultUserAgent = {
|
|
33
|
-
sdk: { name: "JavaScript", version: "4.34.
|
|
33
|
+
sdk: { name: "JavaScript", version: "4.34.5" },
|
|
34
34
|
};
|
|
35
35
|
if (typeof process !== "undefined") {
|
|
36
36
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -1101,13 +1101,21 @@ class StreamingTranscriber {
|
|
|
1101
1101
|
if (this.params.prompt) {
|
|
1102
1102
|
searchParams.set("prompt", this.params.prompt);
|
|
1103
1103
|
}
|
|
1104
|
+
if (this.params.agentContext) {
|
|
1105
|
+
searchParams.set("agent_context", this.params.agentContext);
|
|
1106
|
+
}
|
|
1104
1107
|
if (this.params.filterProfanity) {
|
|
1105
1108
|
searchParams.set("filter_profanity", this.params.filterProfanity.toString());
|
|
1106
1109
|
}
|
|
1107
1110
|
if (this.params.speechModel === "u3-pro") {
|
|
1108
1111
|
console.warn("[Deprecation Warning] The speech model `u3-pro` is deprecated and will be removed in a future release. Please use `u3-rt-pro` instead.");
|
|
1109
1112
|
}
|
|
1110
|
-
|
|
1113
|
+
if (this.params.speechModel !== undefined) {
|
|
1114
|
+
searchParams.set("speech_model", this.params.speechModel.toString());
|
|
1115
|
+
}
|
|
1116
|
+
if (this.params.languageCode !== undefined) {
|
|
1117
|
+
searchParams.set("language_code", this.params.languageCode);
|
|
1118
|
+
}
|
|
1111
1119
|
if (this.params.languageDetection !== undefined) {
|
|
1112
1120
|
searchParams.set("language_detection", this.params.languageDetection.toString());
|
|
1113
1121
|
}
|
|
@@ -1168,6 +1176,9 @@ class StreamingTranscriber {
|
|
|
1168
1176
|
if (this.params.redactPiiSub !== undefined) {
|
|
1169
1177
|
searchParams.set("redact_pii_sub", this.params.redactPiiSub);
|
|
1170
1178
|
}
|
|
1179
|
+
if (this.params.mode !== undefined) {
|
|
1180
|
+
searchParams.set("mode", this.params.mode);
|
|
1181
|
+
}
|
|
1171
1182
|
if (this.params.llmGateway !== undefined) {
|
|
1172
1183
|
searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
|
|
1173
1184
|
}
|
|
@@ -1257,6 +1268,10 @@ class StreamingTranscriber {
|
|
|
1257
1268
|
this.listeners.llmGatewayResponse?.(message);
|
|
1258
1269
|
break;
|
|
1259
1270
|
}
|
|
1271
|
+
case "SpeakerRevision": {
|
|
1272
|
+
this.listeners.speakerRevision?.(message);
|
|
1273
|
+
break;
|
|
1274
|
+
}
|
|
1260
1275
|
case "Warning": {
|
|
1261
1276
|
const warning = message;
|
|
1262
1277
|
console.warn(`Streaming warning (code=${warning.warning_code}): ${warning.warning}`);
|
package/dist/index.cjs
CHANGED
|
@@ -76,7 +76,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
76
76
|
defaultUserAgentString += navigator.userAgent;
|
|
77
77
|
}
|
|
78
78
|
const defaultUserAgent = {
|
|
79
|
-
sdk: { name: "JavaScript", version: "4.34.
|
|
79
|
+
sdk: { name: "JavaScript", version: "4.34.5" },
|
|
80
80
|
};
|
|
81
81
|
if (typeof process !== "undefined") {
|
|
82
82
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -1195,13 +1195,21 @@ class StreamingTranscriber {
|
|
|
1195
1195
|
if (this.params.prompt) {
|
|
1196
1196
|
searchParams.set("prompt", this.params.prompt);
|
|
1197
1197
|
}
|
|
1198
|
+
if (this.params.agentContext) {
|
|
1199
|
+
searchParams.set("agent_context", this.params.agentContext);
|
|
1200
|
+
}
|
|
1198
1201
|
if (this.params.filterProfanity) {
|
|
1199
1202
|
searchParams.set("filter_profanity", this.params.filterProfanity.toString());
|
|
1200
1203
|
}
|
|
1201
1204
|
if (this.params.speechModel === "u3-pro") {
|
|
1202
1205
|
console.warn("[Deprecation Warning] The speech model `u3-pro` is deprecated and will be removed in a future release. Please use `u3-rt-pro` instead.");
|
|
1203
1206
|
}
|
|
1204
|
-
|
|
1207
|
+
if (this.params.speechModel !== undefined) {
|
|
1208
|
+
searchParams.set("speech_model", this.params.speechModel.toString());
|
|
1209
|
+
}
|
|
1210
|
+
if (this.params.languageCode !== undefined) {
|
|
1211
|
+
searchParams.set("language_code", this.params.languageCode);
|
|
1212
|
+
}
|
|
1205
1213
|
if (this.params.languageDetection !== undefined) {
|
|
1206
1214
|
searchParams.set("language_detection", this.params.languageDetection.toString());
|
|
1207
1215
|
}
|
|
@@ -1262,6 +1270,9 @@ class StreamingTranscriber {
|
|
|
1262
1270
|
if (this.params.redactPiiSub !== undefined) {
|
|
1263
1271
|
searchParams.set("redact_pii_sub", this.params.redactPiiSub);
|
|
1264
1272
|
}
|
|
1273
|
+
if (this.params.mode !== undefined) {
|
|
1274
|
+
searchParams.set("mode", this.params.mode);
|
|
1275
|
+
}
|
|
1265
1276
|
if (this.params.llmGateway !== undefined) {
|
|
1266
1277
|
searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
|
|
1267
1278
|
}
|
|
@@ -1312,7 +1323,7 @@ class StreamingTranscriber {
|
|
|
1312
1323
|
(_d = (_c = this.listeners).error) === null || _d === void 0 ? void 0 : _d.call(_c, new Error(event.message));
|
|
1313
1324
|
};
|
|
1314
1325
|
this.socket.onmessage = ({ data }) => {
|
|
1315
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
1326
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
1316
1327
|
const message = JSON.parse(data.toString());
|
|
1317
1328
|
if ("error" in message) {
|
|
1318
1329
|
const err = new StreamingError(message.error);
|
|
@@ -1354,14 +1365,18 @@ class StreamingTranscriber {
|
|
|
1354
1365
|
(_k = (_j = this.listeners).llmGatewayResponse) === null || _k === void 0 ? void 0 : _k.call(_j, message);
|
|
1355
1366
|
break;
|
|
1356
1367
|
}
|
|
1368
|
+
case "SpeakerRevision": {
|
|
1369
|
+
(_m = (_l = this.listeners).speakerRevision) === null || _m === void 0 ? void 0 : _m.call(_l, message);
|
|
1370
|
+
break;
|
|
1371
|
+
}
|
|
1357
1372
|
case "Warning": {
|
|
1358
1373
|
const warning = message;
|
|
1359
1374
|
console.warn(`Streaming warning (code=${warning.warning_code}): ${warning.warning}`);
|
|
1360
|
-
(
|
|
1375
|
+
(_p = (_o = this.listeners).warning) === null || _p === void 0 ? void 0 : _p.call(_o, warning);
|
|
1361
1376
|
break;
|
|
1362
1377
|
}
|
|
1363
1378
|
case "Termination": {
|
|
1364
|
-
(
|
|
1379
|
+
(_q = this.sessionTerminatedResolve) === null || _q === void 0 ? void 0 : _q.call(this);
|
|
1365
1380
|
break;
|
|
1366
1381
|
}
|
|
1367
1382
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -74,7 +74,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
74
74
|
defaultUserAgentString += navigator.userAgent;
|
|
75
75
|
}
|
|
76
76
|
const defaultUserAgent = {
|
|
77
|
-
sdk: { name: "JavaScript", version: "4.34.
|
|
77
|
+
sdk: { name: "JavaScript", version: "4.34.5" },
|
|
78
78
|
};
|
|
79
79
|
if (typeof process !== "undefined") {
|
|
80
80
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -1193,13 +1193,21 @@ class StreamingTranscriber {
|
|
|
1193
1193
|
if (this.params.prompt) {
|
|
1194
1194
|
searchParams.set("prompt", this.params.prompt);
|
|
1195
1195
|
}
|
|
1196
|
+
if (this.params.agentContext) {
|
|
1197
|
+
searchParams.set("agent_context", this.params.agentContext);
|
|
1198
|
+
}
|
|
1196
1199
|
if (this.params.filterProfanity) {
|
|
1197
1200
|
searchParams.set("filter_profanity", this.params.filterProfanity.toString());
|
|
1198
1201
|
}
|
|
1199
1202
|
if (this.params.speechModel === "u3-pro") {
|
|
1200
1203
|
console.warn("[Deprecation Warning] The speech model `u3-pro` is deprecated and will be removed in a future release. Please use `u3-rt-pro` instead.");
|
|
1201
1204
|
}
|
|
1202
|
-
|
|
1205
|
+
if (this.params.speechModel !== undefined) {
|
|
1206
|
+
searchParams.set("speech_model", this.params.speechModel.toString());
|
|
1207
|
+
}
|
|
1208
|
+
if (this.params.languageCode !== undefined) {
|
|
1209
|
+
searchParams.set("language_code", this.params.languageCode);
|
|
1210
|
+
}
|
|
1203
1211
|
if (this.params.languageDetection !== undefined) {
|
|
1204
1212
|
searchParams.set("language_detection", this.params.languageDetection.toString());
|
|
1205
1213
|
}
|
|
@@ -1260,6 +1268,9 @@ class StreamingTranscriber {
|
|
|
1260
1268
|
if (this.params.redactPiiSub !== undefined) {
|
|
1261
1269
|
searchParams.set("redact_pii_sub", this.params.redactPiiSub);
|
|
1262
1270
|
}
|
|
1271
|
+
if (this.params.mode !== undefined) {
|
|
1272
|
+
searchParams.set("mode", this.params.mode);
|
|
1273
|
+
}
|
|
1263
1274
|
if (this.params.llmGateway !== undefined) {
|
|
1264
1275
|
searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
|
|
1265
1276
|
}
|
|
@@ -1310,7 +1321,7 @@ class StreamingTranscriber {
|
|
|
1310
1321
|
(_d = (_c = this.listeners).error) === null || _d === void 0 ? void 0 : _d.call(_c, new Error(event.message));
|
|
1311
1322
|
};
|
|
1312
1323
|
this.socket.onmessage = ({ data }) => {
|
|
1313
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
1324
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
1314
1325
|
const message = JSON.parse(data.toString());
|
|
1315
1326
|
if ("error" in message) {
|
|
1316
1327
|
const err = new StreamingError(message.error);
|
|
@@ -1352,14 +1363,18 @@ class StreamingTranscriber {
|
|
|
1352
1363
|
(_k = (_j = this.listeners).llmGatewayResponse) === null || _k === void 0 ? void 0 : _k.call(_j, message);
|
|
1353
1364
|
break;
|
|
1354
1365
|
}
|
|
1366
|
+
case "SpeakerRevision": {
|
|
1367
|
+
(_m = (_l = this.listeners).speakerRevision) === null || _m === void 0 ? void 0 : _m.call(_l, message);
|
|
1368
|
+
break;
|
|
1369
|
+
}
|
|
1355
1370
|
case "Warning": {
|
|
1356
1371
|
const warning = message;
|
|
1357
1372
|
console.warn(`Streaming warning (code=${warning.warning_code}): ${warning.warning}`);
|
|
1358
|
-
(
|
|
1373
|
+
(_p = (_o = this.listeners).warning) === null || _p === void 0 ? void 0 : _p.call(_o, warning);
|
|
1359
1374
|
break;
|
|
1360
1375
|
}
|
|
1361
1376
|
case "Termination": {
|
|
1362
|
-
(
|
|
1377
|
+
(_q = this.sessionTerminatedResolve) === null || _q === void 0 ? void 0 : _q.call(this);
|
|
1363
1378
|
break;
|
|
1364
1379
|
}
|
|
1365
1380
|
}
|
package/dist/node.cjs
CHANGED
|
@@ -35,7 +35,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
35
35
|
defaultUserAgentString += navigator.userAgent;
|
|
36
36
|
}
|
|
37
37
|
const defaultUserAgent = {
|
|
38
|
-
sdk: { name: "JavaScript", version: "4.34.
|
|
38
|
+
sdk: { name: "JavaScript", version: "4.34.5" },
|
|
39
39
|
};
|
|
40
40
|
if (typeof process !== "undefined") {
|
|
41
41
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -1100,13 +1100,21 @@ class StreamingTranscriber {
|
|
|
1100
1100
|
if (this.params.prompt) {
|
|
1101
1101
|
searchParams.set("prompt", this.params.prompt);
|
|
1102
1102
|
}
|
|
1103
|
+
if (this.params.agentContext) {
|
|
1104
|
+
searchParams.set("agent_context", this.params.agentContext);
|
|
1105
|
+
}
|
|
1103
1106
|
if (this.params.filterProfanity) {
|
|
1104
1107
|
searchParams.set("filter_profanity", this.params.filterProfanity.toString());
|
|
1105
1108
|
}
|
|
1106
1109
|
if (this.params.speechModel === "u3-pro") {
|
|
1107
1110
|
console.warn("[Deprecation Warning] The speech model `u3-pro` is deprecated and will be removed in a future release. Please use `u3-rt-pro` instead.");
|
|
1108
1111
|
}
|
|
1109
|
-
|
|
1112
|
+
if (this.params.speechModel !== undefined) {
|
|
1113
|
+
searchParams.set("speech_model", this.params.speechModel.toString());
|
|
1114
|
+
}
|
|
1115
|
+
if (this.params.languageCode !== undefined) {
|
|
1116
|
+
searchParams.set("language_code", this.params.languageCode);
|
|
1117
|
+
}
|
|
1110
1118
|
if (this.params.languageDetection !== undefined) {
|
|
1111
1119
|
searchParams.set("language_detection", this.params.languageDetection.toString());
|
|
1112
1120
|
}
|
|
@@ -1167,6 +1175,9 @@ class StreamingTranscriber {
|
|
|
1167
1175
|
if (this.params.redactPiiSub !== undefined) {
|
|
1168
1176
|
searchParams.set("redact_pii_sub", this.params.redactPiiSub);
|
|
1169
1177
|
}
|
|
1178
|
+
if (this.params.mode !== undefined) {
|
|
1179
|
+
searchParams.set("mode", this.params.mode);
|
|
1180
|
+
}
|
|
1170
1181
|
if (this.params.llmGateway !== undefined) {
|
|
1171
1182
|
searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
|
|
1172
1183
|
}
|
|
@@ -1256,6 +1267,10 @@ class StreamingTranscriber {
|
|
|
1256
1267
|
this.listeners.llmGatewayResponse?.(message);
|
|
1257
1268
|
break;
|
|
1258
1269
|
}
|
|
1270
|
+
case "SpeakerRevision": {
|
|
1271
|
+
this.listeners.speakerRevision?.(message);
|
|
1272
|
+
break;
|
|
1273
|
+
}
|
|
1259
1274
|
case "Warning": {
|
|
1260
1275
|
const warning = message;
|
|
1261
1276
|
console.warn(`Streaming warning (code=${warning.warning_code}): ${warning.warning}`);
|
package/dist/node.mjs
CHANGED
|
@@ -33,7 +33,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
33
33
|
defaultUserAgentString += navigator.userAgent;
|
|
34
34
|
}
|
|
35
35
|
const defaultUserAgent = {
|
|
36
|
-
sdk: { name: "JavaScript", version: "4.34.
|
|
36
|
+
sdk: { name: "JavaScript", version: "4.34.5" },
|
|
37
37
|
};
|
|
38
38
|
if (typeof process !== "undefined") {
|
|
39
39
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -1098,13 +1098,21 @@ class StreamingTranscriber {
|
|
|
1098
1098
|
if (this.params.prompt) {
|
|
1099
1099
|
searchParams.set("prompt", this.params.prompt);
|
|
1100
1100
|
}
|
|
1101
|
+
if (this.params.agentContext) {
|
|
1102
|
+
searchParams.set("agent_context", this.params.agentContext);
|
|
1103
|
+
}
|
|
1101
1104
|
if (this.params.filterProfanity) {
|
|
1102
1105
|
searchParams.set("filter_profanity", this.params.filterProfanity.toString());
|
|
1103
1106
|
}
|
|
1104
1107
|
if (this.params.speechModel === "u3-pro") {
|
|
1105
1108
|
console.warn("[Deprecation Warning] The speech model `u3-pro` is deprecated and will be removed in a future release. Please use `u3-rt-pro` instead.");
|
|
1106
1109
|
}
|
|
1107
|
-
|
|
1110
|
+
if (this.params.speechModel !== undefined) {
|
|
1111
|
+
searchParams.set("speech_model", this.params.speechModel.toString());
|
|
1112
|
+
}
|
|
1113
|
+
if (this.params.languageCode !== undefined) {
|
|
1114
|
+
searchParams.set("language_code", this.params.languageCode);
|
|
1115
|
+
}
|
|
1108
1116
|
if (this.params.languageDetection !== undefined) {
|
|
1109
1117
|
searchParams.set("language_detection", this.params.languageDetection.toString());
|
|
1110
1118
|
}
|
|
@@ -1165,6 +1173,9 @@ class StreamingTranscriber {
|
|
|
1165
1173
|
if (this.params.redactPiiSub !== undefined) {
|
|
1166
1174
|
searchParams.set("redact_pii_sub", this.params.redactPiiSub);
|
|
1167
1175
|
}
|
|
1176
|
+
if (this.params.mode !== undefined) {
|
|
1177
|
+
searchParams.set("mode", this.params.mode);
|
|
1178
|
+
}
|
|
1168
1179
|
if (this.params.llmGateway !== undefined) {
|
|
1169
1180
|
searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
|
|
1170
1181
|
}
|
|
@@ -1254,6 +1265,10 @@ class StreamingTranscriber {
|
|
|
1254
1265
|
this.listeners.llmGatewayResponse?.(message);
|
|
1255
1266
|
break;
|
|
1256
1267
|
}
|
|
1268
|
+
case "SpeakerRevision": {
|
|
1269
|
+
this.listeners.speakerRevision?.(message);
|
|
1270
|
+
break;
|
|
1271
|
+
}
|
|
1257
1272
|
case "Warning": {
|
|
1258
1273
|
const warning = message;
|
|
1259
1274
|
console.warn(`Streaming warning (code=${warning.warning_code}): ${warning.warning}`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StreamingTranscriberParams, AudioData, BeginEvent, TurnEvent, LLMGatewayResponseEvent, StreamingUpdateConfiguration, WarningEvent } from "../..";
|
|
1
|
+
import { StreamingTranscriberParams, AudioData, BeginEvent, TurnEvent, LLMGatewayResponseEvent, SpeakerRevisionEvent, StreamingUpdateConfiguration, WarningEvent } from "../..";
|
|
2
2
|
import type { VadFrame } from "../../types/streaming/dual-channel";
|
|
3
3
|
/**
|
|
4
4
|
* Options for `sendAudio`. In dual-channel mode (when `channels` is configured
|
|
@@ -34,6 +34,7 @@ export declare class StreamingTranscriber {
|
|
|
34
34
|
on(event: "open", listener: (event: BeginEvent) => void): void;
|
|
35
35
|
on(event: "turn", listener: (event: TurnEvent) => void): void;
|
|
36
36
|
on(event: "llmGatewayResponse", listener: (event: LLMGatewayResponseEvent) => void): void;
|
|
37
|
+
on(event: "speakerRevision", listener: (event: SpeakerRevisionEvent) => void): void;
|
|
37
38
|
on(event: "warning", listener: (event: WarningEvent) => void): void;
|
|
38
39
|
on(event: "vad", listener: (event: VadFrame) => void): void;
|
|
39
40
|
on(event: "error", listener: (error: Error) => void): void;
|
|
@@ -651,13 +651,21 @@ class StreamingTranscriber {
|
|
|
651
651
|
if (this.params.prompt) {
|
|
652
652
|
searchParams.set("prompt", this.params.prompt);
|
|
653
653
|
}
|
|
654
|
+
if (this.params.agentContext) {
|
|
655
|
+
searchParams.set("agent_context", this.params.agentContext);
|
|
656
|
+
}
|
|
654
657
|
if (this.params.filterProfanity) {
|
|
655
658
|
searchParams.set("filter_profanity", this.params.filterProfanity.toString());
|
|
656
659
|
}
|
|
657
660
|
if (this.params.speechModel === "u3-pro") {
|
|
658
661
|
console.warn("[Deprecation Warning] The speech model `u3-pro` is deprecated and will be removed in a future release. Please use `u3-rt-pro` instead.");
|
|
659
662
|
}
|
|
660
|
-
|
|
663
|
+
if (this.params.speechModel !== undefined) {
|
|
664
|
+
searchParams.set("speech_model", this.params.speechModel.toString());
|
|
665
|
+
}
|
|
666
|
+
if (this.params.languageCode !== undefined) {
|
|
667
|
+
searchParams.set("language_code", this.params.languageCode);
|
|
668
|
+
}
|
|
661
669
|
if (this.params.languageDetection !== undefined) {
|
|
662
670
|
searchParams.set("language_detection", this.params.languageDetection.toString());
|
|
663
671
|
}
|
|
@@ -718,6 +726,9 @@ class StreamingTranscriber {
|
|
|
718
726
|
if (this.params.redactPiiSub !== undefined) {
|
|
719
727
|
searchParams.set("redact_pii_sub", this.params.redactPiiSub);
|
|
720
728
|
}
|
|
729
|
+
if (this.params.mode !== undefined) {
|
|
730
|
+
searchParams.set("mode", this.params.mode);
|
|
731
|
+
}
|
|
721
732
|
if (this.params.llmGateway !== undefined) {
|
|
722
733
|
searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
|
|
723
734
|
}
|
|
@@ -811,6 +822,10 @@ Learn more at https://github.com/AssemblyAI/assemblyai-node-sdk/blob/main/docs/c
|
|
|
811
822
|
this.listeners.llmGatewayResponse?.(message);
|
|
812
823
|
break;
|
|
813
824
|
}
|
|
825
|
+
case "SpeakerRevision": {
|
|
826
|
+
this.listeners.speakerRevision?.(message);
|
|
827
|
+
break;
|
|
828
|
+
}
|
|
814
829
|
case "Warning": {
|
|
815
830
|
const warning = message;
|
|
816
831
|
console.warn(`Streaming warning (code=${warning.warning_code}): ${warning.warning}`);
|
|
@@ -1153,7 +1168,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
1153
1168
|
defaultUserAgentString += navigator.userAgent;
|
|
1154
1169
|
}
|
|
1155
1170
|
const defaultUserAgent = {
|
|
1156
|
-
sdk: { name: "JavaScript", version: "4.34.
|
|
1171
|
+
sdk: { name: "JavaScript", version: "4.34.5" },
|
|
1157
1172
|
};
|
|
1158
1173
|
if (typeof process !== "undefined") {
|
|
1159
1174
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
package/dist/streaming.cjs
CHANGED
|
@@ -697,13 +697,21 @@ class StreamingTranscriber {
|
|
|
697
697
|
if (this.params.prompt) {
|
|
698
698
|
searchParams.set("prompt", this.params.prompt);
|
|
699
699
|
}
|
|
700
|
+
if (this.params.agentContext) {
|
|
701
|
+
searchParams.set("agent_context", this.params.agentContext);
|
|
702
|
+
}
|
|
700
703
|
if (this.params.filterProfanity) {
|
|
701
704
|
searchParams.set("filter_profanity", this.params.filterProfanity.toString());
|
|
702
705
|
}
|
|
703
706
|
if (this.params.speechModel === "u3-pro") {
|
|
704
707
|
console.warn("[Deprecation Warning] The speech model `u3-pro` is deprecated and will be removed in a future release. Please use `u3-rt-pro` instead.");
|
|
705
708
|
}
|
|
706
|
-
|
|
709
|
+
if (this.params.speechModel !== undefined) {
|
|
710
|
+
searchParams.set("speech_model", this.params.speechModel.toString());
|
|
711
|
+
}
|
|
712
|
+
if (this.params.languageCode !== undefined) {
|
|
713
|
+
searchParams.set("language_code", this.params.languageCode);
|
|
714
|
+
}
|
|
707
715
|
if (this.params.languageDetection !== undefined) {
|
|
708
716
|
searchParams.set("language_detection", this.params.languageDetection.toString());
|
|
709
717
|
}
|
|
@@ -764,6 +772,9 @@ class StreamingTranscriber {
|
|
|
764
772
|
if (this.params.redactPiiSub !== undefined) {
|
|
765
773
|
searchParams.set("redact_pii_sub", this.params.redactPiiSub);
|
|
766
774
|
}
|
|
775
|
+
if (this.params.mode !== undefined) {
|
|
776
|
+
searchParams.set("mode", this.params.mode);
|
|
777
|
+
}
|
|
767
778
|
if (this.params.llmGateway !== undefined) {
|
|
768
779
|
searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
|
|
769
780
|
}
|
|
@@ -814,7 +825,7 @@ class StreamingTranscriber {
|
|
|
814
825
|
(_d = (_c = this.listeners).error) === null || _d === void 0 ? void 0 : _d.call(_c, new Error(event.message));
|
|
815
826
|
};
|
|
816
827
|
this.socket.onmessage = ({ data }) => {
|
|
817
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
828
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
818
829
|
const message = JSON.parse(data.toString());
|
|
819
830
|
if ("error" in message) {
|
|
820
831
|
const err = new StreamingError(message.error);
|
|
@@ -856,14 +867,18 @@ class StreamingTranscriber {
|
|
|
856
867
|
(_k = (_j = this.listeners).llmGatewayResponse) === null || _k === void 0 ? void 0 : _k.call(_j, message);
|
|
857
868
|
break;
|
|
858
869
|
}
|
|
870
|
+
case "SpeakerRevision": {
|
|
871
|
+
(_m = (_l = this.listeners).speakerRevision) === null || _m === void 0 ? void 0 : _m.call(_l, message);
|
|
872
|
+
break;
|
|
873
|
+
}
|
|
859
874
|
case "Warning": {
|
|
860
875
|
const warning = message;
|
|
861
876
|
console.warn(`Streaming warning (code=${warning.warning_code}): ${warning.warning}`);
|
|
862
|
-
(
|
|
877
|
+
(_p = (_o = this.listeners).warning) === null || _p === void 0 ? void 0 : _p.call(_o, warning);
|
|
863
878
|
break;
|
|
864
879
|
}
|
|
865
880
|
case "Termination": {
|
|
866
|
-
(
|
|
881
|
+
(_q = this.sessionTerminatedResolve) === null || _q === void 0 ? void 0 : _q.call(this);
|
|
867
882
|
break;
|
|
868
883
|
}
|
|
869
884
|
}
|
package/dist/streaming.mjs
CHANGED
|
@@ -695,13 +695,21 @@ class StreamingTranscriber {
|
|
|
695
695
|
if (this.params.prompt) {
|
|
696
696
|
searchParams.set("prompt", this.params.prompt);
|
|
697
697
|
}
|
|
698
|
+
if (this.params.agentContext) {
|
|
699
|
+
searchParams.set("agent_context", this.params.agentContext);
|
|
700
|
+
}
|
|
698
701
|
if (this.params.filterProfanity) {
|
|
699
702
|
searchParams.set("filter_profanity", this.params.filterProfanity.toString());
|
|
700
703
|
}
|
|
701
704
|
if (this.params.speechModel === "u3-pro") {
|
|
702
705
|
console.warn("[Deprecation Warning] The speech model `u3-pro` is deprecated and will be removed in a future release. Please use `u3-rt-pro` instead.");
|
|
703
706
|
}
|
|
704
|
-
|
|
707
|
+
if (this.params.speechModel !== undefined) {
|
|
708
|
+
searchParams.set("speech_model", this.params.speechModel.toString());
|
|
709
|
+
}
|
|
710
|
+
if (this.params.languageCode !== undefined) {
|
|
711
|
+
searchParams.set("language_code", this.params.languageCode);
|
|
712
|
+
}
|
|
705
713
|
if (this.params.languageDetection !== undefined) {
|
|
706
714
|
searchParams.set("language_detection", this.params.languageDetection.toString());
|
|
707
715
|
}
|
|
@@ -762,6 +770,9 @@ class StreamingTranscriber {
|
|
|
762
770
|
if (this.params.redactPiiSub !== undefined) {
|
|
763
771
|
searchParams.set("redact_pii_sub", this.params.redactPiiSub);
|
|
764
772
|
}
|
|
773
|
+
if (this.params.mode !== undefined) {
|
|
774
|
+
searchParams.set("mode", this.params.mode);
|
|
775
|
+
}
|
|
765
776
|
if (this.params.llmGateway !== undefined) {
|
|
766
777
|
searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
|
|
767
778
|
}
|
|
@@ -812,7 +823,7 @@ class StreamingTranscriber {
|
|
|
812
823
|
(_d = (_c = this.listeners).error) === null || _d === void 0 ? void 0 : _d.call(_c, new Error(event.message));
|
|
813
824
|
};
|
|
814
825
|
this.socket.onmessage = ({ data }) => {
|
|
815
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
826
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
816
827
|
const message = JSON.parse(data.toString());
|
|
817
828
|
if ("error" in message) {
|
|
818
829
|
const err = new StreamingError(message.error);
|
|
@@ -854,14 +865,18 @@ class StreamingTranscriber {
|
|
|
854
865
|
(_k = (_j = this.listeners).llmGatewayResponse) === null || _k === void 0 ? void 0 : _k.call(_j, message);
|
|
855
866
|
break;
|
|
856
867
|
}
|
|
868
|
+
case "SpeakerRevision": {
|
|
869
|
+
(_m = (_l = this.listeners).speakerRevision) === null || _m === void 0 ? void 0 : _m.call(_l, message);
|
|
870
|
+
break;
|
|
871
|
+
}
|
|
857
872
|
case "Warning": {
|
|
858
873
|
const warning = message;
|
|
859
874
|
console.warn(`Streaming warning (code=${warning.warning_code}): ${warning.warning}`);
|
|
860
|
-
(
|
|
875
|
+
(_p = (_o = this.listeners).warning) === null || _p === void 0 ? void 0 : _p.call(_o, warning);
|
|
861
876
|
break;
|
|
862
877
|
}
|
|
863
878
|
case "Termination": {
|
|
864
|
-
(
|
|
879
|
+
(_q = this.sessionTerminatedResolve) === null || _q === void 0 ? void 0 : _q.call(this);
|
|
865
880
|
break;
|
|
866
881
|
}
|
|
867
882
|
}
|
|
@@ -86,7 +86,9 @@ export type StreamingTranscriberParams = {
|
|
|
86
86
|
keyterms?: string[];
|
|
87
87
|
keytermsPrompt?: string[];
|
|
88
88
|
prompt?: string;
|
|
89
|
-
|
|
89
|
+
agentContext?: string;
|
|
90
|
+
speechModel?: StreamingSpeechModel;
|
|
91
|
+
languageCode?: string;
|
|
90
92
|
languageDetection?: boolean;
|
|
91
93
|
domain?: StreamingDomain;
|
|
92
94
|
inactivityTimeout?: number;
|
|
@@ -102,6 +104,7 @@ export type StreamingTranscriberParams = {
|
|
|
102
104
|
redactPii?: boolean;
|
|
103
105
|
redactPiiPolicies?: StreamingPiiPolicy[];
|
|
104
106
|
redactPiiSub?: StreamingPiiSubstitution;
|
|
107
|
+
mode?: StreamingMode;
|
|
105
108
|
llmGateway?: LLMGatewayConfig;
|
|
106
109
|
webhookUrl?: string;
|
|
107
110
|
webhookAuthHeaderName?: string;
|
|
@@ -136,19 +139,21 @@ export type StreamingTranscriberParams = {
|
|
|
136
139
|
/** Tuning for dual-channel attribution. Ignored when `channels` is unset. */
|
|
137
140
|
channelAttribution?: ChannelAttributionParams;
|
|
138
141
|
};
|
|
139
|
-
export type StreamingEvents = "open" | "close" | "turn" | "speechStarted" | "llmGatewayResponse" | "warning" | "vad" | "error";
|
|
142
|
+
export type StreamingEvents = "open" | "close" | "turn" | "speechStarted" | "llmGatewayResponse" | "speakerRevision" | "warning" | "vad" | "error";
|
|
140
143
|
export type StreamingListeners = {
|
|
141
144
|
open?: (event: BeginEvent) => void;
|
|
142
145
|
close?: (code: number, reason: string) => void;
|
|
143
146
|
turn?: (event: TurnEvent) => void;
|
|
144
147
|
speechStarted?: (event: SpeechStartedEvent) => void;
|
|
145
148
|
llmGatewayResponse?: (event: LLMGatewayResponseEvent) => void;
|
|
149
|
+
speakerRevision?: (event: SpeakerRevisionEvent) => void;
|
|
146
150
|
warning?: (event: WarningEvent) => void;
|
|
147
151
|
vad?: (event: VadFrame) => void;
|
|
148
152
|
error?: (error: Error) => void;
|
|
149
153
|
};
|
|
150
|
-
export type StreamingSpeechModel = "universal-streaming-english" | "universal-streaming-multilingual" | "u3-rt-pro" | "whisper-rt" | "u3-pro";
|
|
154
|
+
export type StreamingSpeechModel = "universal-streaming-english" | "universal-streaming-multilingual" | "u3-rt-pro" | "u3-rt-pro-beta-1" | "whisper-rt" | "u3-pro";
|
|
151
155
|
export type StreamingDomain = "medical-v1";
|
|
156
|
+
export type StreamingMode = "max_accuracy" | "min_latency" | "balanced";
|
|
152
157
|
export type VoiceFocusModel = "near-field" | "far-field";
|
|
153
158
|
export type StreamingPiiSubstitution = "hash" | "entity_name";
|
|
154
159
|
export type StreamingPiiPolicy = "account_number" | "banking_information" | "blood_type" | "corporate_action" | "credit_card_cvv" | "credit_card_expiration" | "credit_card_number" | "date" | "date_interval" | "date_of_birth" | "day" | "drivers_license" | "drug" | "duration" | "effect" | "email_address" | "event" | "filename" | "financial_metric" | "gender" | "gender_sexuality" | "healthcare_number" | "injury" | "ip_address" | "language" | "location" | "location_address" | "location_address_street" | "location_city" | "location_coordinate" | "location_country" | "location_state" | "location_zip" | "marital_status" | "medical_code" | "medical_condition" | "medical_process" | "money_amount" | "month" | "nationality" | "number_sequence" | "occupation" | "organization" | "organization_id" | "organization_medical_facility" | "passport_number" | "password" | "person_age" | "person_name" | "phone_number" | "physical_attribute" | "political_affiliation" | "product" | "project" | "religion" | "sexuality" | "statistics" | "time" | "trend" | "url" | "us_social_security_number" | "username" | "vehicle_id" | "year" | "zodiac_sign";
|
|
@@ -230,6 +235,7 @@ export type StreamingUpdateConfiguration = {
|
|
|
230
235
|
format_turns?: boolean;
|
|
231
236
|
keyterms_prompt?: string[];
|
|
232
237
|
prompt?: string;
|
|
238
|
+
agent_context?: string;
|
|
233
239
|
filter_profanity?: boolean;
|
|
234
240
|
interruption_delay?: number;
|
|
235
241
|
turn_left_pad_ms?: number;
|
|
@@ -253,5 +259,27 @@ export type LLMGatewayResponseEvent = {
|
|
|
253
259
|
transcript: string;
|
|
254
260
|
data: unknown;
|
|
255
261
|
};
|
|
256
|
-
|
|
262
|
+
/**
|
|
263
|
+
* A single earlier Turn whose speaker labels were revised by reclustering.
|
|
264
|
+
* Match by `turn_order` against the original Turn; replace its per-word
|
|
265
|
+
* `speaker` assignments (and the turn-level `speaker_label`) with these. Text
|
|
266
|
+
* and word timestamps are unchanged from the original Turn.
|
|
267
|
+
*/
|
|
268
|
+
export type SpeakerRevisionItem = {
|
|
269
|
+
turn_order: number;
|
|
270
|
+
speaker_label?: string;
|
|
271
|
+
words: StreamingWord[];
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* Server-side correction to previously-emitted Turns' speaker labels.
|
|
275
|
+
* Diarization-only (emitted only when `speakerLabels` is enabled). Sent once
|
|
276
|
+
* per offline-recluster resolve; `revisions` carries one entry per earlier
|
|
277
|
+
* Turn whose label actually changed (unchanged turns are omitted). Apply each
|
|
278
|
+
* entry by matching its `turn_order`.
|
|
279
|
+
*/
|
|
280
|
+
export type SpeakerRevisionEvent = {
|
|
281
|
+
type: "SpeakerRevision";
|
|
282
|
+
revisions: SpeakerRevisionItem[];
|
|
283
|
+
};
|
|
284
|
+
export type StreamingEventMessage = BeginEvent | TurnEvent | SpeechStartedEvent | TerminationEvent | LLMGatewayResponseEvent | SpeakerRevisionEvent | ErrorEvent | WarningEvent;
|
|
257
285
|
export type StreamingOperationMessage = StreamingUpdateConfiguration | StreamingForceEndpoint | StreamingTerminateSession;
|
package/dist/workerd.mjs
CHANGED
|
@@ -28,7 +28,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
28
28
|
defaultUserAgentString += navigator.userAgent;
|
|
29
29
|
}
|
|
30
30
|
const defaultUserAgent = {
|
|
31
|
-
sdk: { name: "JavaScript", version: "4.34.
|
|
31
|
+
sdk: { name: "JavaScript", version: "4.34.5" },
|
|
32
32
|
};
|
|
33
33
|
if (typeof process !== "undefined") {
|
|
34
34
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -1103,13 +1103,21 @@ class StreamingTranscriber {
|
|
|
1103
1103
|
if (this.params.prompt) {
|
|
1104
1104
|
searchParams.set("prompt", this.params.prompt);
|
|
1105
1105
|
}
|
|
1106
|
+
if (this.params.agentContext) {
|
|
1107
|
+
searchParams.set("agent_context", this.params.agentContext);
|
|
1108
|
+
}
|
|
1106
1109
|
if (this.params.filterProfanity) {
|
|
1107
1110
|
searchParams.set("filter_profanity", this.params.filterProfanity.toString());
|
|
1108
1111
|
}
|
|
1109
1112
|
if (this.params.speechModel === "u3-pro") {
|
|
1110
1113
|
console.warn("[Deprecation Warning] The speech model `u3-pro` is deprecated and will be removed in a future release. Please use `u3-rt-pro` instead.");
|
|
1111
1114
|
}
|
|
1112
|
-
|
|
1115
|
+
if (this.params.speechModel !== undefined) {
|
|
1116
|
+
searchParams.set("speech_model", this.params.speechModel.toString());
|
|
1117
|
+
}
|
|
1118
|
+
if (this.params.languageCode !== undefined) {
|
|
1119
|
+
searchParams.set("language_code", this.params.languageCode);
|
|
1120
|
+
}
|
|
1113
1121
|
if (this.params.languageDetection !== undefined) {
|
|
1114
1122
|
searchParams.set("language_detection", this.params.languageDetection.toString());
|
|
1115
1123
|
}
|
|
@@ -1170,6 +1178,9 @@ class StreamingTranscriber {
|
|
|
1170
1178
|
if (this.params.redactPiiSub !== undefined) {
|
|
1171
1179
|
searchParams.set("redact_pii_sub", this.params.redactPiiSub);
|
|
1172
1180
|
}
|
|
1181
|
+
if (this.params.mode !== undefined) {
|
|
1182
|
+
searchParams.set("mode", this.params.mode);
|
|
1183
|
+
}
|
|
1173
1184
|
if (this.params.llmGateway !== undefined) {
|
|
1174
1185
|
searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
|
|
1175
1186
|
}
|
|
@@ -1259,6 +1270,10 @@ class StreamingTranscriber {
|
|
|
1259
1270
|
this.listeners.llmGatewayResponse?.(message);
|
|
1260
1271
|
break;
|
|
1261
1272
|
}
|
|
1273
|
+
case "SpeakerRevision": {
|
|
1274
|
+
this.listeners.speakerRevision?.(message);
|
|
1275
|
+
break;
|
|
1276
|
+
}
|
|
1262
1277
|
case "Warning": {
|
|
1263
1278
|
const warning = message;
|
|
1264
1279
|
console.warn(`Streaming warning (code=${warning.warning_code}): ${warning.warning}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assemblyai",
|
|
3
|
-
"version": "4.34.
|
|
3
|
+
"version": "4.34.5",
|
|
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"
|