assemblyai 4.32.1 → 4.33.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.33.0]
4
+
5
+ - Add streaming parameters to match the Python SDK:
6
+ - `voiceFocus` and `voiceFocusThreshold` (replaces the unreleased `noiseSuppressionModel` / `noiseSuppressionThreshold`)
7
+ - `continuousPartials` (U3Pro speech models only)
8
+ - `customerSupportAudioCapture` — internal/unstable; sent on the wire as `_customer_support_audio_capture` to mirror the server's stability marker. Records session audio for AssemblyAI support; only enable when coordinating with support
9
+ - `includePartialTurns` — explicitly include or exclude partial (non-final) turns
10
+ - `redactPii`, `redactPiiPolicies`, `redactPiiSub` — server-side PII redaction on final turns
11
+ - `webhookUrl`, `webhookAuthHeaderName`, `webhookAuthHeaderValue`
12
+ - Add `StreamingPiiPolicy` and `StreamingPiiSubstitution` exported types. `StreamingPiiPolicy` covers the full server-side `AAIEntities` enum (65 entities)
13
+ - Add `speaker` field to `StreamingWord`
14
+
3
15
  ## [4.20.0]
4
16
 
5
17
  - Add `on_low_language_confidence` property to `LanguageDetectionOptions`
@@ -65,7 +65,7 @@
65
65
  defaultUserAgentString += navigator.userAgent;
66
66
  }
67
67
  const defaultUserAgent = {
68
- sdk: { name: "JavaScript", version: "4.32.1" },
68
+ sdk: { name: "JavaScript", version: "4.33.1" },
69
69
  };
70
70
  if (typeof process !== "undefined") {
71
71
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -972,11 +972,47 @@ Learn more at https://github.com/AssemblyAI/assemblyai-node-sdk/blob/main/docs/c
972
972
  if (this.params.maxSpeakers !== undefined) {
973
973
  searchParams.set("max_speakers", this.params.maxSpeakers.toString());
974
974
  }
975
- if (this.params.noiseSuppressionModel) {
976
- searchParams.set("noise_suppression_model", this.params.noiseSuppressionModel);
975
+ if (this.params.voiceFocus) {
976
+ searchParams.set("voice_focus", this.params.voiceFocus);
977
977
  }
978
- if (this.params.noiseSuppressionThreshold !== undefined) {
979
- searchParams.set("noise_suppression_threshold", this.params.noiseSuppressionThreshold.toString());
978
+ if (this.params.voiceFocusThreshold !== undefined) {
979
+ searchParams.set("voice_focus_threshold", this.params.voiceFocusThreshold.toString());
980
+ }
981
+ if (this.params.continuousPartials !== undefined) {
982
+ searchParams.set("continuous_partials", this.params.continuousPartials.toString());
983
+ }
984
+ if (this.params.interruptionDelay !== undefined) {
985
+ searchParams.set("interruption_delay", this.params.interruptionDelay.toString());
986
+ }
987
+ if (this.params.customerSupportAudioCapture) {
988
+ console.warn("`customerSupportAudioCapture=true` will record session audio. Only enable this when explicitly coordinating with AssemblyAI support.");
989
+ // The server's canonical wire name is `_customer_support_audio_capture`
990
+ // (leading underscore = "not officially supported / unstable"). The
991
+ // server also accepts `customer_support_audio_capture` via
992
+ // `populate_by_name=True`, but we send the underscore form to honor
993
+ // the server's stability marker.
994
+ searchParams.set("_customer_support_audio_capture", this.params.customerSupportAudioCapture.toString());
995
+ }
996
+ if (this.params.webhookUrl) {
997
+ searchParams.set("webhook_url", this.params.webhookUrl);
998
+ }
999
+ if (this.params.webhookAuthHeaderName) {
1000
+ searchParams.set("webhook_auth_header_name", this.params.webhookAuthHeaderName);
1001
+ }
1002
+ if (this.params.webhookAuthHeaderValue) {
1003
+ searchParams.set("webhook_auth_header_value", this.params.webhookAuthHeaderValue);
1004
+ }
1005
+ if (this.params.includePartialTurns !== undefined) {
1006
+ searchParams.set("include_partial_turns", this.params.includePartialTurns.toString());
1007
+ }
1008
+ if (this.params.redactPii !== undefined) {
1009
+ searchParams.set("redact_pii", this.params.redactPii.toString());
1010
+ }
1011
+ if (this.params.redactPiiPolicies !== undefined) {
1012
+ searchParams.set("redact_pii_policies", JSON.stringify(this.params.redactPiiPolicies));
1013
+ }
1014
+ if (this.params.redactPiiSub !== undefined) {
1015
+ searchParams.set("redact_pii_sub", this.params.redactPiiSub);
980
1016
  }
981
1017
  if (this.params.llmGateway !== undefined) {
982
1018
  searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).assemblyai={})}(this,(function(e){"use strict";function t(e,t){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(s[i[n]]=e[i[n]])}return s}function s(e,t,s,i){return new(s||(s=Promise))((function(n,r){function o(e){try{c(i.next(e))}catch(e){r(e)}}function a(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const i={cache:"no-store"};let n="";"undefined"!=typeof navigator&&navigator.userAgent&&(n+=navigator.userAgent);const r={sdk:{name:"JavaScript",version:"4.32.1"}};"undefined"!=typeof process&&(process.versions.node&&-1===n.indexOf("Node")&&(r.runtime_env={name:"Node",version:process.versions.node}),process.versions.bun&&-1===n.indexOf("Bun")&&(r.runtime_env={name:"Bun",version:process.versions.bun})),"undefined"!=typeof Deno&&process.versions.bun&&-1===n.indexOf("Deno")&&(r.runtime_env={name:"Deno",version:Deno.version.deno});class o{constructor(e){var t;this.params=e,!1===e.userAgent?this.userAgent=void 0:this.userAgent=(t=e.userAgent||{},n+(!1===t?"":" AssemblyAI/1.0 ("+Object.entries(Object.assign(Object.assign({},r),t)).map((([e,t])=>t?`${e}=${t.name}/${t.version}`:"")).join(" ")+")"))}fetch(e,t){return s(this,void 0,void 0,(function*(){t=Object.assign(Object.assign({},i),t);let s={Authorization:this.params.apiKey,"Content-Type":"application/json"};(null==i?void 0:i.headers)&&(s=Object.assign(Object.assign({},s),i.headers)),(null==t?void 0:t.headers)&&(s=Object.assign(Object.assign({},s),t.headers)),this.userAgent&&(s["User-Agent"]=this.userAgent,"undefined"!=typeof window&&"chrome"in window&&(s["AssemblyAI-Agent"]=this.userAgent)),t.headers=s,e.startsWith("http")||(e=this.params.baseUrl+e);const n=yield fetch(e,t);if(n.status>=400){let e;const t=yield n.text();if(t){try{e=JSON.parse(t)}catch(e){}if(null==e?void 0:e.error)throw new Error(e.error);throw new Error(t)}throw new Error(`HTTP Error: ${n.status} ${n.statusText}`)}return n}))}fetchJson(e,t){return s(this,void 0,void 0,(function*(){return(yield this.fetch(e,t)).json()}))}}class a extends o{summary(e,t){return this.fetchJson("/lemur/v3/generate/summary",{method:"POST",body:JSON.stringify(e),signal:t})}questionAnswer(e,t){return this.fetchJson("/lemur/v3/generate/question-answer",{method:"POST",body:JSON.stringify(e),signal:t})}actionItems(e,t){return this.fetchJson("/lemur/v3/generate/action-items",{method:"POST",body:JSON.stringify(e),signal:t})}task(e,t){return this.fetchJson("/lemur/v3/generate/task",{method:"POST",body:JSON.stringify(e),signal:t})}getResponse(e,t){return this.fetchJson(`/lemur/v3/${e}`,{signal:t})}purgeRequestData(e,t){return this.fetchJson(`/lemur/v3/${e}`,{method:"DELETE",signal:t})}}const{WritableStream:c}="undefined"!=typeof window?window:"undefined"!=typeof global?global:globalThis;var l,d;const h=null!==(d=null!==(l=null!==WebSocket&&void 0!==WebSocket?WebSocket:null===global||void 0===global?void 0:global.WebSocket)&&void 0!==l?l:null===window||void 0===window?void 0:window.WebSocket)&&void 0!==d?d:null===self||void 0===self?void 0:self.WebSocket,u=(e,t)=>t?new h(e,t):new h(e),p={[4e3]:"Sample rate must be a positive integer",[4001]:"Not Authorized",[4002]:"Insufficient funds",[4003]:"This feature is paid-only and requires you to add a credit card. Please visit https://app.assemblyai.com/ to add a credit card to your account.",[4004]:"Session ID does not exist",[4008]:"Session has expired",[4010]:"Session is closed",[4029]:"Rate limited",[4030]:"Unique session violation",[4031]:"Session Timeout",[4032]:"Audio too short",[4033]:"Audio too long",[4034]:"Audio too small to transcode",[4100]:"Bad JSON",[4101]:"Bad schema",[4102]:"Too many streams",[4103]:"This session has been reconnected. This WebSocket is no longer valid.",[1013]:"Reconnect attempts exhausted",[4104]:"Could not parse word boost parameter"};class m extends Error{}const f={[3005]:"Server error",[3006]:"Input validation error",[3007]:"Audio chunk duration violation",[3008]:"Session expired: maximum session duration exceeded",[3009]:"Too many concurrent sessions",[4e3]:"Sample rate must be a positive integer",[4001]:"Not Authorized",[4002]:"Insufficient funds",[4003]:"This feature is paid-only and requires you to add a credit card. Please visit https://app.assemblyai.com/ to add a credit card to your account.",[4004]:"Session ID does not exist",[4008]:"Session has expired",[4010]:"Session is closed",[4029]:"Rate limited",[4030]:"Unique session violation",[4031]:"Session Timeout",[4032]:"Audio too short",[4033]:"Audio too long",[4034]:"Audio too small to transcode",[4101]:"Bad schema",[4102]:"Too many streams",[4103]:"This session has been reconnected. This WebSocket is no longer valid."};class v extends Error{}const y='{"terminate_session":true}';class g{constructor(e){var t,s;if(this.listeners={},this.realtimeUrl=null!==(t=e.realtimeUrl)&&void 0!==t?t:"wss://api.assemblyai.com/v2/realtime/ws",this.sampleRate=null!==(s=e.sampleRate)&&void 0!==s?s:16e3,this.wordBoost=e.wordBoost,this.encoding=e.encoding,this.endUtteranceSilenceThreshold=e.endUtteranceSilenceThreshold,this.disablePartialTranscripts=e.disablePartialTranscripts,"token"in e&&e.token&&(this.token=e.token),"apiKey"in e&&e.apiKey&&(this.apiKey=e.apiKey),!this.token&&!this.apiKey)throw new Error("API key or temporary token is required.")}connectionUrl(){const e=new URL(this.realtimeUrl);if("wss:"!==e.protocol)throw new Error("Invalid protocol, must be wss");const t=new URLSearchParams;return this.token&&t.set("token",this.token),t.set("sample_rate",this.sampleRate.toString()),this.wordBoost&&this.wordBoost.length>0&&t.set("word_boost",JSON.stringify(this.wordBoost)),this.encoding&&t.set("encoding",this.encoding),t.set("enable_extra_session_information","true"),this.disablePartialTranscripts&&t.set("disable_partial_transcripts",this.disablePartialTranscripts.toString()),e.search=t.toString(),e}on(e,t){this.listeners[e]=t}connect(){return new Promise((e=>{if(this.socket)throw new Error("Already connected");const t=this.connectionUrl();this.token?this.socket=u(t.toString()):(console.warn("API key authentication is not supported for the RealtimeTranscriber in browser environment. Use temporary token authentication instead.\nLearn more at https://github.com/AssemblyAI/assemblyai-node-sdk/blob/main/docs/compat.md#browser-compatibility."),this.socket=u(t.toString(),{headers:{Authorization:this.apiKey}})),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{void 0!==this.endUtteranceSilenceThreshold&&null!==this.endUtteranceSilenceThreshold&&this.configureEndUtteranceSilenceThreshold(this.endUtteranceSilenceThreshold)},this.socket.onclose=({code:e,reason:t})=>{var s,i;t||e in p&&(t=p[e]),null===(i=(s=this.listeners).close)||void 0===i||i.call(s,e,t)},this.socket.onerror=e=>{var t,s,i,n;e.error?null===(s=(t=this.listeners).error)||void 0===s||s.call(t,e.error):null===(n=(i=this.listeners).error)||void 0===n||n.call(i,new Error(e.message))},this.socket.onmessage=({data:t})=>{var s,i,n,r,o,a,c,l,d,h,u,p,f,v,y;const g=JSON.parse(t.toString());if("error"in g)null===(i=(s=this.listeners).error)||void 0===i||i.call(s,new m(g.error));else switch(g.message_type){case"SessionBegins":{const t={sessionId:g.session_id,expiresAt:new Date(g.expires_at)};e(t),null===(r=(n=this.listeners).open)||void 0===r||r.call(n,t);break}case"PartialTranscript":g.created=new Date(g.created),null===(a=(o=this.listeners).transcript)||void 0===a||a.call(o,g),null===(l=(c=this.listeners)["transcript.partial"])||void 0===l||l.call(c,g);break;case"FinalTranscript":g.created=new Date(g.created),null===(h=(d=this.listeners).transcript)||void 0===h||h.call(d,g),null===(p=(u=this.listeners)["transcript.final"])||void 0===p||p.call(u,g);break;case"SessionInformation":null===(v=(f=this.listeners).session_information)||void 0===v||v.call(f,g);break;case"SessionTerminated":null===(y=this.sessionTerminatedResolve)||void 0===y||y.call(this)}}}))}sendAudio(e){this.send(e)}stream(){return new c({write:e=>{this.sendAudio(e)}})}forceEndUtterance(){this.send('{"force_end_utterance":true}')}configureEndUtteranceSilenceThreshold(e){this.send(`{"end_utterance_silence_threshold":${e}}`)}send(e){if(!this.socket||this.socket.readyState!==this.socket.OPEN)throw new Error("Socket is not open for communication");this.socket.send(e)}close(){return s(this,arguments,void 0,(function*(e=!0){var t;if(this.socket){if(this.socket.readyState===this.socket.OPEN)if(e){const e=new Promise((e=>{this.sessionTerminatedResolve=e}));this.socket.send(y),yield e}else this.socket.send(y);(null===(t=this.socket)||void 0===t?void 0:t.removeAllListeners)&&this.socket.removeAllListeners(),this.socket.close()}this.listeners={},this.socket=void 0}))}}class b extends o{constructor(e){super(e),this.rtFactoryParams=e}createService(e){return this.transcriber(e)}transcriber(e){const t=Object.assign({},e);return t.token||t.apiKey||(t.apiKey=this.rtFactoryParams.apiKey),new g(t)}createTemporaryToken(e){return s(this,void 0,void 0,(function*(){return(yield this.fetchJson("/v2/realtime/token",{method:"POST",body:JSON.stringify(e)})).token}))}}function w(e){return e.startsWith("http")||e.startsWith("https")||e.startsWith("data:")?null:e.startsWith("file://")?e.substring(7):e.startsWith("file:")?e.substring(5):e}class S extends o{constructor(e,t){super(e),this.files=t}transcribe(e,t){return s(this,void 0,void 0,(function*(){const s=yield this.submit(e);return yield this.waitUntilReady(s.id,t)}))}submit(e){return s(this,void 0,void 0,(function*(){let s,i;if("audio"in e){const{audio:n}=e,r=t(e,["audio"]);if("string"==typeof n){const e=w(n);s=null!==e?yield this.files.upload(e):n.startsWith("data:")?yield this.files.upload(n):n}else s=yield this.files.upload(n);i=Object.assign(Object.assign({},r),{audio_url:s})}else i=e;return yield this.fetchJson("/v2/transcript",{method:"POST",body:JSON.stringify(i)})}))}create(e,t){return s(this,void 0,void 0,(function*(){var s;const i=w(e.audio_url);if(null!==i){const t=yield this.files.upload(i);e.audio_url=t}const n=yield this.fetchJson("/v2/transcript",{method:"POST",body:JSON.stringify(e)});return null===(s=null==t?void 0:t.poll)||void 0===s||s?yield this.waitUntilReady(n.id,t):n}))}waitUntilReady(e,t){return s(this,void 0,void 0,(function*(){var s,i;const n=null!==(s=null==t?void 0:t.pollingInterval)&&void 0!==s?s:3e3,r=null!==(i=null==t?void 0:t.pollingTimeout)&&void 0!==i?i:-1,o=Date.now();for(;;){const t=yield this.get(e);if("completed"===t.status||"error"===t.status)return t;if(r>0&&Date.now()-o>r)throw new Error("Polling timeout");yield new Promise((e=>setTimeout(e,n)))}}))}get(e){return this.fetchJson(`/v2/transcript/${e}`)}list(e){return s(this,void 0,void 0,(function*(){let t="/v2/transcript";"string"==typeof e?t=e:e&&(t=`${t}?${new URLSearchParams(Object.keys(e).map((t=>{var s;return[t,(null===(s=e[t])||void 0===s?void 0:s.toString())||""]})))}`);const s=yield this.fetchJson(t);for(const e of s.transcripts)e.created=new Date(e.created),e.completed&&(e.completed=new Date(e.completed));return s}))}delete(e){return this.fetchJson(`/v2/transcript/${e}`,{method:"DELETE"})}wordSearch(e,t){const s=new URLSearchParams({words:t.join(",")});return this.fetchJson(`/v2/transcript/${e}/word-search?${s.toString()}`)}sentences(e){return this.fetchJson(`/v2/transcript/${e}/sentences`)}paragraphs(e){return this.fetchJson(`/v2/transcript/${e}/paragraphs`)}subtitles(e){return s(this,arguments,void 0,(function*(e,t="srt",s){let i=`/v2/transcript/${e}/${t}`;if(s){const e=new URLSearchParams;e.set("chars_per_caption",s.toString()),i+=`?${e.toString()}`}const n=yield this.fetch(i);return yield n.text()}))}redactions(e){return this.redactedAudio(e)}redactedAudio(e){return this.fetchJson(`/v2/transcript/${e}/redacted-audio`)}redactedAudioFile(e){return s(this,void 0,void 0,(function*(){const{redacted_audio_url:t,status:s}=yield this.redactedAudio(e);if("redacted_audio_ready"!==s)throw new Error(`Redacted audio status is ${s}`);const i=yield fetch(t);if(!i.ok)throw new Error(`Failed to fetch redacted audio: ${i.statusText}`);return{arrayBuffer:i.arrayBuffer.bind(i),blob:i.blob.bind(i),body:i.body,bodyUsed:i.bodyUsed}}))}}class k extends o{upload(e){return s(this,void 0,void 0,(function*(){let t;t="string"==typeof e?e.startsWith("data:")?function(e){const t=e.split(","),s=t[0].match(/:(.*?);/)[1],i=atob(t[1]);let n=i.length;const r=new Uint8Array(n);for(;n--;)r[n]=i.charCodeAt(n);return new Blob([r],{type:s})}(e):yield function(e){return s(this,void 0,void 0,(function*(){throw new Error("Interacting with the file system is not supported in this environment.")}))}():e;return(yield this.fetchJson("/v2/upload",{method:"POST",body:t,headers:{"Content-Type":"application/octet-stream"},duplex:"half"})).upload_url}))}}const _='{"type":"Terminate"}';class T{constructor(e){if(this.listeners={},this.params=Object.assign(Object.assign({},e),{websocketBaseUrl:e.websocketBaseUrl||"wss://streaming.assemblyai.com/v3/ws"}),"token"in e&&e.token&&(this.token=e.token),"apiKey"in e&&e.apiKey&&(this.apiKey=e.apiKey),!this.token&&!this.apiKey)throw new Error("API key or temporary token is required.")}connectionUrl(){var e,t;const s=new URL(null!==(e=this.params.websocketBaseUrl)&&void 0!==e?e:"");if("wss:"!==s.protocol)throw new Error("Invalid protocol, must be wss");const i=new URLSearchParams;this.token&&i.set("token",this.token),i.set("sample_rate",this.params.sampleRate.toString()),this.params.endOfTurnConfidenceThreshold&&i.set("end_of_turn_confidence_threshold",this.params.endOfTurnConfidenceThreshold.toString()),void 0!==this.params.minEndOfTurnSilenceWhenConfident&&(void 0!==this.params.minTurnSilence?console.warn("[Deprecation Warning] Both `minEndOfTurnSilenceWhenConfident` and `minTurnSilence` are set. Using `minTurnSilence`; `minEndOfTurnSilenceWhenConfident` is deprecated."):console.warn("[Deprecation Warning] `minEndOfTurnSilenceWhenConfident` is deprecated and will be removed in a future release. Please use `minTurnSilence` instead."));const n=null!==(t=this.params.minTurnSilence)&&void 0!==t?t:this.params.minEndOfTurnSilenceWhenConfident;return void 0!==n&&i.set("min_turn_silence",n.toString()),this.params.maxTurnSilence&&i.set("max_turn_silence",this.params.maxTurnSilence.toString()),void 0!==this.params.vadThreshold&&i.set("vad_threshold",this.params.vadThreshold.toString()),this.params.formatTurns&&i.set("format_turns",this.params.formatTurns.toString()),this.params.encoding&&i.set("encoding",this.params.encoding.toString()),this.params.keytermsPrompt?i.set("keyterms_prompt",JSON.stringify(this.params.keytermsPrompt)):this.params.keyterms&&(console.warn("[Deprecation Warning] `keyterms` is deprecated and will be removed in a future release. Please use `keytermsPrompt` instead."),i.set("keyterms_prompt",JSON.stringify(this.params.keyterms))),this.params.prompt&&i.set("prompt",this.params.prompt),this.params.filterProfanity&&i.set("filter_profanity",this.params.filterProfanity.toString()),"u3-pro"===this.params.speechModel&&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."),i.set("speech_model",this.params.speechModel.toString()),void 0!==this.params.languageDetection&&i.set("language_detection",this.params.languageDetection.toString()),this.params.domain&&i.set("domain",this.params.domain),void 0!==this.params.inactivityTimeout&&i.set("inactivity_timeout",this.params.inactivityTimeout.toString()),void 0!==this.params.speakerLabels&&i.set("speaker_labels",this.params.speakerLabels.toString()),void 0!==this.params.maxSpeakers&&i.set("max_speakers",this.params.maxSpeakers.toString()),this.params.noiseSuppressionModel&&i.set("noise_suppression_model",this.params.noiseSuppressionModel),void 0!==this.params.noiseSuppressionThreshold&&i.set("noise_suppression_threshold",this.params.noiseSuppressionThreshold.toString()),void 0!==this.params.llmGateway&&i.set("llm_gateway",JSON.stringify(this.params.llmGateway)),s.search=i.toString(),s}on(e,t){this.listeners[e]=t}connect(){return new Promise((e=>{if(this.socket)throw new Error("Already connected");const t=this.connectionUrl();this.token?this.socket=u(t.toString()):(console.warn("API key authentication is not supported for the StreamingTranscriber in browser environment. Use temporary token authentication instead.\nLearn more at https://github.com/AssemblyAI/assemblyai-node-sdk/blob/main/docs/compat.md#browser-compatibility."),this.socket=u(t.toString(),{headers:{Authorization:this.apiKey}})),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{},this.socket.onclose=({code:e,reason:t})=>{var s,i;t||e in f&&(t=f[e]),null===(i=(s=this.listeners).close)||void 0===i||i.call(s,e,t)},this.socket.onerror=e=>{var t,s,i,n;e.error?null===(s=(t=this.listeners).error)||void 0===s||s.call(t,e.error):null===(n=(i=this.listeners).error)||void 0===n||n.call(i,new Error(e.message))},this.socket.onmessage=({data:t})=>{var s,i,n,r,o,a,c,l,d,h,u,p,m;const f=JSON.parse(t.toString());if("error"in f){const e=new v(f.error);return"error_code"in f&&(e.code=f.error_code),void(null===(i=(s=this.listeners).error)||void 0===i||i.call(s,e))}switch(f.type){case"Begin":e(f),null===(r=(n=this.listeners).open)||void 0===r||r.call(n,f);break;case"Turn":null===(a=(o=this.listeners).turn)||void 0===a||a.call(o,f);break;case"SpeechStarted":null===(l=(c=this.listeners).speechStarted)||void 0===l||l.call(c,f);break;case"LLMGatewayResponse":null===(h=(d=this.listeners).llmGatewayResponse)||void 0===h||h.call(d,f);break;case"Warning":{const e=f;console.warn(`Streaming warning (code=${e.warning_code}): ${e.warning}`),null===(p=(u=this.listeners).warning)||void 0===p||p.call(u,e);break}case"Termination":null===(m=this.sessionTerminatedResolve)||void 0===m||m.call(this)}}}))}stream(){return new c({write:e=>{this.sendAudio(e)}})}sendAudio(e){this.send(e)}updateConfiguration(e){const{min_end_of_turn_silence_when_confident:s,min_turn_silence:i}=e,n=t(e,["min_end_of_turn_silence_when_confident","min_turn_silence"]);void 0!==s&&(void 0!==i?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."):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."));const r=null!=i?i:s,o=Object.assign(Object.assign({type:"UpdateConfiguration"},n),void 0!==r?{min_turn_silence:r}:{});this.send(JSON.stringify(o))}forceEndpoint(){this.send(JSON.stringify({type:"ForceEndpoint"}))}send(e){if(!this.socket||this.socket.readyState!==this.socket.OPEN)throw new Error("Socket is not open for communication");this.socket.send(e)}close(){return s(this,arguments,void 0,(function*(e=!0){var t;if(this.socket){if(this.socket.readyState===this.socket.OPEN)if(e){const e=new Promise((e=>{this.sessionTerminatedResolve=e}));this.socket.send(_),yield e}else this.socket.send(_);(null===(t=this.socket)||void 0===t?void 0:t.removeAllListeners)&&this.socket.removeAllListeners(),this.socket.close()}this.listeners={},this.socket=void 0}))}}class O extends o{constructor(e){super(e),this.baseServiceParams=e}transcriber(e){const t=Object.assign({},e);return t.token||t.apiKey||(t.apiKey=this.baseServiceParams.apiKey),new T(t)}createTemporaryToken(e){return s(this,void 0,void 0,(function*(){const t=new URLSearchParams;Object.entries(e).forEach((([e,s])=>{null!=s&&t.append(e,String(s))}));const s=t.toString(),i=s?`/v3/token?${s}`:"/v3/token";return(yield this.fetchJson(i,{method:"GET"})).token}))}}e.AssemblyAI=class{constructor(e){e.baseUrl=e.baseUrl||"https://api.assemblyai.com",e.baseUrl&&e.baseUrl.endsWith("/")&&(e.baseUrl=e.baseUrl.slice(0,-1)),this.files=new k(e),this.transcripts=new S(e,this.files),this.lemur=new a(e),this.realtime=new b(e),this.streaming=new O(Object.assign(Object.assign({},e),{baseUrl:e.streamingBaseUrl||"https://streaming.assemblyai.com"}))}},e.FileService=k,e.LemurService=a,e.RealtimeService=class extends g{},e.RealtimeServiceFactory=class extends b{},e.RealtimeTranscriber=g,e.RealtimeTranscriberFactory=b,e.StreamingTranscriber=T,e.TranscriptService=S}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).assemblyai={})}(this,(function(e){"use strict";function t(e,t){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(s[i[n]]=e[i[n]])}return s}function s(e,t,s,i){return new(s||(s=Promise))((function(n,r){function o(e){try{c(i.next(e))}catch(e){r(e)}}function a(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const i={cache:"no-store"};let n="";"undefined"!=typeof navigator&&navigator.userAgent&&(n+=navigator.userAgent);const r={sdk:{name:"JavaScript",version:"4.33.1"}};"undefined"!=typeof process&&(process.versions.node&&-1===n.indexOf("Node")&&(r.runtime_env={name:"Node",version:process.versions.node}),process.versions.bun&&-1===n.indexOf("Bun")&&(r.runtime_env={name:"Bun",version:process.versions.bun})),"undefined"!=typeof Deno&&process.versions.bun&&-1===n.indexOf("Deno")&&(r.runtime_env={name:"Deno",version:Deno.version.deno});class o{constructor(e){var t;this.params=e,!1===e.userAgent?this.userAgent=void 0:this.userAgent=(t=e.userAgent||{},n+(!1===t?"":" AssemblyAI/1.0 ("+Object.entries(Object.assign(Object.assign({},r),t)).map((([e,t])=>t?`${e}=${t.name}/${t.version}`:"")).join(" ")+")"))}fetch(e,t){return s(this,void 0,void 0,(function*(){t=Object.assign(Object.assign({},i),t);let s={Authorization:this.params.apiKey,"Content-Type":"application/json"};(null==i?void 0:i.headers)&&(s=Object.assign(Object.assign({},s),i.headers)),(null==t?void 0:t.headers)&&(s=Object.assign(Object.assign({},s),t.headers)),this.userAgent&&(s["User-Agent"]=this.userAgent,"undefined"!=typeof window&&"chrome"in window&&(s["AssemblyAI-Agent"]=this.userAgent)),t.headers=s,e.startsWith("http")||(e=this.params.baseUrl+e);const n=yield fetch(e,t);if(n.status>=400){let e;const t=yield n.text();if(t){try{e=JSON.parse(t)}catch(e){}if(null==e?void 0:e.error)throw new Error(e.error);throw new Error(t)}throw new Error(`HTTP Error: ${n.status} ${n.statusText}`)}return n}))}fetchJson(e,t){return s(this,void 0,void 0,(function*(){return(yield this.fetch(e,t)).json()}))}}class a extends o{summary(e,t){return this.fetchJson("/lemur/v3/generate/summary",{method:"POST",body:JSON.stringify(e),signal:t})}questionAnswer(e,t){return this.fetchJson("/lemur/v3/generate/question-answer",{method:"POST",body:JSON.stringify(e),signal:t})}actionItems(e,t){return this.fetchJson("/lemur/v3/generate/action-items",{method:"POST",body:JSON.stringify(e),signal:t})}task(e,t){return this.fetchJson("/lemur/v3/generate/task",{method:"POST",body:JSON.stringify(e),signal:t})}getResponse(e,t){return this.fetchJson(`/lemur/v3/${e}`,{signal:t})}purgeRequestData(e,t){return this.fetchJson(`/lemur/v3/${e}`,{method:"DELETE",signal:t})}}const{WritableStream:c}="undefined"!=typeof window?window:"undefined"!=typeof global?global:globalThis;var l,d;const h=null!==(d=null!==(l=null!==WebSocket&&void 0!==WebSocket?WebSocket:null===global||void 0===global?void 0:global.WebSocket)&&void 0!==l?l:null===window||void 0===window?void 0:window.WebSocket)&&void 0!==d?d:null===self||void 0===self?void 0:self.WebSocket,u=(e,t)=>t?new h(e,t):new h(e),p={[4e3]:"Sample rate must be a positive integer",[4001]:"Not Authorized",[4002]:"Insufficient funds",[4003]:"This feature is paid-only and requires you to add a credit card. Please visit https://app.assemblyai.com/ to add a credit card to your account.",[4004]:"Session ID does not exist",[4008]:"Session has expired",[4010]:"Session is closed",[4029]:"Rate limited",[4030]:"Unique session violation",[4031]:"Session Timeout",[4032]:"Audio too short",[4033]:"Audio too long",[4034]:"Audio too small to transcode",[4100]:"Bad JSON",[4101]:"Bad schema",[4102]:"Too many streams",[4103]:"This session has been reconnected. This WebSocket is no longer valid.",[1013]:"Reconnect attempts exhausted",[4104]:"Could not parse word boost parameter"};class m extends Error{}const f={[3005]:"Server error",[3006]:"Input validation error",[3007]:"Audio chunk duration violation",[3008]:"Session expired: maximum session duration exceeded",[3009]:"Too many concurrent sessions",[4e3]:"Sample rate must be a positive integer",[4001]:"Not Authorized",[4002]:"Insufficient funds",[4003]:"This feature is paid-only and requires you to add a credit card. Please visit https://app.assemblyai.com/ to add a credit card to your account.",[4004]:"Session ID does not exist",[4008]:"Session has expired",[4010]:"Session is closed",[4029]:"Rate limited",[4030]:"Unique session violation",[4031]:"Session Timeout",[4032]:"Audio too short",[4033]:"Audio too long",[4034]:"Audio too small to transcode",[4101]:"Bad schema",[4102]:"Too many streams",[4103]:"This session has been reconnected. This WebSocket is no longer valid."};class v extends Error{}const y='{"terminate_session":true}';class g{constructor(e){var t,s;if(this.listeners={},this.realtimeUrl=null!==(t=e.realtimeUrl)&&void 0!==t?t:"wss://api.assemblyai.com/v2/realtime/ws",this.sampleRate=null!==(s=e.sampleRate)&&void 0!==s?s:16e3,this.wordBoost=e.wordBoost,this.encoding=e.encoding,this.endUtteranceSilenceThreshold=e.endUtteranceSilenceThreshold,this.disablePartialTranscripts=e.disablePartialTranscripts,"token"in e&&e.token&&(this.token=e.token),"apiKey"in e&&e.apiKey&&(this.apiKey=e.apiKey),!this.token&&!this.apiKey)throw new Error("API key or temporary token is required.")}connectionUrl(){const e=new URL(this.realtimeUrl);if("wss:"!==e.protocol)throw new Error("Invalid protocol, must be wss");const t=new URLSearchParams;return this.token&&t.set("token",this.token),t.set("sample_rate",this.sampleRate.toString()),this.wordBoost&&this.wordBoost.length>0&&t.set("word_boost",JSON.stringify(this.wordBoost)),this.encoding&&t.set("encoding",this.encoding),t.set("enable_extra_session_information","true"),this.disablePartialTranscripts&&t.set("disable_partial_transcripts",this.disablePartialTranscripts.toString()),e.search=t.toString(),e}on(e,t){this.listeners[e]=t}connect(){return new Promise((e=>{if(this.socket)throw new Error("Already connected");const t=this.connectionUrl();this.token?this.socket=u(t.toString()):(console.warn("API key authentication is not supported for the RealtimeTranscriber in browser environment. Use temporary token authentication instead.\nLearn more at https://github.com/AssemblyAI/assemblyai-node-sdk/blob/main/docs/compat.md#browser-compatibility."),this.socket=u(t.toString(),{headers:{Authorization:this.apiKey}})),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{void 0!==this.endUtteranceSilenceThreshold&&null!==this.endUtteranceSilenceThreshold&&this.configureEndUtteranceSilenceThreshold(this.endUtteranceSilenceThreshold)},this.socket.onclose=({code:e,reason:t})=>{var s,i;t||e in p&&(t=p[e]),null===(i=(s=this.listeners).close)||void 0===i||i.call(s,e,t)},this.socket.onerror=e=>{var t,s,i,n;e.error?null===(s=(t=this.listeners).error)||void 0===s||s.call(t,e.error):null===(n=(i=this.listeners).error)||void 0===n||n.call(i,new Error(e.message))},this.socket.onmessage=({data:t})=>{var s,i,n,r,o,a,c,l,d,h,u,p,f,v,y;const g=JSON.parse(t.toString());if("error"in g)null===(i=(s=this.listeners).error)||void 0===i||i.call(s,new m(g.error));else switch(g.message_type){case"SessionBegins":{const t={sessionId:g.session_id,expiresAt:new Date(g.expires_at)};e(t),null===(r=(n=this.listeners).open)||void 0===r||r.call(n,t);break}case"PartialTranscript":g.created=new Date(g.created),null===(a=(o=this.listeners).transcript)||void 0===a||a.call(o,g),null===(l=(c=this.listeners)["transcript.partial"])||void 0===l||l.call(c,g);break;case"FinalTranscript":g.created=new Date(g.created),null===(h=(d=this.listeners).transcript)||void 0===h||h.call(d,g),null===(p=(u=this.listeners)["transcript.final"])||void 0===p||p.call(u,g);break;case"SessionInformation":null===(v=(f=this.listeners).session_information)||void 0===v||v.call(f,g);break;case"SessionTerminated":null===(y=this.sessionTerminatedResolve)||void 0===y||y.call(this)}}}))}sendAudio(e){this.send(e)}stream(){return new c({write:e=>{this.sendAudio(e)}})}forceEndUtterance(){this.send('{"force_end_utterance":true}')}configureEndUtteranceSilenceThreshold(e){this.send(`{"end_utterance_silence_threshold":${e}}`)}send(e){if(!this.socket||this.socket.readyState!==this.socket.OPEN)throw new Error("Socket is not open for communication");this.socket.send(e)}close(){return s(this,arguments,void 0,(function*(e=!0){var t;if(this.socket){if(this.socket.readyState===this.socket.OPEN)if(e){const e=new Promise((e=>{this.sessionTerminatedResolve=e}));this.socket.send(y),yield e}else this.socket.send(y);(null===(t=this.socket)||void 0===t?void 0:t.removeAllListeners)&&this.socket.removeAllListeners(),this.socket.close()}this.listeners={},this.socket=void 0}))}}class b extends o{constructor(e){super(e),this.rtFactoryParams=e}createService(e){return this.transcriber(e)}transcriber(e){const t=Object.assign({},e);return t.token||t.apiKey||(t.apiKey=this.rtFactoryParams.apiKey),new g(t)}createTemporaryToken(e){return s(this,void 0,void 0,(function*(){return(yield this.fetchJson("/v2/realtime/token",{method:"POST",body:JSON.stringify(e)})).token}))}}function w(e){return e.startsWith("http")||e.startsWith("https")||e.startsWith("data:")?null:e.startsWith("file://")?e.substring(7):e.startsWith("file:")?e.substring(5):e}class S extends o{constructor(e,t){super(e),this.files=t}transcribe(e,t){return s(this,void 0,void 0,(function*(){const s=yield this.submit(e);return yield this.waitUntilReady(s.id,t)}))}submit(e){return s(this,void 0,void 0,(function*(){let s,i;if("audio"in e){const{audio:n}=e,r=t(e,["audio"]);if("string"==typeof n){const e=w(n);s=null!==e?yield this.files.upload(e):n.startsWith("data:")?yield this.files.upload(n):n}else s=yield this.files.upload(n);i=Object.assign(Object.assign({},r),{audio_url:s})}else i=e;return yield this.fetchJson("/v2/transcript",{method:"POST",body:JSON.stringify(i)})}))}create(e,t){return s(this,void 0,void 0,(function*(){var s;const i=w(e.audio_url);if(null!==i){const t=yield this.files.upload(i);e.audio_url=t}const n=yield this.fetchJson("/v2/transcript",{method:"POST",body:JSON.stringify(e)});return null===(s=null==t?void 0:t.poll)||void 0===s||s?yield this.waitUntilReady(n.id,t):n}))}waitUntilReady(e,t){return s(this,void 0,void 0,(function*(){var s,i;const n=null!==(s=null==t?void 0:t.pollingInterval)&&void 0!==s?s:3e3,r=null!==(i=null==t?void 0:t.pollingTimeout)&&void 0!==i?i:-1,o=Date.now();for(;;){const t=yield this.get(e);if("completed"===t.status||"error"===t.status)return t;if(r>0&&Date.now()-o>r)throw new Error("Polling timeout");yield new Promise((e=>setTimeout(e,n)))}}))}get(e){return this.fetchJson(`/v2/transcript/${e}`)}list(e){return s(this,void 0,void 0,(function*(){let t="/v2/transcript";"string"==typeof e?t=e:e&&(t=`${t}?${new URLSearchParams(Object.keys(e).map((t=>{var s;return[t,(null===(s=e[t])||void 0===s?void 0:s.toString())||""]})))}`);const s=yield this.fetchJson(t);for(const e of s.transcripts)e.created=new Date(e.created),e.completed&&(e.completed=new Date(e.completed));return s}))}delete(e){return this.fetchJson(`/v2/transcript/${e}`,{method:"DELETE"})}wordSearch(e,t){const s=new URLSearchParams({words:t.join(",")});return this.fetchJson(`/v2/transcript/${e}/word-search?${s.toString()}`)}sentences(e){return this.fetchJson(`/v2/transcript/${e}/sentences`)}paragraphs(e){return this.fetchJson(`/v2/transcript/${e}/paragraphs`)}subtitles(e){return s(this,arguments,void 0,(function*(e,t="srt",s){let i=`/v2/transcript/${e}/${t}`;if(s){const e=new URLSearchParams;e.set("chars_per_caption",s.toString()),i+=`?${e.toString()}`}const n=yield this.fetch(i);return yield n.text()}))}redactions(e){return this.redactedAudio(e)}redactedAudio(e){return this.fetchJson(`/v2/transcript/${e}/redacted-audio`)}redactedAudioFile(e){return s(this,void 0,void 0,(function*(){const{redacted_audio_url:t,status:s}=yield this.redactedAudio(e);if("redacted_audio_ready"!==s)throw new Error(`Redacted audio status is ${s}`);const i=yield fetch(t);if(!i.ok)throw new Error(`Failed to fetch redacted audio: ${i.statusText}`);return{arrayBuffer:i.arrayBuffer.bind(i),blob:i.blob.bind(i),body:i.body,bodyUsed:i.bodyUsed}}))}}class k extends o{upload(e){return s(this,void 0,void 0,(function*(){let t;t="string"==typeof e?e.startsWith("data:")?function(e){const t=e.split(","),s=t[0].match(/:(.*?);/)[1],i=atob(t[1]);let n=i.length;const r=new Uint8Array(n);for(;n--;)r[n]=i.charCodeAt(n);return new Blob([r],{type:s})}(e):yield function(e){return s(this,void 0,void 0,(function*(){throw new Error("Interacting with the file system is not supported in this environment.")}))}():e;return(yield this.fetchJson("/v2/upload",{method:"POST",body:t,headers:{"Content-Type":"application/octet-stream"},duplex:"half"})).upload_url}))}}const _='{"type":"Terminate"}';class T{constructor(e){if(this.listeners={},this.params=Object.assign(Object.assign({},e),{websocketBaseUrl:e.websocketBaseUrl||"wss://streaming.assemblyai.com/v3/ws"}),"token"in e&&e.token&&(this.token=e.token),"apiKey"in e&&e.apiKey&&(this.apiKey=e.apiKey),!this.token&&!this.apiKey)throw new Error("API key or temporary token is required.")}connectionUrl(){var e,t;const s=new URL(null!==(e=this.params.websocketBaseUrl)&&void 0!==e?e:"");if("wss:"!==s.protocol)throw new Error("Invalid protocol, must be wss");const i=new URLSearchParams;this.token&&i.set("token",this.token),i.set("sample_rate",this.params.sampleRate.toString()),this.params.endOfTurnConfidenceThreshold&&i.set("end_of_turn_confidence_threshold",this.params.endOfTurnConfidenceThreshold.toString()),void 0!==this.params.minEndOfTurnSilenceWhenConfident&&(void 0!==this.params.minTurnSilence?console.warn("[Deprecation Warning] Both `minEndOfTurnSilenceWhenConfident` and `minTurnSilence` are set. Using `minTurnSilence`; `minEndOfTurnSilenceWhenConfident` is deprecated."):console.warn("[Deprecation Warning] `minEndOfTurnSilenceWhenConfident` is deprecated and will be removed in a future release. Please use `minTurnSilence` instead."));const n=null!==(t=this.params.minTurnSilence)&&void 0!==t?t:this.params.minEndOfTurnSilenceWhenConfident;return void 0!==n&&i.set("min_turn_silence",n.toString()),this.params.maxTurnSilence&&i.set("max_turn_silence",this.params.maxTurnSilence.toString()),void 0!==this.params.vadThreshold&&i.set("vad_threshold",this.params.vadThreshold.toString()),this.params.formatTurns&&i.set("format_turns",this.params.formatTurns.toString()),this.params.encoding&&i.set("encoding",this.params.encoding.toString()),this.params.keytermsPrompt?i.set("keyterms_prompt",JSON.stringify(this.params.keytermsPrompt)):this.params.keyterms&&(console.warn("[Deprecation Warning] `keyterms` is deprecated and will be removed in a future release. Please use `keytermsPrompt` instead."),i.set("keyterms_prompt",JSON.stringify(this.params.keyterms))),this.params.prompt&&i.set("prompt",this.params.prompt),this.params.filterProfanity&&i.set("filter_profanity",this.params.filterProfanity.toString()),"u3-pro"===this.params.speechModel&&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."),i.set("speech_model",this.params.speechModel.toString()),void 0!==this.params.languageDetection&&i.set("language_detection",this.params.languageDetection.toString()),this.params.domain&&i.set("domain",this.params.domain),void 0!==this.params.inactivityTimeout&&i.set("inactivity_timeout",this.params.inactivityTimeout.toString()),void 0!==this.params.speakerLabels&&i.set("speaker_labels",this.params.speakerLabels.toString()),void 0!==this.params.maxSpeakers&&i.set("max_speakers",this.params.maxSpeakers.toString()),this.params.voiceFocus&&i.set("voice_focus",this.params.voiceFocus),void 0!==this.params.voiceFocusThreshold&&i.set("voice_focus_threshold",this.params.voiceFocusThreshold.toString()),void 0!==this.params.continuousPartials&&i.set("continuous_partials",this.params.continuousPartials.toString()),void 0!==this.params.interruptionDelay&&i.set("interruption_delay",this.params.interruptionDelay.toString()),this.params.customerSupportAudioCapture&&(console.warn("`customerSupportAudioCapture=true` will record session audio. Only enable this when explicitly coordinating with AssemblyAI support."),i.set("_customer_support_audio_capture",this.params.customerSupportAudioCapture.toString())),this.params.webhookUrl&&i.set("webhook_url",this.params.webhookUrl),this.params.webhookAuthHeaderName&&i.set("webhook_auth_header_name",this.params.webhookAuthHeaderName),this.params.webhookAuthHeaderValue&&i.set("webhook_auth_header_value",this.params.webhookAuthHeaderValue),void 0!==this.params.includePartialTurns&&i.set("include_partial_turns",this.params.includePartialTurns.toString()),void 0!==this.params.redactPii&&i.set("redact_pii",this.params.redactPii.toString()),void 0!==this.params.redactPiiPolicies&&i.set("redact_pii_policies",JSON.stringify(this.params.redactPiiPolicies)),void 0!==this.params.redactPiiSub&&i.set("redact_pii_sub",this.params.redactPiiSub),void 0!==this.params.llmGateway&&i.set("llm_gateway",JSON.stringify(this.params.llmGateway)),s.search=i.toString(),s}on(e,t){this.listeners[e]=t}connect(){return new Promise((e=>{if(this.socket)throw new Error("Already connected");const t=this.connectionUrl();this.token?this.socket=u(t.toString()):(console.warn("API key authentication is not supported for the StreamingTranscriber in browser environment. Use temporary token authentication instead.\nLearn more at https://github.com/AssemblyAI/assemblyai-node-sdk/blob/main/docs/compat.md#browser-compatibility."),this.socket=u(t.toString(),{headers:{Authorization:this.apiKey}})),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{},this.socket.onclose=({code:e,reason:t})=>{var s,i;t||e in f&&(t=f[e]),null===(i=(s=this.listeners).close)||void 0===i||i.call(s,e,t)},this.socket.onerror=e=>{var t,s,i,n;e.error?null===(s=(t=this.listeners).error)||void 0===s||s.call(t,e.error):null===(n=(i=this.listeners).error)||void 0===n||n.call(i,new Error(e.message))},this.socket.onmessage=({data:t})=>{var s,i,n,r,o,a,c,l,d,h,u,p,m;const f=JSON.parse(t.toString());if("error"in f){const e=new v(f.error);return"error_code"in f&&(e.code=f.error_code),void(null===(i=(s=this.listeners).error)||void 0===i||i.call(s,e))}switch(f.type){case"Begin":e(f),null===(r=(n=this.listeners).open)||void 0===r||r.call(n,f);break;case"Turn":null===(a=(o=this.listeners).turn)||void 0===a||a.call(o,f);break;case"SpeechStarted":null===(l=(c=this.listeners).speechStarted)||void 0===l||l.call(c,f);break;case"LLMGatewayResponse":null===(h=(d=this.listeners).llmGatewayResponse)||void 0===h||h.call(d,f);break;case"Warning":{const e=f;console.warn(`Streaming warning (code=${e.warning_code}): ${e.warning}`),null===(p=(u=this.listeners).warning)||void 0===p||p.call(u,e);break}case"Termination":null===(m=this.sessionTerminatedResolve)||void 0===m||m.call(this)}}}))}stream(){return new c({write:e=>{this.sendAudio(e)}})}sendAudio(e){this.send(e)}updateConfiguration(e){const{min_end_of_turn_silence_when_confident:s,min_turn_silence:i}=e,n=t(e,["min_end_of_turn_silence_when_confident","min_turn_silence"]);void 0!==s&&(void 0!==i?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."):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."));const r=null!=i?i:s,o=Object.assign(Object.assign({type:"UpdateConfiguration"},n),void 0!==r?{min_turn_silence:r}:{});this.send(JSON.stringify(o))}forceEndpoint(){this.send(JSON.stringify({type:"ForceEndpoint"}))}send(e){if(!this.socket||this.socket.readyState!==this.socket.OPEN)throw new Error("Socket is not open for communication");this.socket.send(e)}close(){return s(this,arguments,void 0,(function*(e=!0){var t;if(this.socket){if(this.socket.readyState===this.socket.OPEN)if(e){const e=new Promise((e=>{this.sessionTerminatedResolve=e}));this.socket.send(_),yield e}else this.socket.send(_);(null===(t=this.socket)||void 0===t?void 0:t.removeAllListeners)&&this.socket.removeAllListeners(),this.socket.close()}this.listeners={},this.socket=void 0}))}}class O extends o{constructor(e){super(e),this.baseServiceParams=e}transcriber(e){const t=Object.assign({},e);return t.token||t.apiKey||(t.apiKey=this.baseServiceParams.apiKey),new T(t)}createTemporaryToken(e){return s(this,void 0,void 0,(function*(){const t=new URLSearchParams;Object.entries(e).forEach((([e,s])=>{null!=s&&t.append(e,String(s))}));const s=t.toString(),i=s?`/v3/token?${s}`:"/v3/token";return(yield this.fetchJson(i,{method:"GET"})).token}))}}e.AssemblyAI=class{constructor(e){e.baseUrl=e.baseUrl||"https://api.assemblyai.com",e.baseUrl&&e.baseUrl.endsWith("/")&&(e.baseUrl=e.baseUrl.slice(0,-1)),this.files=new k(e),this.transcripts=new S(e,this.files),this.lemur=new a(e),this.realtime=new b(e),this.streaming=new O(Object.assign(Object.assign({},e),{baseUrl:e.streamingBaseUrl||"https://streaming.assemblyai.com"}))}},e.FileService=k,e.LemurService=a,e.RealtimeService=class extends g{},e.RealtimeServiceFactory=class extends b{},e.RealtimeTranscriber=g,e.RealtimeTranscriberFactory=b,e.StreamingTranscriber=T,e.TranscriptService=S}));
package/dist/browser.mjs CHANGED
@@ -15,7 +15,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
15
15
  defaultUserAgentString += navigator.userAgent;
16
16
  }
17
17
  const defaultUserAgent = {
18
- sdk: { name: "JavaScript", version: "4.32.1" },
18
+ sdk: { name: "JavaScript", version: "4.33.1" },
19
19
  };
20
20
  if (typeof process !== "undefined") {
21
21
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -888,11 +888,47 @@ class StreamingTranscriber {
888
888
  if (this.params.maxSpeakers !== undefined) {
889
889
  searchParams.set("max_speakers", this.params.maxSpeakers.toString());
890
890
  }
891
- if (this.params.noiseSuppressionModel) {
892
- searchParams.set("noise_suppression_model", this.params.noiseSuppressionModel);
891
+ if (this.params.voiceFocus) {
892
+ searchParams.set("voice_focus", this.params.voiceFocus);
893
893
  }
894
- if (this.params.noiseSuppressionThreshold !== undefined) {
895
- searchParams.set("noise_suppression_threshold", this.params.noiseSuppressionThreshold.toString());
894
+ if (this.params.voiceFocusThreshold !== undefined) {
895
+ searchParams.set("voice_focus_threshold", this.params.voiceFocusThreshold.toString());
896
+ }
897
+ if (this.params.continuousPartials !== undefined) {
898
+ searchParams.set("continuous_partials", this.params.continuousPartials.toString());
899
+ }
900
+ if (this.params.interruptionDelay !== undefined) {
901
+ searchParams.set("interruption_delay", this.params.interruptionDelay.toString());
902
+ }
903
+ if (this.params.customerSupportAudioCapture) {
904
+ console.warn("`customerSupportAudioCapture=true` will record session audio. Only enable this when explicitly coordinating with AssemblyAI support.");
905
+ // The server's canonical wire name is `_customer_support_audio_capture`
906
+ // (leading underscore = "not officially supported / unstable"). The
907
+ // server also accepts `customer_support_audio_capture` via
908
+ // `populate_by_name=True`, but we send the underscore form to honor
909
+ // the server's stability marker.
910
+ searchParams.set("_customer_support_audio_capture", this.params.customerSupportAudioCapture.toString());
911
+ }
912
+ if (this.params.webhookUrl) {
913
+ searchParams.set("webhook_url", this.params.webhookUrl);
914
+ }
915
+ if (this.params.webhookAuthHeaderName) {
916
+ searchParams.set("webhook_auth_header_name", this.params.webhookAuthHeaderName);
917
+ }
918
+ if (this.params.webhookAuthHeaderValue) {
919
+ searchParams.set("webhook_auth_header_value", this.params.webhookAuthHeaderValue);
920
+ }
921
+ if (this.params.includePartialTurns !== undefined) {
922
+ searchParams.set("include_partial_turns", this.params.includePartialTurns.toString());
923
+ }
924
+ if (this.params.redactPii !== undefined) {
925
+ searchParams.set("redact_pii", this.params.redactPii.toString());
926
+ }
927
+ if (this.params.redactPiiPolicies !== undefined) {
928
+ searchParams.set("redact_pii_policies", JSON.stringify(this.params.redactPiiPolicies));
929
+ }
930
+ if (this.params.redactPiiSub !== undefined) {
931
+ searchParams.set("redact_pii_sub", this.params.redactPiiSub);
896
932
  }
897
933
  if (this.params.llmGateway !== undefined) {
898
934
  searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
package/dist/bun.mjs CHANGED
@@ -17,7 +17,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
17
17
  defaultUserAgentString += navigator.userAgent;
18
18
  }
19
19
  const defaultUserAgent = {
20
- sdk: { name: "JavaScript", version: "4.32.1" },
20
+ sdk: { name: "JavaScript", version: "4.33.1" },
21
21
  };
22
22
  if (typeof process !== "undefined") {
23
23
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -869,11 +869,47 @@ class StreamingTranscriber {
869
869
  if (this.params.maxSpeakers !== undefined) {
870
870
  searchParams.set("max_speakers", this.params.maxSpeakers.toString());
871
871
  }
872
- if (this.params.noiseSuppressionModel) {
873
- searchParams.set("noise_suppression_model", this.params.noiseSuppressionModel);
872
+ if (this.params.voiceFocus) {
873
+ searchParams.set("voice_focus", this.params.voiceFocus);
874
874
  }
875
- if (this.params.noiseSuppressionThreshold !== undefined) {
876
- searchParams.set("noise_suppression_threshold", this.params.noiseSuppressionThreshold.toString());
875
+ if (this.params.voiceFocusThreshold !== undefined) {
876
+ searchParams.set("voice_focus_threshold", this.params.voiceFocusThreshold.toString());
877
+ }
878
+ if (this.params.continuousPartials !== undefined) {
879
+ searchParams.set("continuous_partials", this.params.continuousPartials.toString());
880
+ }
881
+ if (this.params.interruptionDelay !== undefined) {
882
+ searchParams.set("interruption_delay", this.params.interruptionDelay.toString());
883
+ }
884
+ if (this.params.customerSupportAudioCapture) {
885
+ console.warn("`customerSupportAudioCapture=true` will record session audio. Only enable this when explicitly coordinating with AssemblyAI support.");
886
+ // The server's canonical wire name is `_customer_support_audio_capture`
887
+ // (leading underscore = "not officially supported / unstable"). The
888
+ // server also accepts `customer_support_audio_capture` via
889
+ // `populate_by_name=True`, but we send the underscore form to honor
890
+ // the server's stability marker.
891
+ searchParams.set("_customer_support_audio_capture", this.params.customerSupportAudioCapture.toString());
892
+ }
893
+ if (this.params.webhookUrl) {
894
+ searchParams.set("webhook_url", this.params.webhookUrl);
895
+ }
896
+ if (this.params.webhookAuthHeaderName) {
897
+ searchParams.set("webhook_auth_header_name", this.params.webhookAuthHeaderName);
898
+ }
899
+ if (this.params.webhookAuthHeaderValue) {
900
+ searchParams.set("webhook_auth_header_value", this.params.webhookAuthHeaderValue);
901
+ }
902
+ if (this.params.includePartialTurns !== undefined) {
903
+ searchParams.set("include_partial_turns", this.params.includePartialTurns.toString());
904
+ }
905
+ if (this.params.redactPii !== undefined) {
906
+ searchParams.set("redact_pii", this.params.redactPii.toString());
907
+ }
908
+ if (this.params.redactPiiPolicies !== undefined) {
909
+ searchParams.set("redact_pii_policies", JSON.stringify(this.params.redactPiiPolicies));
910
+ }
911
+ if (this.params.redactPiiSub !== undefined) {
912
+ searchParams.set("redact_pii_sub", this.params.redactPiiSub);
877
913
  }
878
914
  if (this.params.llmGateway !== undefined) {
879
915
  searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
package/dist/deno.mjs CHANGED
@@ -17,7 +17,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
17
17
  defaultUserAgentString += navigator.userAgent;
18
18
  }
19
19
  const defaultUserAgent = {
20
- sdk: { name: "JavaScript", version: "4.32.1" },
20
+ sdk: { name: "JavaScript", version: "4.33.1" },
21
21
  };
22
22
  if (typeof process !== "undefined") {
23
23
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -869,11 +869,47 @@ class StreamingTranscriber {
869
869
  if (this.params.maxSpeakers !== undefined) {
870
870
  searchParams.set("max_speakers", this.params.maxSpeakers.toString());
871
871
  }
872
- if (this.params.noiseSuppressionModel) {
873
- searchParams.set("noise_suppression_model", this.params.noiseSuppressionModel);
872
+ if (this.params.voiceFocus) {
873
+ searchParams.set("voice_focus", this.params.voiceFocus);
874
874
  }
875
- if (this.params.noiseSuppressionThreshold !== undefined) {
876
- searchParams.set("noise_suppression_threshold", this.params.noiseSuppressionThreshold.toString());
875
+ if (this.params.voiceFocusThreshold !== undefined) {
876
+ searchParams.set("voice_focus_threshold", this.params.voiceFocusThreshold.toString());
877
+ }
878
+ if (this.params.continuousPartials !== undefined) {
879
+ searchParams.set("continuous_partials", this.params.continuousPartials.toString());
880
+ }
881
+ if (this.params.interruptionDelay !== undefined) {
882
+ searchParams.set("interruption_delay", this.params.interruptionDelay.toString());
883
+ }
884
+ if (this.params.customerSupportAudioCapture) {
885
+ console.warn("`customerSupportAudioCapture=true` will record session audio. Only enable this when explicitly coordinating with AssemblyAI support.");
886
+ // The server's canonical wire name is `_customer_support_audio_capture`
887
+ // (leading underscore = "not officially supported / unstable"). The
888
+ // server also accepts `customer_support_audio_capture` via
889
+ // `populate_by_name=True`, but we send the underscore form to honor
890
+ // the server's stability marker.
891
+ searchParams.set("_customer_support_audio_capture", this.params.customerSupportAudioCapture.toString());
892
+ }
893
+ if (this.params.webhookUrl) {
894
+ searchParams.set("webhook_url", this.params.webhookUrl);
895
+ }
896
+ if (this.params.webhookAuthHeaderName) {
897
+ searchParams.set("webhook_auth_header_name", this.params.webhookAuthHeaderName);
898
+ }
899
+ if (this.params.webhookAuthHeaderValue) {
900
+ searchParams.set("webhook_auth_header_value", this.params.webhookAuthHeaderValue);
901
+ }
902
+ if (this.params.includePartialTurns !== undefined) {
903
+ searchParams.set("include_partial_turns", this.params.includePartialTurns.toString());
904
+ }
905
+ if (this.params.redactPii !== undefined) {
906
+ searchParams.set("redact_pii", this.params.redactPii.toString());
907
+ }
908
+ if (this.params.redactPiiPolicies !== undefined) {
909
+ searchParams.set("redact_pii_policies", JSON.stringify(this.params.redactPiiPolicies));
910
+ }
911
+ if (this.params.redactPiiSub !== undefined) {
912
+ searchParams.set("redact_pii_sub", this.params.redactPiiSub);
877
913
  }
878
914
  if (this.params.llmGateway !== undefined) {
879
915
  searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
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.32.1" },
66
+ sdk: { name: "JavaScript", version: "4.33.1" },
67
67
  };
68
68
  if (typeof process !== "undefined") {
69
69
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -959,11 +959,47 @@ class StreamingTranscriber {
959
959
  if (this.params.maxSpeakers !== undefined) {
960
960
  searchParams.set("max_speakers", this.params.maxSpeakers.toString());
961
961
  }
962
- if (this.params.noiseSuppressionModel) {
963
- searchParams.set("noise_suppression_model", this.params.noiseSuppressionModel);
962
+ if (this.params.voiceFocus) {
963
+ searchParams.set("voice_focus", this.params.voiceFocus);
964
964
  }
965
- if (this.params.noiseSuppressionThreshold !== undefined) {
966
- searchParams.set("noise_suppression_threshold", this.params.noiseSuppressionThreshold.toString());
965
+ if (this.params.voiceFocusThreshold !== undefined) {
966
+ searchParams.set("voice_focus_threshold", this.params.voiceFocusThreshold.toString());
967
+ }
968
+ if (this.params.continuousPartials !== undefined) {
969
+ searchParams.set("continuous_partials", this.params.continuousPartials.toString());
970
+ }
971
+ if (this.params.interruptionDelay !== undefined) {
972
+ searchParams.set("interruption_delay", this.params.interruptionDelay.toString());
973
+ }
974
+ if (this.params.customerSupportAudioCapture) {
975
+ console.warn("`customerSupportAudioCapture=true` will record session audio. Only enable this when explicitly coordinating with AssemblyAI support.");
976
+ // The server's canonical wire name is `_customer_support_audio_capture`
977
+ // (leading underscore = "not officially supported / unstable"). The
978
+ // server also accepts `customer_support_audio_capture` via
979
+ // `populate_by_name=True`, but we send the underscore form to honor
980
+ // the server's stability marker.
981
+ searchParams.set("_customer_support_audio_capture", this.params.customerSupportAudioCapture.toString());
982
+ }
983
+ if (this.params.webhookUrl) {
984
+ searchParams.set("webhook_url", this.params.webhookUrl);
985
+ }
986
+ if (this.params.webhookAuthHeaderName) {
987
+ searchParams.set("webhook_auth_header_name", this.params.webhookAuthHeaderName);
988
+ }
989
+ if (this.params.webhookAuthHeaderValue) {
990
+ searchParams.set("webhook_auth_header_value", this.params.webhookAuthHeaderValue);
991
+ }
992
+ if (this.params.includePartialTurns !== undefined) {
993
+ searchParams.set("include_partial_turns", this.params.includePartialTurns.toString());
994
+ }
995
+ if (this.params.redactPii !== undefined) {
996
+ searchParams.set("redact_pii", this.params.redactPii.toString());
997
+ }
998
+ if (this.params.redactPiiPolicies !== undefined) {
999
+ searchParams.set("redact_pii_policies", JSON.stringify(this.params.redactPiiPolicies));
1000
+ }
1001
+ if (this.params.redactPiiSub !== undefined) {
1002
+ searchParams.set("redact_pii_sub", this.params.redactPiiSub);
967
1003
  }
968
1004
  if (this.params.llmGateway !== undefined) {
969
1005
  searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
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.32.1" },
64
+ sdk: { name: "JavaScript", version: "4.33.1" },
65
65
  };
66
66
  if (typeof process !== "undefined") {
67
67
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -957,11 +957,47 @@ class StreamingTranscriber {
957
957
  if (this.params.maxSpeakers !== undefined) {
958
958
  searchParams.set("max_speakers", this.params.maxSpeakers.toString());
959
959
  }
960
- if (this.params.noiseSuppressionModel) {
961
- searchParams.set("noise_suppression_model", this.params.noiseSuppressionModel);
960
+ if (this.params.voiceFocus) {
961
+ searchParams.set("voice_focus", this.params.voiceFocus);
962
962
  }
963
- if (this.params.noiseSuppressionThreshold !== undefined) {
964
- searchParams.set("noise_suppression_threshold", this.params.noiseSuppressionThreshold.toString());
963
+ if (this.params.voiceFocusThreshold !== undefined) {
964
+ searchParams.set("voice_focus_threshold", this.params.voiceFocusThreshold.toString());
965
+ }
966
+ if (this.params.continuousPartials !== undefined) {
967
+ searchParams.set("continuous_partials", this.params.continuousPartials.toString());
968
+ }
969
+ if (this.params.interruptionDelay !== undefined) {
970
+ searchParams.set("interruption_delay", this.params.interruptionDelay.toString());
971
+ }
972
+ if (this.params.customerSupportAudioCapture) {
973
+ console.warn("`customerSupportAudioCapture=true` will record session audio. Only enable this when explicitly coordinating with AssemblyAI support.");
974
+ // The server's canonical wire name is `_customer_support_audio_capture`
975
+ // (leading underscore = "not officially supported / unstable"). The
976
+ // server also accepts `customer_support_audio_capture` via
977
+ // `populate_by_name=True`, but we send the underscore form to honor
978
+ // the server's stability marker.
979
+ searchParams.set("_customer_support_audio_capture", this.params.customerSupportAudioCapture.toString());
980
+ }
981
+ if (this.params.webhookUrl) {
982
+ searchParams.set("webhook_url", this.params.webhookUrl);
983
+ }
984
+ if (this.params.webhookAuthHeaderName) {
985
+ searchParams.set("webhook_auth_header_name", this.params.webhookAuthHeaderName);
986
+ }
987
+ if (this.params.webhookAuthHeaderValue) {
988
+ searchParams.set("webhook_auth_header_value", this.params.webhookAuthHeaderValue);
989
+ }
990
+ if (this.params.includePartialTurns !== undefined) {
991
+ searchParams.set("include_partial_turns", this.params.includePartialTurns.toString());
992
+ }
993
+ if (this.params.redactPii !== undefined) {
994
+ searchParams.set("redact_pii", this.params.redactPii.toString());
995
+ }
996
+ if (this.params.redactPiiPolicies !== undefined) {
997
+ searchParams.set("redact_pii_policies", JSON.stringify(this.params.redactPiiPolicies));
998
+ }
999
+ if (this.params.redactPiiSub !== undefined) {
1000
+ searchParams.set("redact_pii_sub", this.params.redactPiiSub);
965
1001
  }
966
1002
  if (this.params.llmGateway !== undefined) {
967
1003
  searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
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.32.1" },
25
+ sdk: { name: "JavaScript", version: "4.33.1" },
26
26
  };
27
27
  if (typeof process !== "undefined") {
28
28
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -868,11 +868,47 @@ class StreamingTranscriber {
868
868
  if (this.params.maxSpeakers !== undefined) {
869
869
  searchParams.set("max_speakers", this.params.maxSpeakers.toString());
870
870
  }
871
- if (this.params.noiseSuppressionModel) {
872
- searchParams.set("noise_suppression_model", this.params.noiseSuppressionModel);
871
+ if (this.params.voiceFocus) {
872
+ searchParams.set("voice_focus", this.params.voiceFocus);
873
873
  }
874
- if (this.params.noiseSuppressionThreshold !== undefined) {
875
- searchParams.set("noise_suppression_threshold", this.params.noiseSuppressionThreshold.toString());
874
+ if (this.params.voiceFocusThreshold !== undefined) {
875
+ searchParams.set("voice_focus_threshold", this.params.voiceFocusThreshold.toString());
876
+ }
877
+ if (this.params.continuousPartials !== undefined) {
878
+ searchParams.set("continuous_partials", this.params.continuousPartials.toString());
879
+ }
880
+ if (this.params.interruptionDelay !== undefined) {
881
+ searchParams.set("interruption_delay", this.params.interruptionDelay.toString());
882
+ }
883
+ if (this.params.customerSupportAudioCapture) {
884
+ console.warn("`customerSupportAudioCapture=true` will record session audio. Only enable this when explicitly coordinating with AssemblyAI support.");
885
+ // The server's canonical wire name is `_customer_support_audio_capture`
886
+ // (leading underscore = "not officially supported / unstable"). The
887
+ // server also accepts `customer_support_audio_capture` via
888
+ // `populate_by_name=True`, but we send the underscore form to honor
889
+ // the server's stability marker.
890
+ searchParams.set("_customer_support_audio_capture", this.params.customerSupportAudioCapture.toString());
891
+ }
892
+ if (this.params.webhookUrl) {
893
+ searchParams.set("webhook_url", this.params.webhookUrl);
894
+ }
895
+ if (this.params.webhookAuthHeaderName) {
896
+ searchParams.set("webhook_auth_header_name", this.params.webhookAuthHeaderName);
897
+ }
898
+ if (this.params.webhookAuthHeaderValue) {
899
+ searchParams.set("webhook_auth_header_value", this.params.webhookAuthHeaderValue);
900
+ }
901
+ if (this.params.includePartialTurns !== undefined) {
902
+ searchParams.set("include_partial_turns", this.params.includePartialTurns.toString());
903
+ }
904
+ if (this.params.redactPii !== undefined) {
905
+ searchParams.set("redact_pii", this.params.redactPii.toString());
906
+ }
907
+ if (this.params.redactPiiPolicies !== undefined) {
908
+ searchParams.set("redact_pii_policies", JSON.stringify(this.params.redactPiiPolicies));
909
+ }
910
+ if (this.params.redactPiiSub !== undefined) {
911
+ searchParams.set("redact_pii_sub", this.params.redactPiiSub);
876
912
  }
877
913
  if (this.params.llmGateway !== undefined) {
878
914
  searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
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.32.1" },
23
+ sdk: { name: "JavaScript", version: "4.33.1" },
24
24
  };
25
25
  if (typeof process !== "undefined") {
26
26
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -866,11 +866,47 @@ class StreamingTranscriber {
866
866
  if (this.params.maxSpeakers !== undefined) {
867
867
  searchParams.set("max_speakers", this.params.maxSpeakers.toString());
868
868
  }
869
- if (this.params.noiseSuppressionModel) {
870
- searchParams.set("noise_suppression_model", this.params.noiseSuppressionModel);
869
+ if (this.params.voiceFocus) {
870
+ searchParams.set("voice_focus", this.params.voiceFocus);
871
871
  }
872
- if (this.params.noiseSuppressionThreshold !== undefined) {
873
- searchParams.set("noise_suppression_threshold", this.params.noiseSuppressionThreshold.toString());
872
+ if (this.params.voiceFocusThreshold !== undefined) {
873
+ searchParams.set("voice_focus_threshold", this.params.voiceFocusThreshold.toString());
874
+ }
875
+ if (this.params.continuousPartials !== undefined) {
876
+ searchParams.set("continuous_partials", this.params.continuousPartials.toString());
877
+ }
878
+ if (this.params.interruptionDelay !== undefined) {
879
+ searchParams.set("interruption_delay", this.params.interruptionDelay.toString());
880
+ }
881
+ if (this.params.customerSupportAudioCapture) {
882
+ console.warn("`customerSupportAudioCapture=true` will record session audio. Only enable this when explicitly coordinating with AssemblyAI support.");
883
+ // The server's canonical wire name is `_customer_support_audio_capture`
884
+ // (leading underscore = "not officially supported / unstable"). The
885
+ // server also accepts `customer_support_audio_capture` via
886
+ // `populate_by_name=True`, but we send the underscore form to honor
887
+ // the server's stability marker.
888
+ searchParams.set("_customer_support_audio_capture", this.params.customerSupportAudioCapture.toString());
889
+ }
890
+ if (this.params.webhookUrl) {
891
+ searchParams.set("webhook_url", this.params.webhookUrl);
892
+ }
893
+ if (this.params.webhookAuthHeaderName) {
894
+ searchParams.set("webhook_auth_header_name", this.params.webhookAuthHeaderName);
895
+ }
896
+ if (this.params.webhookAuthHeaderValue) {
897
+ searchParams.set("webhook_auth_header_value", this.params.webhookAuthHeaderValue);
898
+ }
899
+ if (this.params.includePartialTurns !== undefined) {
900
+ searchParams.set("include_partial_turns", this.params.includePartialTurns.toString());
901
+ }
902
+ if (this.params.redactPii !== undefined) {
903
+ searchParams.set("redact_pii", this.params.redactPii.toString());
904
+ }
905
+ if (this.params.redactPiiPolicies !== undefined) {
906
+ searchParams.set("redact_pii_policies", JSON.stringify(this.params.redactPiiPolicies));
907
+ }
908
+ if (this.params.redactPiiSub !== undefined) {
909
+ searchParams.set("redact_pii_sub", this.params.redactPiiSub);
874
910
  }
875
911
  if (this.params.llmGateway !== undefined) {
876
912
  searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
@@ -33,9 +33,19 @@ export type StreamingTranscriberParams = {
33
33
  inactivityTimeout?: number;
34
34
  speakerLabels?: boolean;
35
35
  maxSpeakers?: number;
36
- noiseSuppressionModel?: NoiseSuppressionModel;
37
- noiseSuppressionThreshold?: number;
36
+ voiceFocus?: VoiceFocusModel;
37
+ voiceFocusThreshold?: number;
38
+ continuousPartials?: boolean;
39
+ interruptionDelay?: number;
40
+ customerSupportAudioCapture?: boolean;
41
+ includePartialTurns?: boolean;
42
+ redactPii?: boolean;
43
+ redactPiiPolicies?: StreamingPiiPolicy[];
44
+ redactPiiSub?: StreamingPiiSubstitution;
38
45
  llmGateway?: LLMGatewayConfig;
46
+ webhookUrl?: string;
47
+ webhookAuthHeaderName?: string;
48
+ webhookAuthHeaderValue?: string;
39
49
  };
40
50
  export type StreamingEvents = "open" | "close" | "turn" | "speechStarted" | "llmGatewayResponse" | "warning" | "error";
41
51
  export type StreamingListeners = {
@@ -49,7 +59,9 @@ export type StreamingListeners = {
49
59
  };
50
60
  export type StreamingSpeechModel = "universal-streaming-english" | "universal-streaming-multilingual" | "u3-rt-pro" | "whisper-rt" | "u3-pro";
51
61
  export type StreamingDomain = "medical-v1";
52
- export type NoiseSuppressionModel = "near-field" | "far-field";
62
+ export type VoiceFocusModel = "near-field" | "far-field";
63
+ export type StreamingPiiSubstitution = "hash" | "entity_name";
64
+ 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";
53
65
  export type StreamingTokenParams = {
54
66
  expires_in_seconds: number;
55
67
  max_session_duration_seconds?: number;
@@ -85,6 +97,7 @@ export type StreamingWord = {
85
97
  confidence: number;
86
98
  text: string;
87
99
  word_is_final: boolean;
100
+ speaker?: string;
88
101
  };
89
102
  export type TerminationEvent = {
90
103
  type: "Termination";
@@ -108,6 +121,7 @@ export type StreamingUpdateConfiguration = {
108
121
  keyterms_prompt?: string[];
109
122
  prompt?: string;
110
123
  filter_profanity?: boolean;
124
+ interruption_delay?: number;
111
125
  };
112
126
  export type StreamingForceEndpoint = {
113
127
  type: "ForceEndpoint";
package/dist/workerd.mjs CHANGED
@@ -15,7 +15,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
15
15
  defaultUserAgentString += navigator.userAgent;
16
16
  }
17
17
  const defaultUserAgent = {
18
- sdk: { name: "JavaScript", version: "4.32.1" },
18
+ sdk: { name: "JavaScript", version: "4.33.1" },
19
19
  };
20
20
  if (typeof process !== "undefined") {
21
21
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -871,11 +871,47 @@ class StreamingTranscriber {
871
871
  if (this.params.maxSpeakers !== undefined) {
872
872
  searchParams.set("max_speakers", this.params.maxSpeakers.toString());
873
873
  }
874
- if (this.params.noiseSuppressionModel) {
875
- searchParams.set("noise_suppression_model", this.params.noiseSuppressionModel);
874
+ if (this.params.voiceFocus) {
875
+ searchParams.set("voice_focus", this.params.voiceFocus);
876
876
  }
877
- if (this.params.noiseSuppressionThreshold !== undefined) {
878
- searchParams.set("noise_suppression_threshold", this.params.noiseSuppressionThreshold.toString());
877
+ if (this.params.voiceFocusThreshold !== undefined) {
878
+ searchParams.set("voice_focus_threshold", this.params.voiceFocusThreshold.toString());
879
+ }
880
+ if (this.params.continuousPartials !== undefined) {
881
+ searchParams.set("continuous_partials", this.params.continuousPartials.toString());
882
+ }
883
+ if (this.params.interruptionDelay !== undefined) {
884
+ searchParams.set("interruption_delay", this.params.interruptionDelay.toString());
885
+ }
886
+ if (this.params.customerSupportAudioCapture) {
887
+ console.warn("`customerSupportAudioCapture=true` will record session audio. Only enable this when explicitly coordinating with AssemblyAI support.");
888
+ // The server's canonical wire name is `_customer_support_audio_capture`
889
+ // (leading underscore = "not officially supported / unstable"). The
890
+ // server also accepts `customer_support_audio_capture` via
891
+ // `populate_by_name=True`, but we send the underscore form to honor
892
+ // the server's stability marker.
893
+ searchParams.set("_customer_support_audio_capture", this.params.customerSupportAudioCapture.toString());
894
+ }
895
+ if (this.params.webhookUrl) {
896
+ searchParams.set("webhook_url", this.params.webhookUrl);
897
+ }
898
+ if (this.params.webhookAuthHeaderName) {
899
+ searchParams.set("webhook_auth_header_name", this.params.webhookAuthHeaderName);
900
+ }
901
+ if (this.params.webhookAuthHeaderValue) {
902
+ searchParams.set("webhook_auth_header_value", this.params.webhookAuthHeaderValue);
903
+ }
904
+ if (this.params.includePartialTurns !== undefined) {
905
+ searchParams.set("include_partial_turns", this.params.includePartialTurns.toString());
906
+ }
907
+ if (this.params.redactPii !== undefined) {
908
+ searchParams.set("redact_pii", this.params.redactPii.toString());
909
+ }
910
+ if (this.params.redactPiiPolicies !== undefined) {
911
+ searchParams.set("redact_pii_policies", JSON.stringify(this.params.redactPiiPolicies));
912
+ }
913
+ if (this.params.redactPiiSub !== undefined) {
914
+ searchParams.set("redact_pii_sub", this.params.redactPiiSub);
879
915
  }
880
916
  if (this.params.llmGateway !== undefined) {
881
917
  searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assemblyai",
3
- "version": "4.32.1",
3
+ "version": "4.33.1",
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"
@@ -180,20 +180,86 @@ export class StreamingTranscriber {
180
180
  searchParams.set("max_speakers", this.params.maxSpeakers.toString());
181
181
  }
182
182
 
183
- if (this.params.noiseSuppressionModel) {
183
+ if (this.params.voiceFocus) {
184
+ searchParams.set("voice_focus", this.params.voiceFocus);
185
+ }
186
+
187
+ if (this.params.voiceFocusThreshold !== undefined) {
188
+ searchParams.set(
189
+ "voice_focus_threshold",
190
+ this.params.voiceFocusThreshold.toString(),
191
+ );
192
+ }
193
+
194
+ if (this.params.continuousPartials !== undefined) {
195
+ searchParams.set(
196
+ "continuous_partials",
197
+ this.params.continuousPartials.toString(),
198
+ );
199
+ }
200
+
201
+ if (this.params.interruptionDelay !== undefined) {
202
+ searchParams.set(
203
+ "interruption_delay",
204
+ this.params.interruptionDelay.toString(),
205
+ );
206
+ }
207
+
208
+ if (this.params.customerSupportAudioCapture) {
209
+ console.warn(
210
+ "`customerSupportAudioCapture=true` will record session audio. Only enable this when explicitly coordinating with AssemblyAI support.",
211
+ );
212
+ // The server's canonical wire name is `_customer_support_audio_capture`
213
+ // (leading underscore = "not officially supported / unstable"). The
214
+ // server also accepts `customer_support_audio_capture` via
215
+ // `populate_by_name=True`, but we send the underscore form to honor
216
+ // the server's stability marker.
217
+ searchParams.set(
218
+ "_customer_support_audio_capture",
219
+ this.params.customerSupportAudioCapture.toString(),
220
+ );
221
+ }
222
+
223
+ if (this.params.webhookUrl) {
224
+ searchParams.set("webhook_url", this.params.webhookUrl);
225
+ }
226
+
227
+ if (this.params.webhookAuthHeaderName) {
228
+ searchParams.set(
229
+ "webhook_auth_header_name",
230
+ this.params.webhookAuthHeaderName,
231
+ );
232
+ }
233
+
234
+ if (this.params.webhookAuthHeaderValue) {
184
235
  searchParams.set(
185
- "noise_suppression_model",
186
- this.params.noiseSuppressionModel,
236
+ "webhook_auth_header_value",
237
+ this.params.webhookAuthHeaderValue,
187
238
  );
188
239
  }
189
240
 
190
- if (this.params.noiseSuppressionThreshold !== undefined) {
241
+ if (this.params.includePartialTurns !== undefined) {
191
242
  searchParams.set(
192
- "noise_suppression_threshold",
193
- this.params.noiseSuppressionThreshold.toString(),
243
+ "include_partial_turns",
244
+ this.params.includePartialTurns.toString(),
194
245
  );
195
246
  }
196
247
 
248
+ if (this.params.redactPii !== undefined) {
249
+ searchParams.set("redact_pii", this.params.redactPii.toString());
250
+ }
251
+
252
+ if (this.params.redactPiiPolicies !== undefined) {
253
+ searchParams.set(
254
+ "redact_pii_policies",
255
+ JSON.stringify(this.params.redactPiiPolicies),
256
+ );
257
+ }
258
+
259
+ if (this.params.redactPiiSub !== undefined) {
260
+ searchParams.set("redact_pii_sub", this.params.redactPiiSub);
261
+ }
262
+
197
263
  if (this.params.llmGateway !== undefined) {
198
264
  searchParams.set("llm_gateway", JSON.stringify(this.params.llmGateway));
199
265
  }
@@ -36,9 +36,19 @@ export type StreamingTranscriberParams = {
36
36
  inactivityTimeout?: number;
37
37
  speakerLabels?: boolean;
38
38
  maxSpeakers?: number;
39
- noiseSuppressionModel?: NoiseSuppressionModel;
40
- noiseSuppressionThreshold?: number;
39
+ voiceFocus?: VoiceFocusModel;
40
+ voiceFocusThreshold?: number;
41
+ continuousPartials?: boolean;
42
+ interruptionDelay?: number;
43
+ customerSupportAudioCapture?: boolean;
44
+ includePartialTurns?: boolean;
45
+ redactPii?: boolean;
46
+ redactPiiPolicies?: StreamingPiiPolicy[];
47
+ redactPiiSub?: StreamingPiiSubstitution;
41
48
  llmGateway?: LLMGatewayConfig;
49
+ webhookUrl?: string;
50
+ webhookAuthHeaderName?: string;
51
+ webhookAuthHeaderValue?: string;
42
52
  };
43
53
 
44
54
  export type StreamingEvents =
@@ -69,7 +79,78 @@ export type StreamingSpeechModel =
69
79
 
70
80
  export type StreamingDomain = "medical-v1";
71
81
 
72
- export type NoiseSuppressionModel = "near-field" | "far-field";
82
+ export type VoiceFocusModel = "near-field" | "far-field";
83
+
84
+ export type StreamingPiiSubstitution = "hash" | "entity_name";
85
+
86
+ // Source of truth: assemblyai/engineering/projects/pii/enums.py (`AAIEntities`).
87
+ // Keep this union in sync when entities are added or removed server-side.
88
+ export type StreamingPiiPolicy =
89
+ | "account_number"
90
+ | "banking_information"
91
+ | "blood_type"
92
+ | "corporate_action"
93
+ | "credit_card_cvv"
94
+ | "credit_card_expiration"
95
+ | "credit_card_number"
96
+ | "date"
97
+ | "date_interval"
98
+ | "date_of_birth"
99
+ | "day"
100
+ | "drivers_license"
101
+ | "drug"
102
+ | "duration"
103
+ | "effect"
104
+ | "email_address"
105
+ | "event"
106
+ | "filename"
107
+ | "financial_metric"
108
+ | "gender"
109
+ | "gender_sexuality"
110
+ | "healthcare_number"
111
+ | "injury"
112
+ | "ip_address"
113
+ | "language"
114
+ | "location"
115
+ | "location_address"
116
+ | "location_address_street"
117
+ | "location_city"
118
+ | "location_coordinate"
119
+ | "location_country"
120
+ | "location_state"
121
+ | "location_zip"
122
+ | "marital_status"
123
+ | "medical_code"
124
+ | "medical_condition"
125
+ | "medical_process"
126
+ | "money_amount"
127
+ | "month"
128
+ | "nationality"
129
+ | "number_sequence"
130
+ | "occupation"
131
+ | "organization"
132
+ | "organization_id"
133
+ | "organization_medical_facility"
134
+ | "passport_number"
135
+ | "password"
136
+ | "person_age"
137
+ | "person_name"
138
+ | "phone_number"
139
+ | "physical_attribute"
140
+ | "political_affiliation"
141
+ | "product"
142
+ | "project"
143
+ | "religion"
144
+ | "sexuality"
145
+ | "statistics"
146
+ | "time"
147
+ | "trend"
148
+ | "url"
149
+ | "us_social_security_number"
150
+ | "username"
151
+ | "vehicle_id"
152
+ | "year"
153
+ | "zodiac_sign";
73
154
 
74
155
  export type StreamingTokenParams = {
75
156
  expires_in_seconds: number;
@@ -112,6 +193,7 @@ export type StreamingWord = {
112
193
  confidence: number;
113
194
  text: string;
114
195
  word_is_final: boolean;
196
+ speaker?: string;
115
197
  };
116
198
 
117
199
  export type TerminationEvent = {
@@ -138,6 +220,7 @@ export type StreamingUpdateConfiguration = {
138
220
  keyterms_prompt?: string[];
139
221
  prompt?: string;
140
222
  filter_profanity?: boolean;
223
+ interruption_delay?: number;
141
224
  };
142
225
 
143
226
  export type StreamingForceEndpoint = {