assemblyai 4.30.0 → 4.32.1

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/dist/index.cjs CHANGED
@@ -63,7 +63,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
63
63
  defaultUserAgentString += navigator.userAgent;
64
64
  }
65
65
  const defaultUserAgent = {
66
- sdk: { name: "JavaScript", version: "4.30.0" },
66
+ sdk: { name: "JavaScript", version: "4.32.1" },
67
67
  };
68
68
  if (typeof process !== "undefined") {
69
69
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -279,8 +279,18 @@ const StreamingErrorType = {
279
279
  BadSchema: 4101,
280
280
  TooManyStreams: 4102,
281
281
  Reconnected: 4103,
282
+ ServerError: 3005,
283
+ InputValidationError: 3006,
284
+ AudioChunkDurationViolation: 3007,
285
+ MaxSessionDurationExceeded: 3008,
286
+ ConcurrencyLimitExceeded: 3009,
282
287
  };
283
288
  const StreamingErrorMessages = {
289
+ [StreamingErrorType.ServerError]: "Server error",
290
+ [StreamingErrorType.InputValidationError]: "Input validation error",
291
+ [StreamingErrorType.AudioChunkDurationViolation]: "Audio chunk duration violation",
292
+ [StreamingErrorType.MaxSessionDurationExceeded]: "Session expired: maximum session duration exceeded",
293
+ [StreamingErrorType.ConcurrencyLimitExceeded]: "Too many concurrent sessions",
284
294
  [StreamingErrorType.BadSampleRate]: "Sample rate must be a positive integer",
285
295
  [StreamingErrorType.AuthFailed]: "Not Authorized",
286
296
  [StreamingErrorType.InsufficientFunds]: "Insufficient funds",
@@ -880,7 +890,7 @@ class StreamingTranscriber {
880
890
  }
881
891
  }
882
892
  connectionUrl() {
883
- var _a;
893
+ var _a, _b;
884
894
  const url = new URL((_a = this.params.websocketBaseUrl) !== null && _a !== void 0 ? _a : "");
885
895
  if (url.protocol !== "wss:") {
886
896
  throw new Error("Invalid protocol, must be wss");
@@ -893,12 +903,17 @@ class StreamingTranscriber {
893
903
  if (this.params.endOfTurnConfidenceThreshold) {
894
904
  searchParams.set("end_of_turn_confidence_threshold", this.params.endOfTurnConfidenceThreshold.toString());
895
905
  }
896
- if (this.params.minTurnSilence) {
897
- searchParams.set("min_turn_silence", this.params.minTurnSilence.toString());
906
+ if (this.params.minEndOfTurnSilenceWhenConfident !== undefined) {
907
+ if (this.params.minTurnSilence !== undefined) {
908
+ console.warn("[Deprecation Warning] Both `minEndOfTurnSilenceWhenConfident` and `minTurnSilence` are set. Using `minTurnSilence`; `minEndOfTurnSilenceWhenConfident` is deprecated.");
909
+ }
910
+ else {
911
+ console.warn("[Deprecation Warning] `minEndOfTurnSilenceWhenConfident` is deprecated and will be removed in a future release. Please use `minTurnSilence` instead.");
912
+ }
898
913
  }
899
- else if (this.params.minEndOfTurnSilenceWhenConfident) {
900
- console.warn("[Deprecation Warning] `minEndOfTurnSilenceWhenConfident` is deprecated and will be removed in a future release. Please use `minTurnSilence` instead.");
901
- searchParams.set("min_end_of_turn_silence_when_confident", this.params.minEndOfTurnSilenceWhenConfident.toString());
914
+ const effectiveMinTurnSilence = (_b = this.params.minTurnSilence) !== null && _b !== void 0 ? _b : this.params.minEndOfTurnSilenceWhenConfident;
915
+ if (effectiveMinTurnSilence !== undefined) {
916
+ searchParams.set("min_turn_silence", effectiveMinTurnSilence.toString());
902
917
  }
903
918
  if (this.params.maxTurnSilence) {
904
919
  searchParams.set("max_turn_silence", this.params.maxTurnSilence.toString());
@@ -944,6 +959,12 @@ class StreamingTranscriber {
944
959
  if (this.params.maxSpeakers !== undefined) {
945
960
  searchParams.set("max_speakers", this.params.maxSpeakers.toString());
946
961
  }
962
+ if (this.params.noiseSuppressionModel) {
963
+ searchParams.set("noise_suppression_model", this.params.noiseSuppressionModel);
964
+ }
965
+ if (this.params.noiseSuppressionThreshold !== undefined) {
966
+ searchParams.set("noise_suppression_threshold", this.params.noiseSuppressionThreshold.toString());
967
+ }
947
968
  if (this.params.llmGateway !== undefined) {
948
969
  searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
949
970
  }
@@ -987,10 +1008,15 @@ class StreamingTranscriber {
987
1008
  (_d = (_c = this.listeners).error) === null || _d === void 0 ? void 0 : _d.call(_c, new Error(event.message));
988
1009
  };
989
1010
  this.socket.onmessage = ({ data }) => {
990
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1011
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
991
1012
  const message = JSON.parse(data.toString());
992
1013
  if ("error" in message) {
993
- (_b = (_a = this.listeners).error) === null || _b === void 0 ? void 0 : _b.call(_a, new StreamingError(message.error));
1014
+ const err = new StreamingError(message.error);
1015
+ if ("error_code" in message) {
1016
+ err.code =
1017
+ message.error_code;
1018
+ }
1019
+ (_b = (_a = this.listeners).error) === null || _b === void 0 ? void 0 : _b.call(_a, err);
994
1020
  return;
995
1021
  }
996
1022
  switch (message.type) {
@@ -1011,8 +1037,14 @@ class StreamingTranscriber {
1011
1037
  (_k = (_j = this.listeners).llmGatewayResponse) === null || _k === void 0 ? void 0 : _k.call(_j, message);
1012
1038
  break;
1013
1039
  }
1040
+ case "Warning": {
1041
+ const warning = message;
1042
+ console.warn(`Streaming warning (code=${warning.warning_code}): ${warning.warning}`);
1043
+ (_m = (_l = this.listeners).warning) === null || _m === void 0 ? void 0 : _m.call(_l, warning);
1044
+ break;
1045
+ }
1014
1046
  case "Termination": {
1015
- (_l = this.sessionTerminatedResolve) === null || _l === void 0 ? void 0 : _l.call(this);
1047
+ (_o = this.sessionTerminatedResolve) === null || _o === void 0 ? void 0 : _o.call(this);
1016
1048
  break;
1017
1049
  }
1018
1050
  }
@@ -1034,7 +1066,17 @@ class StreamingTranscriber {
1034
1066
  * @param config - The configuration parameters to update
1035
1067
  */
1036
1068
  updateConfiguration(config) {
1037
- const message = Object.assign({ type: "UpdateConfiguration" }, config);
1069
+ const { min_end_of_turn_silence_when_confident, min_turn_silence } = config, rest = __rest(config, ["min_end_of_turn_silence_when_confident", "min_turn_silence"]);
1070
+ if (min_end_of_turn_silence_when_confident !== undefined) {
1071
+ if (min_turn_silence !== undefined) {
1072
+ console.warn("[Deprecation Warning] Both `min_end_of_turn_silence_when_confident` and `min_turn_silence` are set. Using `min_turn_silence`; `min_end_of_turn_silence_when_confident` is deprecated.");
1073
+ }
1074
+ else {
1075
+ console.warn("[Deprecation Warning] `min_end_of_turn_silence_when_confident` is deprecated and will be removed in a future release. Please use `min_turn_silence` instead.");
1076
+ }
1077
+ }
1078
+ const effective = min_turn_silence !== null && min_turn_silence !== void 0 ? min_turn_silence : min_end_of_turn_silence_when_confident;
1079
+ const message = Object.assign(Object.assign({ type: "UpdateConfiguration" }, rest), (effective !== undefined ? { min_turn_silence: effective } : {}));
1038
1080
  this.send(JSON.stringify(message));
1039
1081
  }
1040
1082
  /**
package/dist/index.mjs CHANGED
@@ -61,7 +61,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
61
61
  defaultUserAgentString += navigator.userAgent;
62
62
  }
63
63
  const defaultUserAgent = {
64
- sdk: { name: "JavaScript", version: "4.30.0" },
64
+ sdk: { name: "JavaScript", version: "4.32.1" },
65
65
  };
66
66
  if (typeof process !== "undefined") {
67
67
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -277,8 +277,18 @@ const StreamingErrorType = {
277
277
  BadSchema: 4101,
278
278
  TooManyStreams: 4102,
279
279
  Reconnected: 4103,
280
+ ServerError: 3005,
281
+ InputValidationError: 3006,
282
+ AudioChunkDurationViolation: 3007,
283
+ MaxSessionDurationExceeded: 3008,
284
+ ConcurrencyLimitExceeded: 3009,
280
285
  };
281
286
  const StreamingErrorMessages = {
287
+ [StreamingErrorType.ServerError]: "Server error",
288
+ [StreamingErrorType.InputValidationError]: "Input validation error",
289
+ [StreamingErrorType.AudioChunkDurationViolation]: "Audio chunk duration violation",
290
+ [StreamingErrorType.MaxSessionDurationExceeded]: "Session expired: maximum session duration exceeded",
291
+ [StreamingErrorType.ConcurrencyLimitExceeded]: "Too many concurrent sessions",
282
292
  [StreamingErrorType.BadSampleRate]: "Sample rate must be a positive integer",
283
293
  [StreamingErrorType.AuthFailed]: "Not Authorized",
284
294
  [StreamingErrorType.InsufficientFunds]: "Insufficient funds",
@@ -878,7 +888,7 @@ class StreamingTranscriber {
878
888
  }
879
889
  }
880
890
  connectionUrl() {
881
- var _a;
891
+ var _a, _b;
882
892
  const url = new URL((_a = this.params.websocketBaseUrl) !== null && _a !== void 0 ? _a : "");
883
893
  if (url.protocol !== "wss:") {
884
894
  throw new Error("Invalid protocol, must be wss");
@@ -891,12 +901,17 @@ class StreamingTranscriber {
891
901
  if (this.params.endOfTurnConfidenceThreshold) {
892
902
  searchParams.set("end_of_turn_confidence_threshold", this.params.endOfTurnConfidenceThreshold.toString());
893
903
  }
894
- if (this.params.minTurnSilence) {
895
- searchParams.set("min_turn_silence", this.params.minTurnSilence.toString());
904
+ if (this.params.minEndOfTurnSilenceWhenConfident !== undefined) {
905
+ if (this.params.minTurnSilence !== undefined) {
906
+ console.warn("[Deprecation Warning] Both `minEndOfTurnSilenceWhenConfident` and `minTurnSilence` are set. Using `minTurnSilence`; `minEndOfTurnSilenceWhenConfident` is deprecated.");
907
+ }
908
+ else {
909
+ console.warn("[Deprecation Warning] `minEndOfTurnSilenceWhenConfident` is deprecated and will be removed in a future release. Please use `minTurnSilence` instead.");
910
+ }
896
911
  }
897
- else if (this.params.minEndOfTurnSilenceWhenConfident) {
898
- console.warn("[Deprecation Warning] `minEndOfTurnSilenceWhenConfident` is deprecated and will be removed in a future release. Please use `minTurnSilence` instead.");
899
- searchParams.set("min_end_of_turn_silence_when_confident", this.params.minEndOfTurnSilenceWhenConfident.toString());
912
+ const effectiveMinTurnSilence = (_b = this.params.minTurnSilence) !== null && _b !== void 0 ? _b : this.params.minEndOfTurnSilenceWhenConfident;
913
+ if (effectiveMinTurnSilence !== undefined) {
914
+ searchParams.set("min_turn_silence", effectiveMinTurnSilence.toString());
900
915
  }
901
916
  if (this.params.maxTurnSilence) {
902
917
  searchParams.set("max_turn_silence", this.params.maxTurnSilence.toString());
@@ -942,6 +957,12 @@ class StreamingTranscriber {
942
957
  if (this.params.maxSpeakers !== undefined) {
943
958
  searchParams.set("max_speakers", this.params.maxSpeakers.toString());
944
959
  }
960
+ if (this.params.noiseSuppressionModel) {
961
+ searchParams.set("noise_suppression_model", this.params.noiseSuppressionModel);
962
+ }
963
+ if (this.params.noiseSuppressionThreshold !== undefined) {
964
+ searchParams.set("noise_suppression_threshold", this.params.noiseSuppressionThreshold.toString());
965
+ }
945
966
  if (this.params.llmGateway !== undefined) {
946
967
  searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
947
968
  }
@@ -985,10 +1006,15 @@ class StreamingTranscriber {
985
1006
  (_d = (_c = this.listeners).error) === null || _d === void 0 ? void 0 : _d.call(_c, new Error(event.message));
986
1007
  };
987
1008
  this.socket.onmessage = ({ data }) => {
988
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1009
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
989
1010
  const message = JSON.parse(data.toString());
990
1011
  if ("error" in message) {
991
- (_b = (_a = this.listeners).error) === null || _b === void 0 ? void 0 : _b.call(_a, new StreamingError(message.error));
1012
+ const err = new StreamingError(message.error);
1013
+ if ("error_code" in message) {
1014
+ err.code =
1015
+ message.error_code;
1016
+ }
1017
+ (_b = (_a = this.listeners).error) === null || _b === void 0 ? void 0 : _b.call(_a, err);
992
1018
  return;
993
1019
  }
994
1020
  switch (message.type) {
@@ -1009,8 +1035,14 @@ class StreamingTranscriber {
1009
1035
  (_k = (_j = this.listeners).llmGatewayResponse) === null || _k === void 0 ? void 0 : _k.call(_j, message);
1010
1036
  break;
1011
1037
  }
1038
+ case "Warning": {
1039
+ const warning = message;
1040
+ console.warn(`Streaming warning (code=${warning.warning_code}): ${warning.warning}`);
1041
+ (_m = (_l = this.listeners).warning) === null || _m === void 0 ? void 0 : _m.call(_l, warning);
1042
+ break;
1043
+ }
1012
1044
  case "Termination": {
1013
- (_l = this.sessionTerminatedResolve) === null || _l === void 0 ? void 0 : _l.call(this);
1045
+ (_o = this.sessionTerminatedResolve) === null || _o === void 0 ? void 0 : _o.call(this);
1014
1046
  break;
1015
1047
  }
1016
1048
  }
@@ -1032,7 +1064,17 @@ class StreamingTranscriber {
1032
1064
  * @param config - The configuration parameters to update
1033
1065
  */
1034
1066
  updateConfiguration(config) {
1035
- const message = Object.assign({ type: "UpdateConfiguration" }, config);
1067
+ const { min_end_of_turn_silence_when_confident, min_turn_silence } = config, rest = __rest(config, ["min_end_of_turn_silence_when_confident", "min_turn_silence"]);
1068
+ if (min_end_of_turn_silence_when_confident !== undefined) {
1069
+ if (min_turn_silence !== undefined) {
1070
+ console.warn("[Deprecation Warning] Both `min_end_of_turn_silence_when_confident` and `min_turn_silence` are set. Using `min_turn_silence`; `min_end_of_turn_silence_when_confident` is deprecated.");
1071
+ }
1072
+ else {
1073
+ console.warn("[Deprecation Warning] `min_end_of_turn_silence_when_confident` is deprecated and will be removed in a future release. Please use `min_turn_silence` instead.");
1074
+ }
1075
+ }
1076
+ const effective = min_turn_silence !== null && min_turn_silence !== void 0 ? min_turn_silence : min_end_of_turn_silence_when_confident;
1077
+ const message = Object.assign(Object.assign({ type: "UpdateConfiguration" }, rest), (effective !== undefined ? { min_turn_silence: effective } : {}));
1036
1078
  this.send(JSON.stringify(message));
1037
1079
  }
1038
1080
  /**
package/dist/node.cjs CHANGED
@@ -22,7 +22,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
22
22
  defaultUserAgentString += navigator.userAgent;
23
23
  }
24
24
  const defaultUserAgent = {
25
- sdk: { name: "JavaScript", version: "4.30.0" },
25
+ sdk: { name: "JavaScript", version: "4.32.1" },
26
26
  };
27
27
  if (typeof process !== "undefined") {
28
28
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -221,8 +221,18 @@ const StreamingErrorType = {
221
221
  BadSchema: 4101,
222
222
  TooManyStreams: 4102,
223
223
  Reconnected: 4103,
224
+ ServerError: 3005,
225
+ InputValidationError: 3006,
226
+ AudioChunkDurationViolation: 3007,
227
+ MaxSessionDurationExceeded: 3008,
228
+ ConcurrencyLimitExceeded: 3009,
224
229
  };
225
230
  const StreamingErrorMessages = {
231
+ [StreamingErrorType.ServerError]: "Server error",
232
+ [StreamingErrorType.InputValidationError]: "Input validation error",
233
+ [StreamingErrorType.AudioChunkDurationViolation]: "Audio chunk duration violation",
234
+ [StreamingErrorType.MaxSessionDurationExceeded]: "Session expired: maximum session duration exceeded",
235
+ [StreamingErrorType.ConcurrencyLimitExceeded]: "Too many concurrent sessions",
226
236
  [StreamingErrorType.BadSampleRate]: "Sample rate must be a positive integer",
227
237
  [StreamingErrorType.AuthFailed]: "Not Authorized",
228
238
  [StreamingErrorType.InsufficientFunds]: "Insufficient funds",
@@ -801,12 +811,18 @@ class StreamingTranscriber {
801
811
  if (this.params.endOfTurnConfidenceThreshold) {
802
812
  searchParams.set("end_of_turn_confidence_threshold", this.params.endOfTurnConfidenceThreshold.toString());
803
813
  }
804
- if (this.params.minTurnSilence) {
805
- searchParams.set("min_turn_silence", this.params.minTurnSilence.toString());
814
+ if (this.params.minEndOfTurnSilenceWhenConfident !== undefined) {
815
+ if (this.params.minTurnSilence !== undefined) {
816
+ console.warn("[Deprecation Warning] Both `minEndOfTurnSilenceWhenConfident` and `minTurnSilence` are set. Using `minTurnSilence`; `minEndOfTurnSilenceWhenConfident` is deprecated.");
817
+ }
818
+ else {
819
+ console.warn("[Deprecation Warning] `minEndOfTurnSilenceWhenConfident` is deprecated and will be removed in a future release. Please use `minTurnSilence` instead.");
820
+ }
806
821
  }
807
- else if (this.params.minEndOfTurnSilenceWhenConfident) {
808
- console.warn("[Deprecation Warning] `minEndOfTurnSilenceWhenConfident` is deprecated and will be removed in a future release. Please use `minTurnSilence` instead.");
809
- searchParams.set("min_end_of_turn_silence_when_confident", this.params.minEndOfTurnSilenceWhenConfident.toString());
822
+ const effectiveMinTurnSilence = this.params.minTurnSilence ??
823
+ this.params.minEndOfTurnSilenceWhenConfident;
824
+ if (effectiveMinTurnSilence !== undefined) {
825
+ searchParams.set("min_turn_silence", effectiveMinTurnSilence.toString());
810
826
  }
811
827
  if (this.params.maxTurnSilence) {
812
828
  searchParams.set("max_turn_silence", this.params.maxTurnSilence.toString());
@@ -852,6 +868,12 @@ class StreamingTranscriber {
852
868
  if (this.params.maxSpeakers !== undefined) {
853
869
  searchParams.set("max_speakers", this.params.maxSpeakers.toString());
854
870
  }
871
+ if (this.params.noiseSuppressionModel) {
872
+ searchParams.set("noise_suppression_model", this.params.noiseSuppressionModel);
873
+ }
874
+ if (this.params.noiseSuppressionThreshold !== undefined) {
875
+ searchParams.set("noise_suppression_threshold", this.params.noiseSuppressionThreshold.toString());
876
+ }
855
877
  if (this.params.llmGateway !== undefined) {
856
878
  searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
857
879
  }
@@ -895,7 +917,12 @@ class StreamingTranscriber {
895
917
  this.socket.onmessage = ({ data }) => {
896
918
  const message = JSON.parse(data.toString());
897
919
  if ("error" in message) {
898
- this.listeners.error?.(new StreamingError(message.error));
920
+ const err = new StreamingError(message.error);
921
+ if ("error_code" in message) {
922
+ err.code =
923
+ message.error_code;
924
+ }
925
+ this.listeners.error?.(err);
899
926
  return;
900
927
  }
901
928
  switch (message.type) {
@@ -916,6 +943,12 @@ class StreamingTranscriber {
916
943
  this.listeners.llmGatewayResponse?.(message);
917
944
  break;
918
945
  }
946
+ case "Warning": {
947
+ const warning = message;
948
+ console.warn(`Streaming warning (code=${warning.warning_code}): ${warning.warning}`);
949
+ this.listeners.warning?.(warning);
950
+ break;
951
+ }
919
952
  case "Termination": {
920
953
  this.sessionTerminatedResolve?.();
921
954
  break;
@@ -939,9 +972,20 @@ class StreamingTranscriber {
939
972
  * @param config - The configuration parameters to update
940
973
  */
941
974
  updateConfiguration(config) {
975
+ const { min_end_of_turn_silence_when_confident, min_turn_silence, ...rest } = config;
976
+ if (min_end_of_turn_silence_when_confident !== undefined) {
977
+ if (min_turn_silence !== undefined) {
978
+ console.warn("[Deprecation Warning] Both `min_end_of_turn_silence_when_confident` and `min_turn_silence` are set. Using `min_turn_silence`; `min_end_of_turn_silence_when_confident` is deprecated.");
979
+ }
980
+ else {
981
+ console.warn("[Deprecation Warning] `min_end_of_turn_silence_when_confident` is deprecated and will be removed in a future release. Please use `min_turn_silence` instead.");
982
+ }
983
+ }
984
+ const effective = min_turn_silence ?? min_end_of_turn_silence_when_confident;
942
985
  const message = {
943
986
  type: "UpdateConfiguration",
944
- ...config,
987
+ ...rest,
988
+ ...(effective !== undefined ? { min_turn_silence: effective } : {}),
945
989
  };
946
990
  this.send(JSON.stringify(message));
947
991
  }
package/dist/node.mjs CHANGED
@@ -20,7 +20,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
20
20
  defaultUserAgentString += navigator.userAgent;
21
21
  }
22
22
  const defaultUserAgent = {
23
- sdk: { name: "JavaScript", version: "4.30.0" },
23
+ sdk: { name: "JavaScript", version: "4.32.1" },
24
24
  };
25
25
  if (typeof process !== "undefined") {
26
26
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -219,8 +219,18 @@ const StreamingErrorType = {
219
219
  BadSchema: 4101,
220
220
  TooManyStreams: 4102,
221
221
  Reconnected: 4103,
222
+ ServerError: 3005,
223
+ InputValidationError: 3006,
224
+ AudioChunkDurationViolation: 3007,
225
+ MaxSessionDurationExceeded: 3008,
226
+ ConcurrencyLimitExceeded: 3009,
222
227
  };
223
228
  const StreamingErrorMessages = {
229
+ [StreamingErrorType.ServerError]: "Server error",
230
+ [StreamingErrorType.InputValidationError]: "Input validation error",
231
+ [StreamingErrorType.AudioChunkDurationViolation]: "Audio chunk duration violation",
232
+ [StreamingErrorType.MaxSessionDurationExceeded]: "Session expired: maximum session duration exceeded",
233
+ [StreamingErrorType.ConcurrencyLimitExceeded]: "Too many concurrent sessions",
224
234
  [StreamingErrorType.BadSampleRate]: "Sample rate must be a positive integer",
225
235
  [StreamingErrorType.AuthFailed]: "Not Authorized",
226
236
  [StreamingErrorType.InsufficientFunds]: "Insufficient funds",
@@ -799,12 +809,18 @@ class StreamingTranscriber {
799
809
  if (this.params.endOfTurnConfidenceThreshold) {
800
810
  searchParams.set("end_of_turn_confidence_threshold", this.params.endOfTurnConfidenceThreshold.toString());
801
811
  }
802
- if (this.params.minTurnSilence) {
803
- searchParams.set("min_turn_silence", this.params.minTurnSilence.toString());
812
+ if (this.params.minEndOfTurnSilenceWhenConfident !== undefined) {
813
+ if (this.params.minTurnSilence !== undefined) {
814
+ console.warn("[Deprecation Warning] Both `minEndOfTurnSilenceWhenConfident` and `minTurnSilence` are set. Using `minTurnSilence`; `minEndOfTurnSilenceWhenConfident` is deprecated.");
815
+ }
816
+ else {
817
+ console.warn("[Deprecation Warning] `minEndOfTurnSilenceWhenConfident` is deprecated and will be removed in a future release. Please use `minTurnSilence` instead.");
818
+ }
804
819
  }
805
- else if (this.params.minEndOfTurnSilenceWhenConfident) {
806
- console.warn("[Deprecation Warning] `minEndOfTurnSilenceWhenConfident` is deprecated and will be removed in a future release. Please use `minTurnSilence` instead.");
807
- searchParams.set("min_end_of_turn_silence_when_confident", this.params.minEndOfTurnSilenceWhenConfident.toString());
820
+ const effectiveMinTurnSilence = this.params.minTurnSilence ??
821
+ this.params.minEndOfTurnSilenceWhenConfident;
822
+ if (effectiveMinTurnSilence !== undefined) {
823
+ searchParams.set("min_turn_silence", effectiveMinTurnSilence.toString());
808
824
  }
809
825
  if (this.params.maxTurnSilence) {
810
826
  searchParams.set("max_turn_silence", this.params.maxTurnSilence.toString());
@@ -850,6 +866,12 @@ class StreamingTranscriber {
850
866
  if (this.params.maxSpeakers !== undefined) {
851
867
  searchParams.set("max_speakers", this.params.maxSpeakers.toString());
852
868
  }
869
+ if (this.params.noiseSuppressionModel) {
870
+ searchParams.set("noise_suppression_model", this.params.noiseSuppressionModel);
871
+ }
872
+ if (this.params.noiseSuppressionThreshold !== undefined) {
873
+ searchParams.set("noise_suppression_threshold", this.params.noiseSuppressionThreshold.toString());
874
+ }
853
875
  if (this.params.llmGateway !== undefined) {
854
876
  searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
855
877
  }
@@ -893,7 +915,12 @@ class StreamingTranscriber {
893
915
  this.socket.onmessage = ({ data }) => {
894
916
  const message = JSON.parse(data.toString());
895
917
  if ("error" in message) {
896
- this.listeners.error?.(new StreamingError(message.error));
918
+ const err = new StreamingError(message.error);
919
+ if ("error_code" in message) {
920
+ err.code =
921
+ message.error_code;
922
+ }
923
+ this.listeners.error?.(err);
897
924
  return;
898
925
  }
899
926
  switch (message.type) {
@@ -914,6 +941,12 @@ class StreamingTranscriber {
914
941
  this.listeners.llmGatewayResponse?.(message);
915
942
  break;
916
943
  }
944
+ case "Warning": {
945
+ const warning = message;
946
+ console.warn(`Streaming warning (code=${warning.warning_code}): ${warning.warning}`);
947
+ this.listeners.warning?.(warning);
948
+ break;
949
+ }
917
950
  case "Termination": {
918
951
  this.sessionTerminatedResolve?.();
919
952
  break;
@@ -937,9 +970,20 @@ class StreamingTranscriber {
937
970
  * @param config - The configuration parameters to update
938
971
  */
939
972
  updateConfiguration(config) {
973
+ const { min_end_of_turn_silence_when_confident, min_turn_silence, ...rest } = config;
974
+ if (min_end_of_turn_silence_when_confident !== undefined) {
975
+ if (min_turn_silence !== undefined) {
976
+ console.warn("[Deprecation Warning] Both `min_end_of_turn_silence_when_confident` and `min_turn_silence` are set. Using `min_turn_silence`; `min_end_of_turn_silence_when_confident` is deprecated.");
977
+ }
978
+ else {
979
+ console.warn("[Deprecation Warning] `min_end_of_turn_silence_when_confident` is deprecated and will be removed in a future release. Please use `min_turn_silence` instead.");
980
+ }
981
+ }
982
+ const effective = min_turn_silence ?? min_end_of_turn_silence_when_confident;
940
983
  const message = {
941
984
  type: "UpdateConfiguration",
942
- ...config,
985
+ ...rest,
986
+ ...(effective !== undefined ? { min_turn_silence: effective } : {}),
943
987
  };
944
988
  this.send(JSON.stringify(message));
945
989
  }
@@ -1,4 +1,4 @@
1
- import { StreamingTranscriberParams, AudioData, BeginEvent, TurnEvent, LLMGatewayResponseEvent, StreamingUpdateConfiguration } from "../..";
1
+ import { StreamingTranscriberParams, AudioData, BeginEvent, TurnEvent, LLMGatewayResponseEvent, StreamingUpdateConfiguration, WarningEvent } from "../..";
2
2
  export declare class StreamingTranscriber {
3
3
  private apiKey?;
4
4
  private token?;
@@ -11,6 +11,7 @@ export declare class StreamingTranscriber {
11
11
  on(event: "open", listener: (event: BeginEvent) => void): void;
12
12
  on(event: "turn", listener: (event: TurnEvent) => void): void;
13
13
  on(event: "llmGatewayResponse", listener: (event: LLMGatewayResponseEvent) => void): void;
14
+ on(event: "warning", listener: (event: WarningEvent) => void): void;
14
15
  on(event: "error", listener: (error: Error) => void): void;
15
16
  on(event: "close", listener: (code: number, reason: string) => void): void;
16
17
  connect(): Promise<BeginEvent>;
@@ -2634,6 +2634,10 @@ export type Transcript = {
2634
2634
  * See {@link https://www.assemblyai.com/docs/models/pii-redaction | PII redaction } for more information.
2635
2635
  */
2636
2636
  redact_pii_policies?: PiiPolicy[] | null;
2637
+ /**
2638
+ * Whether the unredacted text, words, and utterances were also returned alongside the redacted fields. Only applies when `redact_pii` is enabled.
2639
+ */
2640
+ redact_pii_return_unredacted?: boolean | null;
2637
2641
  /**
2638
2642
  * The replacement logic for detected PII, can be "entity_type" or "hash". See {@link https://www.assemblyai.com/docs/models/pii-redaction | PII redaction } for more details.
2639
2643
  */
@@ -2723,6 +2727,18 @@ export type Transcript = {
2723
2727
  * The list of custom topics provided if custom topics is enabled
2724
2728
  */
2725
2729
  topics?: string[];
2730
+ /**
2731
+ * The unredacted transcript text. Returned only when `redact_pii_return_unredacted` was set with `redact_pii`.
2732
+ */
2733
+ unredacted_text?: string | null;
2734
+ /**
2735
+ * The unredacted list of utterances. Returned only when `redact_pii_return_unredacted` was set with `redact_pii` and channel/speaker modes are enabled.
2736
+ */
2737
+ unredacted_utterances?: TranscriptUtterance[] | null;
2738
+ /**
2739
+ * The unredacted list of individual words. Returned only when `redact_pii_return_unredacted` was set with `redact_pii`.
2740
+ */
2741
+ unredacted_words?: TranscriptWord[] | null;
2726
2742
  /**
2727
2743
  * When dual_channel or speaker_labels is enabled, a list of turn-by-turn utterance objects.
2728
2744
  * See {@link https://www.assemblyai.com/docs/models/speaker-diarization | Speaker diarization } for more information.
@@ -3093,6 +3109,11 @@ export type TranscriptOptionalParams = {
3093
3109
  * The list of PII Redaction policies to enable. See {@link https://www.assemblyai.com/docs/models/pii-redaction | PII redaction } for more details.
3094
3110
  */
3095
3111
  redact_pii_policies?: PiiPolicy[];
3112
+ /**
3113
+ * If `redact_pii` is enabled, also return the unredacted text, words, and utterances alongside the redacted fields.
3114
+ * @defaultValue false
3115
+ */
3116
+ redact_pii_return_unredacted?: boolean;
3096
3117
  /**
3097
3118
  * The replacement logic for detected PII, can be "entity_type" or "hash". See {@link https://www.assemblyai.com/docs/models/pii-redaction | PII redaction } for more details.
3098
3119
  * @defaultValue "hash"
@@ -33,19 +33,23 @@ export type StreamingTranscriberParams = {
33
33
  inactivityTimeout?: number;
34
34
  speakerLabels?: boolean;
35
35
  maxSpeakers?: number;
36
+ noiseSuppressionModel?: NoiseSuppressionModel;
37
+ noiseSuppressionThreshold?: number;
36
38
  llmGateway?: LLMGatewayConfig;
37
39
  };
38
- export type StreamingEvents = "open" | "close" | "turn" | "speechStarted" | "llmGatewayResponse" | "error";
40
+ export type StreamingEvents = "open" | "close" | "turn" | "speechStarted" | "llmGatewayResponse" | "warning" | "error";
39
41
  export type StreamingListeners = {
40
42
  open?: (event: BeginEvent) => void;
41
43
  close?: (code: number, reason: string) => void;
42
44
  turn?: (event: TurnEvent) => void;
43
45
  speechStarted?: (event: SpeechStartedEvent) => void;
44
46
  llmGatewayResponse?: (event: LLMGatewayResponseEvent) => void;
47
+ warning?: (event: WarningEvent) => void;
45
48
  error?: (error: Error) => void;
46
49
  };
47
50
  export type StreamingSpeechModel = "universal-streaming-english" | "universal-streaming-multilingual" | "u3-rt-pro" | "whisper-rt" | "u3-pro";
48
51
  export type StreamingDomain = "medical-v1";
52
+ export type NoiseSuppressionModel = "near-field" | "far-field";
49
53
  export type StreamingTokenParams = {
50
54
  expires_in_seconds: number;
51
55
  max_session_duration_seconds?: number;
@@ -109,13 +113,20 @@ export type StreamingForceEndpoint = {
109
113
  type: "ForceEndpoint";
110
114
  };
111
115
  export type ErrorEvent = {
116
+ type: "Error";
117
+ error_code?: number;
112
118
  error: string;
113
119
  };
120
+ export type WarningEvent = {
121
+ type: "Warning";
122
+ warning_code: number;
123
+ warning: string;
124
+ };
114
125
  export type LLMGatewayResponseEvent = {
115
126
  type: "LLMGatewayResponse";
116
127
  turn_order: number;
117
128
  transcript: string;
118
129
  data: unknown;
119
130
  };
120
- export type StreamingEventMessage = BeginEvent | TurnEvent | SpeechStartedEvent | TerminationEvent | LLMGatewayResponseEvent | ErrorEvent;
131
+ export type StreamingEventMessage = BeginEvent | TurnEvent | SpeechStartedEvent | TerminationEvent | LLMGatewayResponseEvent | ErrorEvent | WarningEvent;
121
132
  export type StreamingOperationMessage = StreamingUpdateConfiguration | StreamingForceEndpoint | StreamingTerminateSession;
@@ -15,6 +15,11 @@ declare const StreamingErrorType: {
15
15
  readonly BadSchema: 4101;
16
16
  readonly TooManyStreams: 4102;
17
17
  readonly Reconnected: 4103;
18
+ readonly ServerError: 3005;
19
+ readonly InputValidationError: 3006;
20
+ readonly AudioChunkDurationViolation: 3007;
21
+ readonly MaxSessionDurationExceeded: 3008;
22
+ readonly ConcurrencyLimitExceeded: 3009;
18
23
  };
19
24
  type StreamingErrorTypeCodes = (typeof StreamingErrorType)[keyof typeof StreamingErrorType];
20
25
  declare const StreamingErrorMessages: Record<StreamingErrorTypeCodes, string>;