assemblyai 4.34.0 → 4.34.4
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 +17 -5
- package/dist/assemblyai.streaming.umd.min.js +1 -1
- package/dist/assemblyai.umd.js +17 -5
- package/dist/assemblyai.umd.min.js +1 -1
- package/dist/browser.mjs +14 -2
- package/dist/bun.mjs +14 -2
- package/dist/deno.mjs +14 -2
- package/dist/index.cjs +17 -5
- package/dist/index.mjs +17 -5
- package/dist/node.cjs +14 -2
- package/dist/node.mjs +14 -2
- package/dist/services/streaming/service.d.ts +2 -1
- package/dist/streaming.browser.mjs +14 -2
- package/dist/streaming.cjs +16 -4
- package/dist/streaming.mjs +16 -4
- package/dist/types/streaming/index.d.ts +31 -4
- package/dist/workerd.mjs +14 -2
- package/package.json +1 -1
- package/src/services/streaming/service.ts +20 -1
- package/src/types/streaming/index.ts +34 -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.4" },
|
|
34
34
|
};
|
|
35
35
|
if (typeof process !== "undefined") {
|
|
36
36
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -1101,13 +1101,18 @@ 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
|
+
}
|
|
1111
1116
|
if (this.params.languageDetection !== undefined) {
|
|
1112
1117
|
searchParams.set("language_detection", this.params.languageDetection.toString());
|
|
1113
1118
|
}
|
|
@@ -1168,6 +1173,9 @@ class StreamingTranscriber {
|
|
|
1168
1173
|
if (this.params.redactPiiSub !== undefined) {
|
|
1169
1174
|
searchParams.set("redact_pii_sub", this.params.redactPiiSub);
|
|
1170
1175
|
}
|
|
1176
|
+
if (this.params.mode !== undefined) {
|
|
1177
|
+
searchParams.set("mode", this.params.mode);
|
|
1178
|
+
}
|
|
1171
1179
|
if (this.params.llmGateway !== undefined) {
|
|
1172
1180
|
searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
|
|
1173
1181
|
}
|
|
@@ -1257,6 +1265,10 @@ class StreamingTranscriber {
|
|
|
1257
1265
|
this.listeners.llmGatewayResponse?.(message);
|
|
1258
1266
|
break;
|
|
1259
1267
|
}
|
|
1268
|
+
case "SpeakerRevision": {
|
|
1269
|
+
this.listeners.speakerRevision?.(message);
|
|
1270
|
+
break;
|
|
1271
|
+
}
|
|
1260
1272
|
case "Warning": {
|
|
1261
1273
|
const warning = message;
|
|
1262
1274
|
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.4" },
|
|
80
80
|
};
|
|
81
81
|
if (typeof process !== "undefined") {
|
|
82
82
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -1195,13 +1195,18 @@ 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
|
+
}
|
|
1205
1210
|
if (this.params.languageDetection !== undefined) {
|
|
1206
1211
|
searchParams.set("language_detection", this.params.languageDetection.toString());
|
|
1207
1212
|
}
|
|
@@ -1262,6 +1267,9 @@ class StreamingTranscriber {
|
|
|
1262
1267
|
if (this.params.redactPiiSub !== undefined) {
|
|
1263
1268
|
searchParams.set("redact_pii_sub", this.params.redactPiiSub);
|
|
1264
1269
|
}
|
|
1270
|
+
if (this.params.mode !== undefined) {
|
|
1271
|
+
searchParams.set("mode", this.params.mode);
|
|
1272
|
+
}
|
|
1265
1273
|
if (this.params.llmGateway !== undefined) {
|
|
1266
1274
|
searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
|
|
1267
1275
|
}
|
|
@@ -1312,7 +1320,7 @@ class StreamingTranscriber {
|
|
|
1312
1320
|
(_d = (_c = this.listeners).error) === null || _d === void 0 ? void 0 : _d.call(_c, new Error(event.message));
|
|
1313
1321
|
};
|
|
1314
1322
|
this.socket.onmessage = ({ data }) => {
|
|
1315
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
1323
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
1316
1324
|
const message = JSON.parse(data.toString());
|
|
1317
1325
|
if ("error" in message) {
|
|
1318
1326
|
const err = new StreamingError(message.error);
|
|
@@ -1354,14 +1362,18 @@ class StreamingTranscriber {
|
|
|
1354
1362
|
(_k = (_j = this.listeners).llmGatewayResponse) === null || _k === void 0 ? void 0 : _k.call(_j, message);
|
|
1355
1363
|
break;
|
|
1356
1364
|
}
|
|
1365
|
+
case "SpeakerRevision": {
|
|
1366
|
+
(_m = (_l = this.listeners).speakerRevision) === null || _m === void 0 ? void 0 : _m.call(_l, message);
|
|
1367
|
+
break;
|
|
1368
|
+
}
|
|
1357
1369
|
case "Warning": {
|
|
1358
1370
|
const warning = message;
|
|
1359
1371
|
console.warn(`Streaming warning (code=${warning.warning_code}): ${warning.warning}`);
|
|
1360
|
-
(
|
|
1372
|
+
(_p = (_o = this.listeners).warning) === null || _p === void 0 ? void 0 : _p.call(_o, warning);
|
|
1361
1373
|
break;
|
|
1362
1374
|
}
|
|
1363
1375
|
case "Termination": {
|
|
1364
|
-
(
|
|
1376
|
+
(_q = this.sessionTerminatedResolve) === null || _q === void 0 ? void 0 : _q.call(this);
|
|
1365
1377
|
break;
|
|
1366
1378
|
}
|
|
1367
1379
|
}
|
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.4" },
|
|
78
78
|
};
|
|
79
79
|
if (typeof process !== "undefined") {
|
|
80
80
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -1193,13 +1193,18 @@ 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
|
+
}
|
|
1203
1208
|
if (this.params.languageDetection !== undefined) {
|
|
1204
1209
|
searchParams.set("language_detection", this.params.languageDetection.toString());
|
|
1205
1210
|
}
|
|
@@ -1260,6 +1265,9 @@ class StreamingTranscriber {
|
|
|
1260
1265
|
if (this.params.redactPiiSub !== undefined) {
|
|
1261
1266
|
searchParams.set("redact_pii_sub", this.params.redactPiiSub);
|
|
1262
1267
|
}
|
|
1268
|
+
if (this.params.mode !== undefined) {
|
|
1269
|
+
searchParams.set("mode", this.params.mode);
|
|
1270
|
+
}
|
|
1263
1271
|
if (this.params.llmGateway !== undefined) {
|
|
1264
1272
|
searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
|
|
1265
1273
|
}
|
|
@@ -1310,7 +1318,7 @@ class StreamingTranscriber {
|
|
|
1310
1318
|
(_d = (_c = this.listeners).error) === null || _d === void 0 ? void 0 : _d.call(_c, new Error(event.message));
|
|
1311
1319
|
};
|
|
1312
1320
|
this.socket.onmessage = ({ data }) => {
|
|
1313
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
1321
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
1314
1322
|
const message = JSON.parse(data.toString());
|
|
1315
1323
|
if ("error" in message) {
|
|
1316
1324
|
const err = new StreamingError(message.error);
|
|
@@ -1352,14 +1360,18 @@ class StreamingTranscriber {
|
|
|
1352
1360
|
(_k = (_j = this.listeners).llmGatewayResponse) === null || _k === void 0 ? void 0 : _k.call(_j, message);
|
|
1353
1361
|
break;
|
|
1354
1362
|
}
|
|
1363
|
+
case "SpeakerRevision": {
|
|
1364
|
+
(_m = (_l = this.listeners).speakerRevision) === null || _m === void 0 ? void 0 : _m.call(_l, message);
|
|
1365
|
+
break;
|
|
1366
|
+
}
|
|
1355
1367
|
case "Warning": {
|
|
1356
1368
|
const warning = message;
|
|
1357
1369
|
console.warn(`Streaming warning (code=${warning.warning_code}): ${warning.warning}`);
|
|
1358
|
-
(
|
|
1370
|
+
(_p = (_o = this.listeners).warning) === null || _p === void 0 ? void 0 : _p.call(_o, warning);
|
|
1359
1371
|
break;
|
|
1360
1372
|
}
|
|
1361
1373
|
case "Termination": {
|
|
1362
|
-
(
|
|
1374
|
+
(_q = this.sessionTerminatedResolve) === null || _q === void 0 ? void 0 : _q.call(this);
|
|
1363
1375
|
break;
|
|
1364
1376
|
}
|
|
1365
1377
|
}
|
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.4" },
|
|
39
39
|
};
|
|
40
40
|
if (typeof process !== "undefined") {
|
|
41
41
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -1100,13 +1100,18 @@ 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
|
+
}
|
|
1110
1115
|
if (this.params.languageDetection !== undefined) {
|
|
1111
1116
|
searchParams.set("language_detection", this.params.languageDetection.toString());
|
|
1112
1117
|
}
|
|
@@ -1167,6 +1172,9 @@ class StreamingTranscriber {
|
|
|
1167
1172
|
if (this.params.redactPiiSub !== undefined) {
|
|
1168
1173
|
searchParams.set("redact_pii_sub", this.params.redactPiiSub);
|
|
1169
1174
|
}
|
|
1175
|
+
if (this.params.mode !== undefined) {
|
|
1176
|
+
searchParams.set("mode", this.params.mode);
|
|
1177
|
+
}
|
|
1170
1178
|
if (this.params.llmGateway !== undefined) {
|
|
1171
1179
|
searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
|
|
1172
1180
|
}
|
|
@@ -1256,6 +1264,10 @@ class StreamingTranscriber {
|
|
|
1256
1264
|
this.listeners.llmGatewayResponse?.(message);
|
|
1257
1265
|
break;
|
|
1258
1266
|
}
|
|
1267
|
+
case "SpeakerRevision": {
|
|
1268
|
+
this.listeners.speakerRevision?.(message);
|
|
1269
|
+
break;
|
|
1270
|
+
}
|
|
1259
1271
|
case "Warning": {
|
|
1260
1272
|
const warning = message;
|
|
1261
1273
|
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.4" },
|
|
37
37
|
};
|
|
38
38
|
if (typeof process !== "undefined") {
|
|
39
39
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -1098,13 +1098,18 @@ 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
|
+
}
|
|
1108
1113
|
if (this.params.languageDetection !== undefined) {
|
|
1109
1114
|
searchParams.set("language_detection", this.params.languageDetection.toString());
|
|
1110
1115
|
}
|
|
@@ -1165,6 +1170,9 @@ class StreamingTranscriber {
|
|
|
1165
1170
|
if (this.params.redactPiiSub !== undefined) {
|
|
1166
1171
|
searchParams.set("redact_pii_sub", this.params.redactPiiSub);
|
|
1167
1172
|
}
|
|
1173
|
+
if (this.params.mode !== undefined) {
|
|
1174
|
+
searchParams.set("mode", this.params.mode);
|
|
1175
|
+
}
|
|
1168
1176
|
if (this.params.llmGateway !== undefined) {
|
|
1169
1177
|
searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
|
|
1170
1178
|
}
|
|
@@ -1254,6 +1262,10 @@ class StreamingTranscriber {
|
|
|
1254
1262
|
this.listeners.llmGatewayResponse?.(message);
|
|
1255
1263
|
break;
|
|
1256
1264
|
}
|
|
1265
|
+
case "SpeakerRevision": {
|
|
1266
|
+
this.listeners.speakerRevision?.(message);
|
|
1267
|
+
break;
|
|
1268
|
+
}
|
|
1257
1269
|
case "Warning": {
|
|
1258
1270
|
const warning = message;
|
|
1259
1271
|
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,18 @@ 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
|
+
}
|
|
661
666
|
if (this.params.languageDetection !== undefined) {
|
|
662
667
|
searchParams.set("language_detection", this.params.languageDetection.toString());
|
|
663
668
|
}
|
|
@@ -718,6 +723,9 @@ class StreamingTranscriber {
|
|
|
718
723
|
if (this.params.redactPiiSub !== undefined) {
|
|
719
724
|
searchParams.set("redact_pii_sub", this.params.redactPiiSub);
|
|
720
725
|
}
|
|
726
|
+
if (this.params.mode !== undefined) {
|
|
727
|
+
searchParams.set("mode", this.params.mode);
|
|
728
|
+
}
|
|
721
729
|
if (this.params.llmGateway !== undefined) {
|
|
722
730
|
searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
|
|
723
731
|
}
|
|
@@ -811,6 +819,10 @@ Learn more at https://github.com/AssemblyAI/assemblyai-node-sdk/blob/main/docs/c
|
|
|
811
819
|
this.listeners.llmGatewayResponse?.(message);
|
|
812
820
|
break;
|
|
813
821
|
}
|
|
822
|
+
case "SpeakerRevision": {
|
|
823
|
+
this.listeners.speakerRevision?.(message);
|
|
824
|
+
break;
|
|
825
|
+
}
|
|
814
826
|
case "Warning": {
|
|
815
827
|
const warning = message;
|
|
816
828
|
console.warn(`Streaming warning (code=${warning.warning_code}): ${warning.warning}`);
|
|
@@ -1153,7 +1165,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
1153
1165
|
defaultUserAgentString += navigator.userAgent;
|
|
1154
1166
|
}
|
|
1155
1167
|
const defaultUserAgent = {
|
|
1156
|
-
sdk: { name: "JavaScript", version: "4.34.
|
|
1168
|
+
sdk: { name: "JavaScript", version: "4.34.4" },
|
|
1157
1169
|
};
|
|
1158
1170
|
if (typeof process !== "undefined") {
|
|
1159
1171
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
package/dist/streaming.cjs
CHANGED
|
@@ -697,13 +697,18 @@ 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
|
+
}
|
|
707
712
|
if (this.params.languageDetection !== undefined) {
|
|
708
713
|
searchParams.set("language_detection", this.params.languageDetection.toString());
|
|
709
714
|
}
|
|
@@ -764,6 +769,9 @@ class StreamingTranscriber {
|
|
|
764
769
|
if (this.params.redactPiiSub !== undefined) {
|
|
765
770
|
searchParams.set("redact_pii_sub", this.params.redactPiiSub);
|
|
766
771
|
}
|
|
772
|
+
if (this.params.mode !== undefined) {
|
|
773
|
+
searchParams.set("mode", this.params.mode);
|
|
774
|
+
}
|
|
767
775
|
if (this.params.llmGateway !== undefined) {
|
|
768
776
|
searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
|
|
769
777
|
}
|
|
@@ -814,7 +822,7 @@ class StreamingTranscriber {
|
|
|
814
822
|
(_d = (_c = this.listeners).error) === null || _d === void 0 ? void 0 : _d.call(_c, new Error(event.message));
|
|
815
823
|
};
|
|
816
824
|
this.socket.onmessage = ({ data }) => {
|
|
817
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
825
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
818
826
|
const message = JSON.parse(data.toString());
|
|
819
827
|
if ("error" in message) {
|
|
820
828
|
const err = new StreamingError(message.error);
|
|
@@ -856,14 +864,18 @@ class StreamingTranscriber {
|
|
|
856
864
|
(_k = (_j = this.listeners).llmGatewayResponse) === null || _k === void 0 ? void 0 : _k.call(_j, message);
|
|
857
865
|
break;
|
|
858
866
|
}
|
|
867
|
+
case "SpeakerRevision": {
|
|
868
|
+
(_m = (_l = this.listeners).speakerRevision) === null || _m === void 0 ? void 0 : _m.call(_l, message);
|
|
869
|
+
break;
|
|
870
|
+
}
|
|
859
871
|
case "Warning": {
|
|
860
872
|
const warning = message;
|
|
861
873
|
console.warn(`Streaming warning (code=${warning.warning_code}): ${warning.warning}`);
|
|
862
|
-
(
|
|
874
|
+
(_p = (_o = this.listeners).warning) === null || _p === void 0 ? void 0 : _p.call(_o, warning);
|
|
863
875
|
break;
|
|
864
876
|
}
|
|
865
877
|
case "Termination": {
|
|
866
|
-
(
|
|
878
|
+
(_q = this.sessionTerminatedResolve) === null || _q === void 0 ? void 0 : _q.call(this);
|
|
867
879
|
break;
|
|
868
880
|
}
|
|
869
881
|
}
|
package/dist/streaming.mjs
CHANGED
|
@@ -695,13 +695,18 @@ 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
|
+
}
|
|
705
710
|
if (this.params.languageDetection !== undefined) {
|
|
706
711
|
searchParams.set("language_detection", this.params.languageDetection.toString());
|
|
707
712
|
}
|
|
@@ -762,6 +767,9 @@ class StreamingTranscriber {
|
|
|
762
767
|
if (this.params.redactPiiSub !== undefined) {
|
|
763
768
|
searchParams.set("redact_pii_sub", this.params.redactPiiSub);
|
|
764
769
|
}
|
|
770
|
+
if (this.params.mode !== undefined) {
|
|
771
|
+
searchParams.set("mode", this.params.mode);
|
|
772
|
+
}
|
|
765
773
|
if (this.params.llmGateway !== undefined) {
|
|
766
774
|
searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
|
|
767
775
|
}
|
|
@@ -812,7 +820,7 @@ class StreamingTranscriber {
|
|
|
812
820
|
(_d = (_c = this.listeners).error) === null || _d === void 0 ? void 0 : _d.call(_c, new Error(event.message));
|
|
813
821
|
};
|
|
814
822
|
this.socket.onmessage = ({ data }) => {
|
|
815
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
823
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
816
824
|
const message = JSON.parse(data.toString());
|
|
817
825
|
if ("error" in message) {
|
|
818
826
|
const err = new StreamingError(message.error);
|
|
@@ -854,14 +862,18 @@ class StreamingTranscriber {
|
|
|
854
862
|
(_k = (_j = this.listeners).llmGatewayResponse) === null || _k === void 0 ? void 0 : _k.call(_j, message);
|
|
855
863
|
break;
|
|
856
864
|
}
|
|
865
|
+
case "SpeakerRevision": {
|
|
866
|
+
(_m = (_l = this.listeners).speakerRevision) === null || _m === void 0 ? void 0 : _m.call(_l, message);
|
|
867
|
+
break;
|
|
868
|
+
}
|
|
857
869
|
case "Warning": {
|
|
858
870
|
const warning = message;
|
|
859
871
|
console.warn(`Streaming warning (code=${warning.warning_code}): ${warning.warning}`);
|
|
860
|
-
(
|
|
872
|
+
(_p = (_o = this.listeners).warning) === null || _p === void 0 ? void 0 : _p.call(_o, warning);
|
|
861
873
|
break;
|
|
862
874
|
}
|
|
863
875
|
case "Termination": {
|
|
864
|
-
(
|
|
876
|
+
(_q = this.sessionTerminatedResolve) === null || _q === void 0 ? void 0 : _q.call(this);
|
|
865
877
|
break;
|
|
866
878
|
}
|
|
867
879
|
}
|
|
@@ -86,7 +86,8 @@ export type StreamingTranscriberParams = {
|
|
|
86
86
|
keyterms?: string[];
|
|
87
87
|
keytermsPrompt?: string[];
|
|
88
88
|
prompt?: string;
|
|
89
|
-
|
|
89
|
+
agentContext?: string;
|
|
90
|
+
speechModel?: StreamingSpeechModel;
|
|
90
91
|
languageDetection?: boolean;
|
|
91
92
|
domain?: StreamingDomain;
|
|
92
93
|
inactivityTimeout?: number;
|
|
@@ -102,6 +103,7 @@ export type StreamingTranscriberParams = {
|
|
|
102
103
|
redactPii?: boolean;
|
|
103
104
|
redactPiiPolicies?: StreamingPiiPolicy[];
|
|
104
105
|
redactPiiSub?: StreamingPiiSubstitution;
|
|
106
|
+
mode?: StreamingMode;
|
|
105
107
|
llmGateway?: LLMGatewayConfig;
|
|
106
108
|
webhookUrl?: string;
|
|
107
109
|
webhookAuthHeaderName?: string;
|
|
@@ -136,19 +138,21 @@ export type StreamingTranscriberParams = {
|
|
|
136
138
|
/** Tuning for dual-channel attribution. Ignored when `channels` is unset. */
|
|
137
139
|
channelAttribution?: ChannelAttributionParams;
|
|
138
140
|
};
|
|
139
|
-
export type StreamingEvents = "open" | "close" | "turn" | "speechStarted" | "llmGatewayResponse" | "warning" | "vad" | "error";
|
|
141
|
+
export type StreamingEvents = "open" | "close" | "turn" | "speechStarted" | "llmGatewayResponse" | "speakerRevision" | "warning" | "vad" | "error";
|
|
140
142
|
export type StreamingListeners = {
|
|
141
143
|
open?: (event: BeginEvent) => void;
|
|
142
144
|
close?: (code: number, reason: string) => void;
|
|
143
145
|
turn?: (event: TurnEvent) => void;
|
|
144
146
|
speechStarted?: (event: SpeechStartedEvent) => void;
|
|
145
147
|
llmGatewayResponse?: (event: LLMGatewayResponseEvent) => void;
|
|
148
|
+
speakerRevision?: (event: SpeakerRevisionEvent) => void;
|
|
146
149
|
warning?: (event: WarningEvent) => void;
|
|
147
150
|
vad?: (event: VadFrame) => void;
|
|
148
151
|
error?: (error: Error) => void;
|
|
149
152
|
};
|
|
150
|
-
export type StreamingSpeechModel = "universal-streaming-english" | "universal-streaming-multilingual" | "u3-rt-pro" | "whisper-rt" | "u3-pro";
|
|
153
|
+
export type StreamingSpeechModel = "universal-streaming-english" | "universal-streaming-multilingual" | "u3-rt-pro" | "u3-rt-pro-beta-1" | "whisper-rt" | "u3-pro";
|
|
151
154
|
export type StreamingDomain = "medical-v1";
|
|
155
|
+
export type StreamingMode = "max_accuracy" | "min_latency" | "balanced";
|
|
152
156
|
export type VoiceFocusModel = "near-field" | "far-field";
|
|
153
157
|
export type StreamingPiiSubstitution = "hash" | "entity_name";
|
|
154
158
|
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 +234,7 @@ export type StreamingUpdateConfiguration = {
|
|
|
230
234
|
format_turns?: boolean;
|
|
231
235
|
keyterms_prompt?: string[];
|
|
232
236
|
prompt?: string;
|
|
237
|
+
agent_context?: string;
|
|
233
238
|
filter_profanity?: boolean;
|
|
234
239
|
interruption_delay?: number;
|
|
235
240
|
turn_left_pad_ms?: number;
|
|
@@ -253,5 +258,27 @@ export type LLMGatewayResponseEvent = {
|
|
|
253
258
|
transcript: string;
|
|
254
259
|
data: unknown;
|
|
255
260
|
};
|
|
256
|
-
|
|
261
|
+
/**
|
|
262
|
+
* A single earlier Turn whose speaker labels were revised by reclustering.
|
|
263
|
+
* Match by `turn_order` against the original Turn; replace its per-word
|
|
264
|
+
* `speaker` assignments (and the turn-level `speaker_label`) with these. Text
|
|
265
|
+
* and word timestamps are unchanged from the original Turn.
|
|
266
|
+
*/
|
|
267
|
+
export type SpeakerRevisionItem = {
|
|
268
|
+
turn_order: number;
|
|
269
|
+
speaker_label?: string;
|
|
270
|
+
words: StreamingWord[];
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Server-side correction to previously-emitted Turns' speaker labels.
|
|
274
|
+
* Diarization-only (emitted only when `speakerLabels` is enabled). Sent once
|
|
275
|
+
* per offline-recluster resolve; `revisions` carries one entry per earlier
|
|
276
|
+
* Turn whose label actually changed (unchanged turns are omitted). Apply each
|
|
277
|
+
* entry by matching its `turn_order`.
|
|
278
|
+
*/
|
|
279
|
+
export type SpeakerRevisionEvent = {
|
|
280
|
+
type: "SpeakerRevision";
|
|
281
|
+
revisions: SpeakerRevisionItem[];
|
|
282
|
+
};
|
|
283
|
+
export type StreamingEventMessage = BeginEvent | TurnEvent | SpeechStartedEvent | TerminationEvent | LLMGatewayResponseEvent | SpeakerRevisionEvent | ErrorEvent | WarningEvent;
|
|
257
284
|
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.4" },
|
|
32
32
|
};
|
|
33
33
|
if (typeof process !== "undefined") {
|
|
34
34
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -1103,13 +1103,18 @@ 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
|
+
}
|
|
1113
1118
|
if (this.params.languageDetection !== undefined) {
|
|
1114
1119
|
searchParams.set("language_detection", this.params.languageDetection.toString());
|
|
1115
1120
|
}
|
|
@@ -1170,6 +1175,9 @@ class StreamingTranscriber {
|
|
|
1170
1175
|
if (this.params.redactPiiSub !== undefined) {
|
|
1171
1176
|
searchParams.set("redact_pii_sub", this.params.redactPiiSub);
|
|
1172
1177
|
}
|
|
1178
|
+
if (this.params.mode !== undefined) {
|
|
1179
|
+
searchParams.set("mode", this.params.mode);
|
|
1180
|
+
}
|
|
1173
1181
|
if (this.params.llmGateway !== undefined) {
|
|
1174
1182
|
searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
|
|
1175
1183
|
}
|
|
@@ -1259,6 +1267,10 @@ class StreamingTranscriber {
|
|
|
1259
1267
|
this.listeners.llmGatewayResponse?.(message);
|
|
1260
1268
|
break;
|
|
1261
1269
|
}
|
|
1270
|
+
case "SpeakerRevision": {
|
|
1271
|
+
this.listeners.speakerRevision?.(message);
|
|
1272
|
+
break;
|
|
1273
|
+
}
|
|
1262
1274
|
case "Warning": {
|
|
1263
1275
|
const warning = message;
|
|
1264
1276
|
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.4",
|
|
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"
|