assemblyai 4.3.0 → 4.3.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.
@@ -205,8 +205,8 @@
205
205
  this.sampleRate = (_b = params.sampleRate) !== null && _b !== void 0 ? _b : 16000;
206
206
  this.wordBoost = params.wordBoost;
207
207
  this.encoding = params.encoding;
208
- this.end_utterance_silence_threshold =
209
- params.end_utterance_silence_threshold;
208
+ this.endUtteranceSilenceThreshold =
209
+ params.endUtteranceSilenceThreshold;
210
210
  if ("token" in params && params.token)
211
211
  this.token = params.token;
212
212
  if ("apiKey" in params && params.apiKey)
@@ -254,11 +254,11 @@
254
254
  }
255
255
  this.socket.binaryType = "arraybuffer";
256
256
  this.socket.onopen = () => {
257
- if (this.end_utterance_silence_threshold === undefined ||
258
- this.end_utterance_silence_threshold === null) {
257
+ if (this.endUtteranceSilenceThreshold === undefined ||
258
+ this.endUtteranceSilenceThreshold === null) {
259
259
  return;
260
260
  }
261
- this.configureEndUtteranceSilenceThreshold(this.end_utterance_silence_threshold);
261
+ this.configureEndUtteranceSilenceThreshold(this.endUtteranceSilenceThreshold);
262
262
  };
263
263
  this.socket.onclose = ({ code, reason }) => {
264
264
  var _a, _b;
@@ -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,s,i){return new(s||(s=Promise))((function(n,o){function r(e){try{c(i.next(e))}catch(e){o(e)}}function a(e){try{c(i.throw(e))}catch(e){o(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(r,a)}c((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class s{constructor(e){this.params=e}fetch(e,s){var i;return t(this,void 0,void 0,(function*(){(s=null!=s?s:{}).headers=null!==(i=s.headers)&&void 0!==i?i:{},s.headers=Object.assign({Authorization:this.params.apiKey,"Content-Type":"application/json"},s.headers),e.startsWith("http")||(e=this.params.baseUrl+e);const t=yield fetch(e,s);if(t.status>=400){let e;const s=yield t.text();if(s){try{e=JSON.parse(s)}catch(e){}if(null==e?void 0:e.error)throw new Error(e.error);throw new Error(s)}throw new Error(`HTTP Error: ${t.status} ${t.statusText}`)}return t}))}fetchJson(e,s){return t(this,void 0,void 0,(function*(){return(yield this.fetch(e,s)).json()}))}}class i extends s{summary(e){return this.fetchJson("/lemur/v3/generate/summary",{method:"POST",body:JSON.stringify(e)})}questionAnswer(e){return this.fetchJson("/lemur/v3/generate/question-answer",{method:"POST",body:JSON.stringify(e)})}actionItems(e){return this.fetchJson("/lemur/v3/generate/action-items",{method:"POST",body:JSON.stringify(e)})}task(e){return this.fetchJson("/lemur/v3/generate/task",{method:"POST",body:JSON.stringify(e)})}purgeRequestData(e){return this.fetchJson(`/lemur/v3/${e}`,{method:"DELETE"})}}const{WritableStream:n}="undefined"!=typeof window?window:"undefined"!=typeof global?global:globalThis;var o=null;"undefined"!=typeof WebSocket?o=WebSocket:"undefined"!=typeof MozWebSocket?o=MozWebSocket:"undefined"!=typeof global?o=global.WebSocket||global.MozWebSocket:"undefined"!=typeof window?o=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(o=self.WebSocket||self.MozWebSocket);var r,a=o;!function(e){e[e.BadSampleRate=4e3]="BadSampleRate",e[e.AuthFailed=4001]="AuthFailed",e[e.InsufficientFundsOrFreeAccount=4002]="InsufficientFundsOrFreeAccount",e[e.NonexistentSessionId=4004]="NonexistentSessionId",e[e.SessionExpired=4008]="SessionExpired",e[e.ClosedSession=4010]="ClosedSession",e[e.RateLimited=4029]="RateLimited",e[e.UniqueSessionViolation=4030]="UniqueSessionViolation",e[e.SessionTimeout=4031]="SessionTimeout",e[e.AudioTooShort=4032]="AudioTooShort",e[e.AudioTooLong=4033]="AudioTooLong",e[e.BadJson=4100]="BadJson",e[e.BadSchema=4101]="BadSchema",e[e.TooManyStreams=4102]="TooManyStreams",e[e.Reconnected=4103]="Reconnected",e[e.ReconnectAttemptsExhausted=1013]="ReconnectAttemptsExhausted"}(r||(r={}));const c={[r.BadSampleRate]:"Sample rate must be a positive integer",[r.AuthFailed]:"Not Authorized",[r.InsufficientFundsOrFreeAccount]:"Insufficient funds or you are using a free account. This feature is paid-only and requires you to add a credit card. Please visit https://assemblyai.com/dashboard/ to add a credit card to your account.",[r.NonexistentSessionId]:"Session ID does not exist",[r.SessionExpired]:"Session has expired",[r.ClosedSession]:"Session is closed",[r.RateLimited]:"Rate limited",[r.UniqueSessionViolation]:"Unique session violation",[r.SessionTimeout]:"Session Timeout",[r.AudioTooShort]:"Audio too short",[r.AudioTooLong]:"Audio too long",[r.BadJson]:"Bad JSON",[r.BadSchema]:"Bad schema",[r.TooManyStreams]:"Too many streams",[r.Reconnected]:"Reconnected",[r.ReconnectAttemptsExhausted]:"Reconnect attempts exhausted"};class l extends Error{}const d='{"terminate_session":true}';class h{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.end_utterance_silence_threshold=e.end_utterance_silence_threshold,"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),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=new a(t.toString()):this.socket=new a(t.toString(),{headers:{Authorization:this.apiKey}}),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{void 0!==this.end_utterance_silence_threshold&&null!==this.end_utterance_silence_threshold&&this.configureEndUtteranceSilenceThreshold(this.end_utterance_silence_threshold)},this.socket.onclose=({code:e,reason:t})=>{var s,i;t||e in r&&(t=c[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,o,r,a,c,d,h,u,f,p,m;const y=JSON.parse(t.toString());if("error"in y)null===(i=(s=this.listeners).error)||void 0===i||i.call(s,new l(y.error));else switch(y.message_type){case"SessionBegins":{const t={sessionId:y.session_id,expiresAt:new Date(y.expires_at)};e(t),null===(o=(n=this.listeners).open)||void 0===o||o.call(n,t);break}case"PartialTranscript":y.created=new Date(y.created),null===(a=(r=this.listeners).transcript)||void 0===a||a.call(r,y),null===(d=(c=this.listeners)["transcript.partial"])||void 0===d||d.call(c,y);break;case"FinalTranscript":y.created=new Date(y.created),null===(u=(h=this.listeners).transcript)||void 0===u||u.call(h,y),null===(p=(f=this.listeners)["transcript.final"])||void 0===p||p.call(f,y);break;case"SessionTerminated":null===(m=this.sessionTerminatedResolve)||void 0===m||m.call(this)}}}))}sendAudio(e){this.send(e)}stream(){return new n({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!==a.OPEN)throw new Error("Socket is not open for communication");this.socket.send(e)}close(e=!0){return t(this,void 0,void 0,(function*(){if(this.socket){if(this.socket.readyState===a.OPEN)if(e){const e=new Promise((e=>{this.sessionTerminatedResolve=e}));this.socket.send(d),yield e}else this.socket.send(d);"removeAllListeners"in this.socket&&this.socket.removeAllListeners(),this.socket.close()}this.listeners={},this.socket=void 0}))}}class u extends s{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 h(t)}createTemporaryToken(e){return t(this,void 0,void 0,(function*(){return(yield this.fetchJson("/v2/realtime/token",{method:"POST",body:JSON.stringify(e)})).token}))}}function f(e){return e.startsWith("http")||e.startsWith("https")?null:e.startsWith("file://")?e.substring(7):e.startsWith("file:")?e.substring(5):e}class p extends s{constructor(e,t){super(e),this.files=t}transcribe(e,s){return t(this,void 0,void 0,(function*(){const t=yield this.submit(e);return yield this.waitUntilReady(t.id,s)}))}submit(e){return t(this,void 0,void 0,(function*(){const{audio:t}=e,s=function(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}(e,["audio"]);let i;if("string"==typeof t){const e=f(t);i=null!==e?yield this.files.upload(e):t}else i=yield this.files.upload(t);return yield this.fetchJson("/v2/transcript",{method:"POST",body:JSON.stringify(Object.assign(Object.assign({},s),{audio_url:i}))})}))}create(e,s){var i;return t(this,void 0,void 0,(function*(){const t=f(e.audio_url);if(null!==t){const s=yield this.files.upload(t);e.audio_url=s}const n=yield this.fetchJson("/v2/transcript",{method:"POST",body:JSON.stringify(e)});return null===(i=null==s?void 0:s.poll)||void 0===i||i?yield this.waitUntilReady(n.id,s):n}))}waitUntilReady(e,s){var i,n;return t(this,void 0,void 0,(function*(){const t=null!==(i=null==s?void 0:s.pollingInterval)&&void 0!==i?i:3e3,o=null!==(n=null==s?void 0:s.pollingTimeout)&&void 0!==n?n:-1,r=Date.now();for(;;){const s=yield this.get(e);if("completed"===s.status||"error"===s.status)return s;if(o>0&&Date.now()-r>o)throw new Error("Polling timeout");yield new Promise((e=>setTimeout(e,t)))}}))}get(e){return this.fetchJson(`/v2/transcript/${e}`)}list(e){return t(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,s="srt",i){return t(this,void 0,void 0,(function*(){let t=`/v2/transcript/${e}/${s}`;if(i){const e=new URLSearchParams;e.set("chars_per_caption",i.toString()),t+=`?${e.toString()}`}const n=yield this.fetch(t);return yield n.text()}))}redactions(e){return this.fetchJson(`/v2/transcript/${e}/redacted-audio`)}}class m extends s{upload(e){return t(this,void 0,void 0,(function*(){let s;s="string"==typeof e?yield function(e){return t(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:s,headers:{"Content-Type":"application/octet-stream"},duplex:"half"})).upload_url}))}}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 m(e),this.transcripts=new p(e,this.files),this.lemur=new i(e),this.realtime=new u(e)}},e.FileService=m,e.LemurService=i,e.RealtimeService=class extends h{},e.RealtimeServiceFactory=class extends u{},e.RealtimeTranscriber=h,e.RealtimeTranscriberFactory=u,e.TranscriptService=p}));
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,s,i){return new(s||(s=Promise))((function(n,o){function r(e){try{c(i.next(e))}catch(e){o(e)}}function a(e){try{c(i.throw(e))}catch(e){o(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(r,a)}c((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class s{constructor(e){this.params=e}fetch(e,s){var i;return t(this,void 0,void 0,(function*(){(s=null!=s?s:{}).headers=null!==(i=s.headers)&&void 0!==i?i:{},s.headers=Object.assign({Authorization:this.params.apiKey,"Content-Type":"application/json"},s.headers),e.startsWith("http")||(e=this.params.baseUrl+e);const t=yield fetch(e,s);if(t.status>=400){let e;const s=yield t.text();if(s){try{e=JSON.parse(s)}catch(e){}if(null==e?void 0:e.error)throw new Error(e.error);throw new Error(s)}throw new Error(`HTTP Error: ${t.status} ${t.statusText}`)}return t}))}fetchJson(e,s){return t(this,void 0,void 0,(function*(){return(yield this.fetch(e,s)).json()}))}}class i extends s{summary(e){return this.fetchJson("/lemur/v3/generate/summary",{method:"POST",body:JSON.stringify(e)})}questionAnswer(e){return this.fetchJson("/lemur/v3/generate/question-answer",{method:"POST",body:JSON.stringify(e)})}actionItems(e){return this.fetchJson("/lemur/v3/generate/action-items",{method:"POST",body:JSON.stringify(e)})}task(e){return this.fetchJson("/lemur/v3/generate/task",{method:"POST",body:JSON.stringify(e)})}purgeRequestData(e){return this.fetchJson(`/lemur/v3/${e}`,{method:"DELETE"})}}const{WritableStream:n}="undefined"!=typeof window?window:"undefined"!=typeof global?global:globalThis;var o=null;"undefined"!=typeof WebSocket?o=WebSocket:"undefined"!=typeof MozWebSocket?o=MozWebSocket:"undefined"!=typeof global?o=global.WebSocket||global.MozWebSocket:"undefined"!=typeof window?o=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(o=self.WebSocket||self.MozWebSocket);var r,a=o;!function(e){e[e.BadSampleRate=4e3]="BadSampleRate",e[e.AuthFailed=4001]="AuthFailed",e[e.InsufficientFundsOrFreeAccount=4002]="InsufficientFundsOrFreeAccount",e[e.NonexistentSessionId=4004]="NonexistentSessionId",e[e.SessionExpired=4008]="SessionExpired",e[e.ClosedSession=4010]="ClosedSession",e[e.RateLimited=4029]="RateLimited",e[e.UniqueSessionViolation=4030]="UniqueSessionViolation",e[e.SessionTimeout=4031]="SessionTimeout",e[e.AudioTooShort=4032]="AudioTooShort",e[e.AudioTooLong=4033]="AudioTooLong",e[e.BadJson=4100]="BadJson",e[e.BadSchema=4101]="BadSchema",e[e.TooManyStreams=4102]="TooManyStreams",e[e.Reconnected=4103]="Reconnected",e[e.ReconnectAttemptsExhausted=1013]="ReconnectAttemptsExhausted"}(r||(r={}));const c={[r.BadSampleRate]:"Sample rate must be a positive integer",[r.AuthFailed]:"Not Authorized",[r.InsufficientFundsOrFreeAccount]:"Insufficient funds or you are using a free account. This feature is paid-only and requires you to add a credit card. Please visit https://assemblyai.com/dashboard/ to add a credit card to your account.",[r.NonexistentSessionId]:"Session ID does not exist",[r.SessionExpired]:"Session has expired",[r.ClosedSession]:"Session is closed",[r.RateLimited]:"Rate limited",[r.UniqueSessionViolation]:"Unique session violation",[r.SessionTimeout]:"Session Timeout",[r.AudioTooShort]:"Audio too short",[r.AudioTooLong]:"Audio too long",[r.BadJson]:"Bad JSON",[r.BadSchema]:"Bad schema",[r.TooManyStreams]:"Too many streams",[r.Reconnected]:"Reconnected",[r.ReconnectAttemptsExhausted]:"Reconnect attempts exhausted"};class l extends Error{}const d='{"terminate_session":true}';class h{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,"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),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=new a(t.toString()):this.socket=new a(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 r&&(t=c[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,o,r,a,c,d,h,u,f,p,m;const y=JSON.parse(t.toString());if("error"in y)null===(i=(s=this.listeners).error)||void 0===i||i.call(s,new l(y.error));else switch(y.message_type){case"SessionBegins":{const t={sessionId:y.session_id,expiresAt:new Date(y.expires_at)};e(t),null===(o=(n=this.listeners).open)||void 0===o||o.call(n,t);break}case"PartialTranscript":y.created=new Date(y.created),null===(a=(r=this.listeners).transcript)||void 0===a||a.call(r,y),null===(d=(c=this.listeners)["transcript.partial"])||void 0===d||d.call(c,y);break;case"FinalTranscript":y.created=new Date(y.created),null===(u=(h=this.listeners).transcript)||void 0===u||u.call(h,y),null===(p=(f=this.listeners)["transcript.final"])||void 0===p||p.call(f,y);break;case"SessionTerminated":null===(m=this.sessionTerminatedResolve)||void 0===m||m.call(this)}}}))}sendAudio(e){this.send(e)}stream(){return new n({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!==a.OPEN)throw new Error("Socket is not open for communication");this.socket.send(e)}close(e=!0){return t(this,void 0,void 0,(function*(){if(this.socket){if(this.socket.readyState===a.OPEN)if(e){const e=new Promise((e=>{this.sessionTerminatedResolve=e}));this.socket.send(d),yield e}else this.socket.send(d);"removeAllListeners"in this.socket&&this.socket.removeAllListeners(),this.socket.close()}this.listeners={},this.socket=void 0}))}}class u extends s{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 h(t)}createTemporaryToken(e){return t(this,void 0,void 0,(function*(){return(yield this.fetchJson("/v2/realtime/token",{method:"POST",body:JSON.stringify(e)})).token}))}}function f(e){return e.startsWith("http")||e.startsWith("https")?null:e.startsWith("file://")?e.substring(7):e.startsWith("file:")?e.substring(5):e}class p extends s{constructor(e,t){super(e),this.files=t}transcribe(e,s){return t(this,void 0,void 0,(function*(){const t=yield this.submit(e);return yield this.waitUntilReady(t.id,s)}))}submit(e){return t(this,void 0,void 0,(function*(){const{audio:t}=e,s=function(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}(e,["audio"]);let i;if("string"==typeof t){const e=f(t);i=null!==e?yield this.files.upload(e):t}else i=yield this.files.upload(t);return yield this.fetchJson("/v2/transcript",{method:"POST",body:JSON.stringify(Object.assign(Object.assign({},s),{audio_url:i}))})}))}create(e,s){var i;return t(this,void 0,void 0,(function*(){const t=f(e.audio_url);if(null!==t){const s=yield this.files.upload(t);e.audio_url=s}const n=yield this.fetchJson("/v2/transcript",{method:"POST",body:JSON.stringify(e)});return null===(i=null==s?void 0:s.poll)||void 0===i||i?yield this.waitUntilReady(n.id,s):n}))}waitUntilReady(e,s){var i,n;return t(this,void 0,void 0,(function*(){const t=null!==(i=null==s?void 0:s.pollingInterval)&&void 0!==i?i:3e3,o=null!==(n=null==s?void 0:s.pollingTimeout)&&void 0!==n?n:-1,r=Date.now();for(;;){const s=yield this.get(e);if("completed"===s.status||"error"===s.status)return s;if(o>0&&Date.now()-r>o)throw new Error("Polling timeout");yield new Promise((e=>setTimeout(e,t)))}}))}get(e){return this.fetchJson(`/v2/transcript/${e}`)}list(e){return t(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,s="srt",i){return t(this,void 0,void 0,(function*(){let t=`/v2/transcript/${e}/${s}`;if(i){const e=new URLSearchParams;e.set("chars_per_caption",i.toString()),t+=`?${e.toString()}`}const n=yield this.fetch(t);return yield n.text()}))}redactions(e){return this.fetchJson(`/v2/transcript/${e}/redacted-audio`)}}class m extends s{upload(e){return t(this,void 0,void 0,(function*(){let s;s="string"==typeof e?yield function(e){return t(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:s,headers:{"Content-Type":"application/octet-stream"},duplex:"half"})).upload_url}))}}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 m(e),this.transcripts=new p(e,this.files),this.lemur=new i(e),this.realtime=new u(e)}},e.FileService=m,e.LemurService=i,e.RealtimeService=class extends h{},e.RealtimeServiceFactory=class extends u{},e.RealtimeTranscriber=h,e.RealtimeTranscriberFactory=u,e.TranscriptService=p}));
package/dist/bun.mjs CHANGED
@@ -139,8 +139,8 @@ class RealtimeTranscriber {
139
139
  this.sampleRate = params.sampleRate ?? 16000;
140
140
  this.wordBoost = params.wordBoost;
141
141
  this.encoding = params.encoding;
142
- this.end_utterance_silence_threshold =
143
- params.end_utterance_silence_threshold;
142
+ this.endUtteranceSilenceThreshold =
143
+ params.endUtteranceSilenceThreshold;
144
144
  if ("token" in params && params.token)
145
145
  this.token = params.token;
146
146
  if ("apiKey" in params && params.apiKey)
@@ -188,11 +188,11 @@ class RealtimeTranscriber {
188
188
  }
189
189
  this.socket.binaryType = "arraybuffer";
190
190
  this.socket.onopen = () => {
191
- if (this.end_utterance_silence_threshold === undefined ||
192
- this.end_utterance_silence_threshold === null) {
191
+ if (this.endUtteranceSilenceThreshold === undefined ||
192
+ this.endUtteranceSilenceThreshold === null) {
193
193
  return;
194
194
  }
195
- this.configureEndUtteranceSilenceThreshold(this.end_utterance_silence_threshold);
195
+ this.configureEndUtteranceSilenceThreshold(this.endUtteranceSilenceThreshold);
196
196
  };
197
197
  this.socket.onclose = ({ code, reason }) => {
198
198
  if (!reason) {
package/dist/deno.mjs CHANGED
@@ -139,8 +139,8 @@ class RealtimeTranscriber {
139
139
  this.sampleRate = params.sampleRate ?? 16000;
140
140
  this.wordBoost = params.wordBoost;
141
141
  this.encoding = params.encoding;
142
- this.end_utterance_silence_threshold =
143
- params.end_utterance_silence_threshold;
142
+ this.endUtteranceSilenceThreshold =
143
+ params.endUtteranceSilenceThreshold;
144
144
  if ("token" in params && params.token)
145
145
  this.token = params.token;
146
146
  if ("apiKey" in params && params.apiKey)
@@ -188,11 +188,11 @@ class RealtimeTranscriber {
188
188
  }
189
189
  this.socket.binaryType = "arraybuffer";
190
190
  this.socket.onopen = () => {
191
- if (this.end_utterance_silence_threshold === undefined ||
192
- this.end_utterance_silence_threshold === null) {
191
+ if (this.endUtteranceSilenceThreshold === undefined ||
192
+ this.endUtteranceSilenceThreshold === null) {
193
193
  return;
194
194
  }
195
- this.configureEndUtteranceSilenceThreshold(this.end_utterance_silence_threshold);
195
+ this.configureEndUtteranceSilenceThreshold(this.endUtteranceSilenceThreshold);
196
196
  };
197
197
  this.socket.onclose = ({ code, reason }) => {
198
198
  if (!reason) {
package/dist/index.cjs CHANGED
@@ -187,8 +187,8 @@ class RealtimeTranscriber {
187
187
  this.sampleRate = (_b = params.sampleRate) !== null && _b !== void 0 ? _b : 16000;
188
188
  this.wordBoost = params.wordBoost;
189
189
  this.encoding = params.encoding;
190
- this.end_utterance_silence_threshold =
191
- params.end_utterance_silence_threshold;
190
+ this.endUtteranceSilenceThreshold =
191
+ params.endUtteranceSilenceThreshold;
192
192
  if ("token" in params && params.token)
193
193
  this.token = params.token;
194
194
  if ("apiKey" in params && params.apiKey)
@@ -236,11 +236,11 @@ class RealtimeTranscriber {
236
236
  }
237
237
  this.socket.binaryType = "arraybuffer";
238
238
  this.socket.onopen = () => {
239
- if (this.end_utterance_silence_threshold === undefined ||
240
- this.end_utterance_silence_threshold === null) {
239
+ if (this.endUtteranceSilenceThreshold === undefined ||
240
+ this.endUtteranceSilenceThreshold === null) {
241
241
  return;
242
242
  }
243
- this.configureEndUtteranceSilenceThreshold(this.end_utterance_silence_threshold);
243
+ this.configureEndUtteranceSilenceThreshold(this.endUtteranceSilenceThreshold);
244
244
  };
245
245
  this.socket.onclose = ({ code, reason }) => {
246
246
  var _a, _b;
package/dist/index.mjs CHANGED
@@ -185,8 +185,8 @@ class RealtimeTranscriber {
185
185
  this.sampleRate = (_b = params.sampleRate) !== null && _b !== void 0 ? _b : 16000;
186
186
  this.wordBoost = params.wordBoost;
187
187
  this.encoding = params.encoding;
188
- this.end_utterance_silence_threshold =
189
- params.end_utterance_silence_threshold;
188
+ this.endUtteranceSilenceThreshold =
189
+ params.endUtteranceSilenceThreshold;
190
190
  if ("token" in params && params.token)
191
191
  this.token = params.token;
192
192
  if ("apiKey" in params && params.apiKey)
@@ -234,11 +234,11 @@ class RealtimeTranscriber {
234
234
  }
235
235
  this.socket.binaryType = "arraybuffer";
236
236
  this.socket.onopen = () => {
237
- if (this.end_utterance_silence_threshold === undefined ||
238
- this.end_utterance_silence_threshold === null) {
237
+ if (this.endUtteranceSilenceThreshold === undefined ||
238
+ this.endUtteranceSilenceThreshold === null) {
239
239
  return;
240
240
  }
241
- this.configureEndUtteranceSilenceThreshold(this.end_utterance_silence_threshold);
241
+ this.configureEndUtteranceSilenceThreshold(this.endUtteranceSilenceThreshold);
242
242
  };
243
243
  this.socket.onclose = ({ code, reason }) => {
244
244
  var _a, _b;
package/dist/node.cjs CHANGED
@@ -138,8 +138,8 @@ class RealtimeTranscriber {
138
138
  this.sampleRate = params.sampleRate ?? 16000;
139
139
  this.wordBoost = params.wordBoost;
140
140
  this.encoding = params.encoding;
141
- this.end_utterance_silence_threshold =
142
- params.end_utterance_silence_threshold;
141
+ this.endUtteranceSilenceThreshold =
142
+ params.endUtteranceSilenceThreshold;
143
143
  if ("token" in params && params.token)
144
144
  this.token = params.token;
145
145
  if ("apiKey" in params && params.apiKey)
@@ -187,11 +187,11 @@ class RealtimeTranscriber {
187
187
  }
188
188
  this.socket.binaryType = "arraybuffer";
189
189
  this.socket.onopen = () => {
190
- if (this.end_utterance_silence_threshold === undefined ||
191
- this.end_utterance_silence_threshold === null) {
190
+ if (this.endUtteranceSilenceThreshold === undefined ||
191
+ this.endUtteranceSilenceThreshold === null) {
192
192
  return;
193
193
  }
194
- this.configureEndUtteranceSilenceThreshold(this.end_utterance_silence_threshold);
194
+ this.configureEndUtteranceSilenceThreshold(this.endUtteranceSilenceThreshold);
195
195
  };
196
196
  this.socket.onclose = ({ code, reason }) => {
197
197
  if (!reason) {
package/dist/node.mjs CHANGED
@@ -136,8 +136,8 @@ class RealtimeTranscriber {
136
136
  this.sampleRate = params.sampleRate ?? 16000;
137
137
  this.wordBoost = params.wordBoost;
138
138
  this.encoding = params.encoding;
139
- this.end_utterance_silence_threshold =
140
- params.end_utterance_silence_threshold;
139
+ this.endUtteranceSilenceThreshold =
140
+ params.endUtteranceSilenceThreshold;
141
141
  if ("token" in params && params.token)
142
142
  this.token = params.token;
143
143
  if ("apiKey" in params && params.apiKey)
@@ -185,11 +185,11 @@ class RealtimeTranscriber {
185
185
  }
186
186
  this.socket.binaryType = "arraybuffer";
187
187
  this.socket.onopen = () => {
188
- if (this.end_utterance_silence_threshold === undefined ||
189
- this.end_utterance_silence_threshold === null) {
188
+ if (this.endUtteranceSilenceThreshold === undefined ||
189
+ this.endUtteranceSilenceThreshold === null) {
190
190
  return;
191
191
  }
192
- this.configureEndUtteranceSilenceThreshold(this.end_utterance_silence_threshold);
192
+ this.configureEndUtteranceSilenceThreshold(this.endUtteranceSilenceThreshold);
193
193
  };
194
194
  this.socket.onclose = ({ code, reason }) => {
195
195
  if (!reason) {
@@ -6,7 +6,7 @@ export declare class RealtimeTranscriber {
6
6
  private encoding?;
7
7
  private apiKey?;
8
8
  private token?;
9
- private end_utterance_silence_threshold?;
9
+ private endUtteranceSilenceThreshold?;
10
10
  private socket?;
11
11
  private listeners;
12
12
  private sessionTerminatedResolve?;
@@ -19,7 +19,7 @@ type CreateRealtimeTranscriberParams = {
19
19
  /**
20
20
  * The duration of the end utterance silence threshold in milliseconds
21
21
  */
22
- end_utterance_silence_threshold?: number;
22
+ endUtteranceSilenceThreshold?: number;
23
23
  } & ({
24
24
  /**
25
25
  * The API key used to authenticate the RealtimeTranscriber
@@ -56,7 +56,7 @@ type RealtimeTranscriberParams = {
56
56
  /**
57
57
  * The duration of the end utterance silence threshold in milliseconds
58
58
  */
59
- end_utterance_silence_threshold?: number;
59
+ endUtteranceSilenceThreshold?: number;
60
60
  } & ({
61
61
  /**
62
62
  * The API key used to authenticate the RealtimeTranscriber.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assemblyai",
3
- "version": "4.3.0",
3
+ "version": "4.3.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"
@@ -48,7 +48,7 @@ export class RealtimeTranscriber {
48
48
  private encoding?: AudioEncoding;
49
49
  private apiKey?: string;
50
50
  private token?: string;
51
- private end_utterance_silence_threshold?: number;
51
+ private endUtteranceSilenceThreshold?: number;
52
52
  private socket?: WebSocket;
53
53
  private listeners: RealtimeListeners = {};
54
54
  private sessionTerminatedResolve?: () => void;
@@ -58,8 +58,8 @@ export class RealtimeTranscriber {
58
58
  this.sampleRate = params.sampleRate ?? 16_000;
59
59
  this.wordBoost = params.wordBoost;
60
60
  this.encoding = params.encoding;
61
- this.end_utterance_silence_threshold =
62
- params.end_utterance_silence_threshold;
61
+ this.endUtteranceSilenceThreshold =
62
+ params.endUtteranceSilenceThreshold;
63
63
  if ("token" in params && params.token) this.token = params.token;
64
64
  if ("apiKey" in params && params.apiKey) this.apiKey = params.apiKey;
65
65
 
@@ -130,13 +130,13 @@ export class RealtimeTranscriber {
130
130
 
131
131
  this.socket.onopen = () => {
132
132
  if (
133
- this.end_utterance_silence_threshold === undefined ||
134
- this.end_utterance_silence_threshold === null
133
+ this.endUtteranceSilenceThreshold === undefined ||
134
+ this.endUtteranceSilenceThreshold === null
135
135
  ) {
136
136
  return;
137
137
  }
138
138
  this.configureEndUtteranceSilenceThreshold(
139
- this.end_utterance_silence_threshold
139
+ this.endUtteranceSilenceThreshold
140
140
  );
141
141
  };
142
142
 
@@ -26,7 +26,7 @@ type CreateRealtimeTranscriberParams = {
26
26
  /**
27
27
  * The duration of the end utterance silence threshold in milliseconds
28
28
  */
29
- end_utterance_silence_threshold?: number;
29
+ endUtteranceSilenceThreshold?: number;
30
30
  } & (
31
31
  | {
32
32
  /**
@@ -68,7 +68,7 @@ type RealtimeTranscriberParams = {
68
68
  /**
69
69
  * The duration of the end utterance silence threshold in milliseconds
70
70
  */
71
- end_utterance_silence_threshold?: number;
71
+ endUtteranceSilenceThreshold?: number;
72
72
  } & (
73
73
  | {
74
74
  /**