assemblyai 4.6.0 → 4.6.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,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.6.1]
4
+
5
+ - Remove `conformer-2` from `SpeechModel` union type.
6
+ - Remove conformer-2 deprecation warning
7
+
3
8
  ## [4.6.0]
4
9
 
5
10
  - Add more TSDoc comments for `RealtimeService` documentation
@@ -65,7 +65,7 @@
65
65
  defaultUserAgentString += navigator.userAgent;
66
66
  }
67
67
  const defaultUserAgent = {
68
- sdk: { name: "JavaScript", version: "4.6.0" },
68
+ sdk: { name: "JavaScript", version: "4.6.1" },
69
69
  };
70
70
  if (typeof process !== "undefined") {
71
71
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -529,7 +529,6 @@
529
529
  */
530
530
  transcribe(params, options) {
531
531
  return __awaiter(this, void 0, void 0, function* () {
532
- deprecateConformer2(params);
533
532
  const transcript = yield this.submit(params);
534
533
  return yield this.waitUntilReady(transcript.id, options);
535
534
  });
@@ -541,7 +540,6 @@
541
540
  */
542
541
  submit(params) {
543
542
  return __awaiter(this, void 0, void 0, function* () {
544
- deprecateConformer2(params);
545
543
  let audioUrl;
546
544
  let transcriptParams = undefined;
547
545
  if ("audio" in params) {
@@ -588,7 +586,6 @@
588
586
  create(params, options) {
589
587
  return __awaiter(this, void 0, void 0, function* () {
590
588
  var _a;
591
- deprecateConformer2(params);
592
589
  const path = getPath(params.audio_url);
593
590
  if (path !== null) {
594
591
  const uploadUrl = yield this.files.upload(path);
@@ -764,13 +761,6 @@
764
761
  });
765
762
  }
766
763
  }
767
- function deprecateConformer2(params) {
768
- if (!params)
769
- return;
770
- if (params.speech_model === "conformer-2") {
771
- console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
772
- }
773
- }
774
764
 
775
765
  const readFile = function (
776
766
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -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;const s={cache:"no-store"};let i="";"undefined"!=typeof navigator&&navigator.userAgent&&(i+=navigator.userAgent);const n={sdk:{name:"JavaScript",version:"4.6.0"}};"undefined"!=typeof process&&(process.versions.node&&-1===i.indexOf("Node")&&(n.runtime_env={name:"Node",version:process.versions.node}),process.versions.bun&&-1===i.indexOf("Bun")&&(n.runtime_env={name:"Bun",version:process.versions.bun})),"undefined"!=typeof Deno&&process.versions.bun&&-1===i.indexOf("Deno")&&(n.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||{},i+(!1===t?"":" AssemblyAI/1.0 ("+Object.entries(Object.assign(Object.assign({},n),t)).map((([e,t])=>t?`${e}=${t.name}/${t.version}`:"")).join(" ")+")"))}fetch(e,i){return t(this,void 0,void 0,(function*(){i=Object.assign(Object.assign({},s),i);let t={Authorization:this.params.apiKey,"Content-Type":"application/json"};(null==s?void 0:s.headers)&&(t=Object.assign(Object.assign({},t),s.headers)),(null==i?void 0:i.headers)&&(t=Object.assign(Object.assign({},t),i.headers)),this.userAgent&&(t["User-Agent"]=this.userAgent,"undefined"!=typeof window&&"chrome"in window&&(t["AssemblyAI-Agent"]=this.userAgent)),i.headers=t,e.startsWith("http")||(e=this.params.baseUrl+e);const n=yield fetch(e,i);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,s){return t(this,void 0,void 0,(function*(){return(yield this.fetch(e,s)).json()}))}}class r extends o{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)})}getResponse(e){return this.fetchJson(`/lemur/v3/${e}`)}purgeRequestData(e){return this.fetchJson(`/lemur/v3/${e}`,{method:"DELETE"})}}const{WritableStream:a}="undefined"!=typeof window?window:"undefined"!=typeof global?global:globalThis;var c,d;const l=null!==(d=null!==(c=null!==WebSocket&&void 0!==WebSocket?WebSocket:null===global||void 0===global?void 0:global.WebSocket)&&void 0!==c?c: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 l(e,t):new l(e);var h;!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"}(h||(h={}));const f={[h.BadSampleRate]:"Sample rate must be a positive integer",[h.AuthFailed]:"Not Authorized",[h.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.",[h.NonexistentSessionId]:"Session ID does not exist",[h.SessionExpired]:"Session has expired",[h.ClosedSession]:"Session is closed",[h.RateLimited]:"Rate limited",[h.UniqueSessionViolation]:"Unique session violation",[h.SessionTimeout]:"Session Timeout",[h.AudioTooShort]:"Audio too short",[h.AudioTooLong]:"Audio too long",[h.BadJson]:"Bad JSON",[h.BadSchema]:"Bad schema",[h.TooManyStreams]:"Too many streams",[h.Reconnected]:"Reconnected",[h.ReconnectAttemptsExhausted]:"Reconnect attempts exhausted"};class p extends Error{}const m='{"terminate_session":true}';class v{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()):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 h&&(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,o,r,a,c,d,l,u,h,f,m,v,y;const b=JSON.parse(t.toString());if("error"in b)null===(i=(s=this.listeners).error)||void 0===i||i.call(s,new p(b.error));else switch(b.message_type){case"SessionBegins":{const t={sessionId:b.session_id,expiresAt:new Date(b.expires_at)};e(t),null===(o=(n=this.listeners).open)||void 0===o||o.call(n,t);break}case"PartialTranscript":b.created=new Date(b.created),null===(a=(r=this.listeners).transcript)||void 0===a||a.call(r,b),null===(d=(c=this.listeners)["transcript.partial"])||void 0===d||d.call(c,b);break;case"FinalTranscript":b.created=new Date(b.created),null===(u=(l=this.listeners).transcript)||void 0===u||u.call(l,b),null===(f=(h=this.listeners)["transcript.final"])||void 0===f||f.call(h,b);break;case"SessionInformation":null===(v=(m=this.listeners).session_information)||void 0===v||v.call(m,b);break;case"SessionTerminated":null===(y=this.sessionTerminatedResolve)||void 0===y||y.call(this)}}}))}sendAudio(e){this.send(e)}stream(){return new a({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 t(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(m),yield e}else this.socket.send(m);(null===(t=this.socket)||void 0===t?void 0:t.removeAllListeners)&&this.socket.removeAllListeners(),this.socket.close()}this.listeners={},this.socket=void 0}))}}class y 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 v(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 b(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,s){return t(this,void 0,void 0,(function*(){g(e);const t=yield this.submit(e);return yield this.waitUntilReady(t.id,s)}))}submit(e){return t(this,void 0,void 0,(function*(){let t,s;if(g(e),"audio"in e){const{audio:i}=e,n=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"]);if("string"==typeof i){const e=b(i);t=null!==e?yield this.files.upload(e):i.startsWith("data:")?yield this.files.upload(i):i}else t=yield this.files.upload(i);s=Object.assign(Object.assign({},n),{audio_url:t})}else s=e;return yield this.fetchJson("/v2/transcript",{method:"POST",body:JSON.stringify(s)})}))}create(e,s){return t(this,void 0,void 0,(function*(){var t;g(e);const i=b(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===(t=null==s?void 0:s.poll)||void 0===t||t?yield this.waitUntilReady(n.id,s):n}))}waitUntilReady(e,s){return t(this,void 0,void 0,(function*(){var t,i;const n=null!==(t=null==s?void 0:s.pollingInterval)&&void 0!==t?t:3e3,o=null!==(i=null==s?void 0:s.pollingTimeout)&&void 0!==i?i:-1,r=Date.now();for(;;){const t=yield this.get(e);if("completed"===t.status||"error"===t.status)return t;if(o>0&&Date.now()-r>o)throw new Error("Polling timeout");yield new Promise((e=>setTimeout(e,n)))}}))}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){return t(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 t(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}}))}}function g(e){e&&"conformer-2"===e.speech_model&&console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.")}class w extends o{upload(e){return t(this,void 0,void 0,(function*(){let s;s="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 o=new Uint8Array(n);for(;n--;)o[n]=i.charCodeAt(n);return new Blob([o],{type:s})}(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 w(e),this.transcripts=new S(e,this.files),this.lemur=new r(e),this.realtime=new y(e)}},e.FileService=w,e.LemurService=r,e.RealtimeService=class extends v{},e.RealtimeServiceFactory=class extends y{},e.RealtimeTranscriber=v,e.RealtimeTranscriberFactory=y,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,s,i){return new(s||(s=Promise))((function(n,o){function r(e){try{d(i.next(e))}catch(e){o(e)}}function a(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,a)}d((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const s={cache:"no-store"};let i="";"undefined"!=typeof navigator&&navigator.userAgent&&(i+=navigator.userAgent);const n={sdk:{name:"JavaScript",version:"4.6.1"}};"undefined"!=typeof process&&(process.versions.node&&-1===i.indexOf("Node")&&(n.runtime_env={name:"Node",version:process.versions.node}),process.versions.bun&&-1===i.indexOf("Bun")&&(n.runtime_env={name:"Bun",version:process.versions.bun})),"undefined"!=typeof Deno&&process.versions.bun&&-1===i.indexOf("Deno")&&(n.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||{},i+(!1===t?"":" AssemblyAI/1.0 ("+Object.entries(Object.assign(Object.assign({},n),t)).map((([e,t])=>t?`${e}=${t.name}/${t.version}`:"")).join(" ")+")"))}fetch(e,i){return t(this,void 0,void 0,(function*(){i=Object.assign(Object.assign({},s),i);let t={Authorization:this.params.apiKey,"Content-Type":"application/json"};(null==s?void 0:s.headers)&&(t=Object.assign(Object.assign({},t),s.headers)),(null==i?void 0:i.headers)&&(t=Object.assign(Object.assign({},t),i.headers)),this.userAgent&&(t["User-Agent"]=this.userAgent,"undefined"!=typeof window&&"chrome"in window&&(t["AssemblyAI-Agent"]=this.userAgent)),i.headers=t,e.startsWith("http")||(e=this.params.baseUrl+e);const n=yield fetch(e,i);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,s){return t(this,void 0,void 0,(function*(){return(yield this.fetch(e,s)).json()}))}}class r extends o{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)})}getResponse(e){return this.fetchJson(`/lemur/v3/${e}`)}purgeRequestData(e){return this.fetchJson(`/lemur/v3/${e}`,{method:"DELETE"})}}const{WritableStream:a}="undefined"!=typeof window?window:"undefined"!=typeof global?global:globalThis;var d,c;const l=null!==(c=null!==(d=null!==WebSocket&&void 0!==WebSocket?WebSocket:null===global||void 0===global?void 0:global.WebSocket)&&void 0!==d?d:null===window||void 0===window?void 0:window.WebSocket)&&void 0!==c?c:null===self||void 0===self?void 0:self.WebSocket,u=(e,t)=>t?new l(e,t):new l(e);var h;!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"}(h||(h={}));const f={[h.BadSampleRate]:"Sample rate must be a positive integer",[h.AuthFailed]:"Not Authorized",[h.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.",[h.NonexistentSessionId]:"Session ID does not exist",[h.SessionExpired]:"Session has expired",[h.ClosedSession]:"Session is closed",[h.RateLimited]:"Rate limited",[h.UniqueSessionViolation]:"Unique session violation",[h.SessionTimeout]:"Session Timeout",[h.AudioTooShort]:"Audio too short",[h.AudioTooLong]:"Audio too long",[h.BadJson]:"Bad JSON",[h.BadSchema]:"Bad schema",[h.TooManyStreams]:"Too many streams",[h.Reconnected]:"Reconnected",[h.ReconnectAttemptsExhausted]:"Reconnect attempts exhausted"};class p extends Error{}const m='{"terminate_session":true}';class v{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()):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 h&&(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,o,r,a,d,c,l,u,h,f,m,v,y;const b=JSON.parse(t.toString());if("error"in b)null===(i=(s=this.listeners).error)||void 0===i||i.call(s,new p(b.error));else switch(b.message_type){case"SessionBegins":{const t={sessionId:b.session_id,expiresAt:new Date(b.expires_at)};e(t),null===(o=(n=this.listeners).open)||void 0===o||o.call(n,t);break}case"PartialTranscript":b.created=new Date(b.created),null===(a=(r=this.listeners).transcript)||void 0===a||a.call(r,b),null===(c=(d=this.listeners)["transcript.partial"])||void 0===c||c.call(d,b);break;case"FinalTranscript":b.created=new Date(b.created),null===(u=(l=this.listeners).transcript)||void 0===u||u.call(l,b),null===(f=(h=this.listeners)["transcript.final"])||void 0===f||f.call(h,b);break;case"SessionInformation":null===(v=(m=this.listeners).session_information)||void 0===v||v.call(m,b);break;case"SessionTerminated":null===(y=this.sessionTerminatedResolve)||void 0===y||y.call(this)}}}))}sendAudio(e){this.send(e)}stream(){return new a({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 t(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(m),yield e}else this.socket.send(m);(null===(t=this.socket)||void 0===t?void 0:t.removeAllListeners)&&this.socket.removeAllListeners(),this.socket.close()}this.listeners={},this.socket=void 0}))}}class y 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 v(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 b(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,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*(){let t,s;if("audio"in e){const{audio:i}=e,n=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"]);if("string"==typeof i){const e=b(i);t=null!==e?yield this.files.upload(e):i.startsWith("data:")?yield this.files.upload(i):i}else t=yield this.files.upload(i);s=Object.assign(Object.assign({},n),{audio_url:t})}else s=e;return yield this.fetchJson("/v2/transcript",{method:"POST",body:JSON.stringify(s)})}))}create(e,s){return t(this,void 0,void 0,(function*(){var t;const i=b(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===(t=null==s?void 0:s.poll)||void 0===t||t?yield this.waitUntilReady(n.id,s):n}))}waitUntilReady(e,s){return t(this,void 0,void 0,(function*(){var t,i;const n=null!==(t=null==s?void 0:s.pollingInterval)&&void 0!==t?t:3e3,o=null!==(i=null==s?void 0:s.pollingTimeout)&&void 0!==i?i:-1,r=Date.now();for(;;){const t=yield this.get(e);if("completed"===t.status||"error"===t.status)return t;if(o>0&&Date.now()-r>o)throw new Error("Polling timeout");yield new Promise((e=>setTimeout(e,n)))}}))}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){return t(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 t(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 g extends o{upload(e){return t(this,void 0,void 0,(function*(){let s;s="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 o=new Uint8Array(n);for(;n--;)o[n]=i.charCodeAt(n);return new Blob([o],{type:s})}(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 g(e),this.transcripts=new S(e,this.files),this.lemur=new r(e),this.realtime=new y(e)}},e.FileService=g,e.LemurService=r,e.RealtimeService=class extends v{},e.RealtimeServiceFactory=class extends y{},e.RealtimeTranscriber=v,e.RealtimeTranscriberFactory=y,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.6.0" },
18
+ sdk: { name: "JavaScript", version: "4.6.1" },
19
19
  };
20
20
  if (typeof process !== "undefined") {
21
21
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -464,7 +464,6 @@ class TranscriptService extends BaseService {
464
464
  * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
465
465
  */
466
466
  async transcribe(params, options) {
467
- deprecateConformer2(params);
468
467
  const transcript = await this.submit(params);
469
468
  return await this.waitUntilReady(transcript.id, options);
470
469
  }
@@ -474,7 +473,6 @@ class TranscriptService extends BaseService {
474
473
  * @returns A promise that resolves to the queued transcript.
475
474
  */
476
475
  async submit(params) {
477
- deprecateConformer2(params);
478
476
  let audioUrl;
479
477
  let transcriptParams = undefined;
480
478
  if ("audio" in params) {
@@ -518,7 +516,6 @@ class TranscriptService extends BaseService {
518
516
  * @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
519
517
  */
520
518
  async create(params, options) {
521
- deprecateConformer2(params);
522
519
  const path = getPath(params.audio_url);
523
520
  if (path !== null) {
524
521
  const uploadUrl = await this.files.upload(path);
@@ -681,13 +678,6 @@ class TranscriptService extends BaseService {
681
678
  };
682
679
  }
683
680
  }
684
- function deprecateConformer2(params) {
685
- if (!params)
686
- return;
687
- if (params.speech_model === "conformer-2") {
688
- console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
689
- }
690
- }
691
681
 
692
682
  const readFile = async function (
693
683
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
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.6.0" },
20
+ sdk: { name: "JavaScript", version: "4.6.1" },
21
21
  };
22
22
  if (typeof process !== "undefined") {
23
23
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -460,7 +460,6 @@ class TranscriptService extends BaseService {
460
460
  * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
461
461
  */
462
462
  async transcribe(params, options) {
463
- deprecateConformer2(params);
464
463
  const transcript = await this.submit(params);
465
464
  return await this.waitUntilReady(transcript.id, options);
466
465
  }
@@ -470,7 +469,6 @@ class TranscriptService extends BaseService {
470
469
  * @returns A promise that resolves to the queued transcript.
471
470
  */
472
471
  async submit(params) {
473
- deprecateConformer2(params);
474
472
  let audioUrl;
475
473
  let transcriptParams = undefined;
476
474
  if ("audio" in params) {
@@ -514,7 +512,6 @@ class TranscriptService extends BaseService {
514
512
  * @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
515
513
  */
516
514
  async create(params, options) {
517
- deprecateConformer2(params);
518
515
  const path = getPath(params.audio_url);
519
516
  if (path !== null) {
520
517
  const uploadUrl = await this.files.upload(path);
@@ -677,13 +674,6 @@ class TranscriptService extends BaseService {
677
674
  };
678
675
  }
679
676
  }
680
- function deprecateConformer2(params) {
681
- if (!params)
682
- return;
683
- if (params.speech_model === "conformer-2") {
684
- console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
685
- }
686
- }
687
677
 
688
678
  const readFile = async (path) => Bun.file(path).stream();
689
679
 
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.6.0" },
20
+ sdk: { name: "JavaScript", version: "4.6.1" },
21
21
  };
22
22
  if (typeof process !== "undefined") {
23
23
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -460,7 +460,6 @@ class TranscriptService extends BaseService {
460
460
  * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
461
461
  */
462
462
  async transcribe(params, options) {
463
- deprecateConformer2(params);
464
463
  const transcript = await this.submit(params);
465
464
  return await this.waitUntilReady(transcript.id, options);
466
465
  }
@@ -470,7 +469,6 @@ class TranscriptService extends BaseService {
470
469
  * @returns A promise that resolves to the queued transcript.
471
470
  */
472
471
  async submit(params) {
473
- deprecateConformer2(params);
474
472
  let audioUrl;
475
473
  let transcriptParams = undefined;
476
474
  if ("audio" in params) {
@@ -514,7 +512,6 @@ class TranscriptService extends BaseService {
514
512
  * @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
515
513
  */
516
514
  async create(params, options) {
517
- deprecateConformer2(params);
518
515
  const path = getPath(params.audio_url);
519
516
  if (path !== null) {
520
517
  const uploadUrl = await this.files.upload(path);
@@ -677,13 +674,6 @@ class TranscriptService extends BaseService {
677
674
  };
678
675
  }
679
676
  }
680
- function deprecateConformer2(params) {
681
- if (!params)
682
- return;
683
- if (params.speech_model === "conformer-2") {
684
- console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
685
- }
686
- }
687
677
 
688
678
  const readFile = async (path) => (await Deno.open(path)).readable;
689
679
 
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.6.0" },
66
+ sdk: { name: "JavaScript", version: "4.6.1" },
67
67
  };
68
68
  if (typeof process !== "undefined") {
69
69
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -520,7 +520,6 @@ class TranscriptService extends BaseService {
520
520
  */
521
521
  transcribe(params, options) {
522
522
  return __awaiter(this, void 0, void 0, function* () {
523
- deprecateConformer2(params);
524
523
  const transcript = yield this.submit(params);
525
524
  return yield this.waitUntilReady(transcript.id, options);
526
525
  });
@@ -532,7 +531,6 @@ class TranscriptService extends BaseService {
532
531
  */
533
532
  submit(params) {
534
533
  return __awaiter(this, void 0, void 0, function* () {
535
- deprecateConformer2(params);
536
534
  let audioUrl;
537
535
  let transcriptParams = undefined;
538
536
  if ("audio" in params) {
@@ -579,7 +577,6 @@ class TranscriptService extends BaseService {
579
577
  create(params, options) {
580
578
  return __awaiter(this, void 0, void 0, function* () {
581
579
  var _a;
582
- deprecateConformer2(params);
583
580
  const path = getPath(params.audio_url);
584
581
  if (path !== null) {
585
582
  const uploadUrl = yield this.files.upload(path);
@@ -755,13 +752,6 @@ class TranscriptService extends BaseService {
755
752
  });
756
753
  }
757
754
  }
758
- function deprecateConformer2(params) {
759
- if (!params)
760
- return;
761
- if (params.speech_model === "conformer-2") {
762
- console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
763
- }
764
- }
765
755
 
766
756
  const readFile = function (
767
757
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
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.6.0" },
64
+ sdk: { name: "JavaScript", version: "4.6.1" },
65
65
  };
66
66
  if (typeof process !== "undefined") {
67
67
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -518,7 +518,6 @@ class TranscriptService extends BaseService {
518
518
  */
519
519
  transcribe(params, options) {
520
520
  return __awaiter(this, void 0, void 0, function* () {
521
- deprecateConformer2(params);
522
521
  const transcript = yield this.submit(params);
523
522
  return yield this.waitUntilReady(transcript.id, options);
524
523
  });
@@ -530,7 +529,6 @@ class TranscriptService extends BaseService {
530
529
  */
531
530
  submit(params) {
532
531
  return __awaiter(this, void 0, void 0, function* () {
533
- deprecateConformer2(params);
534
532
  let audioUrl;
535
533
  let transcriptParams = undefined;
536
534
  if ("audio" in params) {
@@ -577,7 +575,6 @@ class TranscriptService extends BaseService {
577
575
  create(params, options) {
578
576
  return __awaiter(this, void 0, void 0, function* () {
579
577
  var _a;
580
- deprecateConformer2(params);
581
578
  const path = getPath(params.audio_url);
582
579
  if (path !== null) {
583
580
  const uploadUrl = yield this.files.upload(path);
@@ -753,13 +750,6 @@ class TranscriptService extends BaseService {
753
750
  });
754
751
  }
755
752
  }
756
- function deprecateConformer2(params) {
757
- if (!params)
758
- return;
759
- if (params.speech_model === "conformer-2") {
760
- console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
761
- }
762
- }
763
753
 
764
754
  const readFile = function (
765
755
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
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.6.0" },
25
+ sdk: { name: "JavaScript", version: "4.6.1" },
26
26
  };
27
27
  if (typeof process !== "undefined") {
28
28
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -459,7 +459,6 @@ class TranscriptService extends BaseService {
459
459
  * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
460
460
  */
461
461
  async transcribe(params, options) {
462
- deprecateConformer2(params);
463
462
  const transcript = await this.submit(params);
464
463
  return await this.waitUntilReady(transcript.id, options);
465
464
  }
@@ -469,7 +468,6 @@ class TranscriptService extends BaseService {
469
468
  * @returns A promise that resolves to the queued transcript.
470
469
  */
471
470
  async submit(params) {
472
- deprecateConformer2(params);
473
471
  let audioUrl;
474
472
  let transcriptParams = undefined;
475
473
  if ("audio" in params) {
@@ -513,7 +511,6 @@ class TranscriptService extends BaseService {
513
511
  * @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
514
512
  */
515
513
  async create(params, options) {
516
- deprecateConformer2(params);
517
514
  const path = getPath(params.audio_url);
518
515
  if (path !== null) {
519
516
  const uploadUrl = await this.files.upload(path);
@@ -676,13 +673,6 @@ class TranscriptService extends BaseService {
676
673
  };
677
674
  }
678
675
  }
679
- function deprecateConformer2(params) {
680
- if (!params)
681
- return;
682
- if (params.speech_model === "conformer-2") {
683
- console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
684
- }
685
- }
686
676
 
687
677
  const readFile = async (path) => stream.Readable.toWeb(fs.createReadStream(path));
688
678
 
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.6.0" },
23
+ sdk: { name: "JavaScript", version: "4.6.1" },
24
24
  };
25
25
  if (typeof process !== "undefined") {
26
26
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -457,7 +457,6 @@ class TranscriptService extends BaseService {
457
457
  * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
458
458
  */
459
459
  async transcribe(params, options) {
460
- deprecateConformer2(params);
461
460
  const transcript = await this.submit(params);
462
461
  return await this.waitUntilReady(transcript.id, options);
463
462
  }
@@ -467,7 +466,6 @@ class TranscriptService extends BaseService {
467
466
  * @returns A promise that resolves to the queued transcript.
468
467
  */
469
468
  async submit(params) {
470
- deprecateConformer2(params);
471
469
  let audioUrl;
472
470
  let transcriptParams = undefined;
473
471
  if ("audio" in params) {
@@ -511,7 +509,6 @@ class TranscriptService extends BaseService {
511
509
  * @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
512
510
  */
513
511
  async create(params, options) {
514
- deprecateConformer2(params);
515
512
  const path = getPath(params.audio_url);
516
513
  if (path !== null) {
517
514
  const uploadUrl = await this.files.upload(path);
@@ -674,13 +671,6 @@ class TranscriptService extends BaseService {
674
671
  };
675
672
  }
676
673
  }
677
- function deprecateConformer2(params) {
678
- if (!params)
679
- return;
680
- if (params.speech_model === "conformer-2") {
681
- console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
682
- }
683
- }
684
674
 
685
675
  const readFile = async (path) => Readable.toWeb(createReadStream(path));
686
676
 
@@ -529,12 +529,7 @@ export type LemurActionItemsParams = LemurBaseParams & {
529
529
  * }
530
530
  * ```
531
531
  */
532
- export type LemurActionItemsResponse = LemurBaseResponse & {
533
- /**
534
- * The response generated by LeMUR
535
- */
536
- response: string;
537
- };
532
+ export type LemurActionItemsResponse = LemurStringResponse;
538
533
  /**
539
534
  * @example
540
535
  * ```js
@@ -731,7 +726,26 @@ export type LemurQuestionAnswerResponse = LemurBaseResponse & {
731
726
  */
732
727
  response: LemurQuestionAnswer[];
733
728
  };
734
- export type LemurResponse = LemurTaskResponse | LemurSummaryResponse | LemurQuestionAnswerResponse | LemurActionItemsResponse;
729
+ export type LemurResponse = LemurStringResponse | LemurQuestionAnswerResponse;
730
+ /**
731
+ * @example
732
+ * ```js
733
+ * {
734
+ * "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e",
735
+ * "response": "Based on the transcript, the following locations were mentioned as being affected by wildfire smoke from Canada:\n\n- Maine\n- Maryland\n- Minnesota\n- Mid Atlantic region\n- Northeast region\n- New York City\n- Baltimore\n",
736
+ * "usage": {
737
+ * "input_tokens": 27,
738
+ * "output_tokens": 3
739
+ * }
740
+ * }
741
+ * ```
742
+ */
743
+ export type LemurStringResponse = {
744
+ /**
745
+ * The response generated by LeMUR.
746
+ */
747
+ response: string;
748
+ } & LemurBaseResponse;
735
749
  /**
736
750
  * @example
737
751
  * ```js
@@ -765,12 +779,7 @@ export type LemurSummaryParams = LemurBaseParams & {
765
779
  * }
766
780
  * ```
767
781
  */
768
- export type LemurSummaryResponse = LemurBaseResponse & {
769
- /**
770
- * The response generated by LeMUR
771
- */
772
- response: string;
773
- };
782
+ export type LemurSummaryResponse = LemurStringResponse;
774
783
  /**
775
784
  * @example
776
785
  * ```js
@@ -805,12 +814,7 @@ export type LemurTaskParams = {
805
814
  * }
806
815
  * ```
807
816
  */
808
- export type LemurTaskResponse = {
809
- /**
810
- * The response generated by LeMUR.
811
- */
812
- response: string;
813
- } & LemurBaseResponse;
817
+ export type LemurTaskResponse = LemurStringResponse;
814
818
  /**
815
819
  * The usage numbers for the LeMUR request
816
820
  */
@@ -1222,7 +1226,7 @@ export type SeverityScoreSummary = {
1222
1226
  /**
1223
1227
  * The speech model to use for the transcription.
1224
1228
  */
1225
- export type SpeechModel = "best" | "nano" | "conformer-2";
1229
+ export type SpeechModel = "best" | "nano";
1226
1230
  /**
1227
1231
  * The replacement logic for detected PII, can be "entity_name" or "hash". See {@link https://www.assemblyai.com/docs/models/pii-redaction | PII redaction } for more details.
1228
1232
  */
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.6.0" },
18
+ sdk: { name: "JavaScript", version: "4.6.1" },
19
19
  };
20
20
  if (typeof process !== "undefined") {
21
21
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -458,7 +458,6 @@ class TranscriptService extends BaseService {
458
458
  * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
459
459
  */
460
460
  async transcribe(params, options) {
461
- deprecateConformer2(params);
462
461
  const transcript = await this.submit(params);
463
462
  return await this.waitUntilReady(transcript.id, options);
464
463
  }
@@ -468,7 +467,6 @@ class TranscriptService extends BaseService {
468
467
  * @returns A promise that resolves to the queued transcript.
469
468
  */
470
469
  async submit(params) {
471
- deprecateConformer2(params);
472
470
  let audioUrl;
473
471
  let transcriptParams = undefined;
474
472
  if ("audio" in params) {
@@ -512,7 +510,6 @@ class TranscriptService extends BaseService {
512
510
  * @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
513
511
  */
514
512
  async create(params, options) {
515
- deprecateConformer2(params);
516
513
  const path = getPath(params.audio_url);
517
514
  if (path !== null) {
518
515
  const uploadUrl = await this.files.upload(path);
@@ -675,13 +672,6 @@ class TranscriptService extends BaseService {
675
672
  };
676
673
  }
677
674
  }
678
- function deprecateConformer2(params) {
679
- if (!params)
680
- return;
681
- if (params.speech_model === "conformer-2") {
682
- console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
683
- }
684
- }
685
675
 
686
676
  const readFile = async function (
687
677
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assemblyai",
3
- "version": "4.6.0",
3
+ "version": "4.6.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"
@@ -15,7 +15,6 @@ import {
15
15
  TranscribeParams,
16
16
  TranscribeOptions,
17
17
  SubmitParams,
18
- SpeechModel,
19
18
  RedactedAudioFile,
20
19
  } from "../..";
21
20
  import { FileService } from "../files";
@@ -39,7 +38,6 @@ export class TranscriptService extends BaseService {
39
38
  params: TranscribeParams,
40
39
  options?: TranscribeOptions,
41
40
  ): Promise<Transcript> {
42
- deprecateConformer2(params);
43
41
  const transcript = await this.submit(params);
44
42
  return await this.waitUntilReady(transcript.id, options);
45
43
  }
@@ -50,7 +48,6 @@ export class TranscriptService extends BaseService {
50
48
  * @returns A promise that resolves to the queued transcript.
51
49
  */
52
50
  async submit(params: SubmitParams): Promise<Transcript> {
53
- deprecateConformer2(params);
54
51
  let audioUrl;
55
52
  let transcriptParams: TranscriptParams | undefined = undefined;
56
53
  if ("audio" in params) {
@@ -95,7 +92,6 @@ export class TranscriptService extends BaseService {
95
92
  params: TranscriptParams,
96
93
  options?: CreateTranscriptOptions,
97
94
  ): Promise<Transcript> {
98
- deprecateConformer2(params);
99
95
  const path = getPath(params.audio_url);
100
96
  if (path !== null) {
101
97
  const uploadUrl = await this.files.upload(path);
@@ -287,12 +283,3 @@ export class TranscriptService extends BaseService {
287
283
  };
288
284
  }
289
285
  }
290
-
291
- function deprecateConformer2(params: { speech_model?: SpeechModel | null }) {
292
- if (!params) return;
293
- if (params.speech_model === "conformer-2") {
294
- console.warn(
295
- "The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.",
296
- );
297
- }
298
- }
@@ -596,12 +596,7 @@ export type LemurActionItemsParams = LemurBaseParams & {
596
596
  * }
597
597
  * ```
598
598
  */
599
- export type LemurActionItemsResponse = LemurBaseResponse & {
600
- /**
601
- * The response generated by LeMUR
602
- */
603
- response: string;
604
- };
599
+ export type LemurActionItemsResponse = LemurStringResponse;
605
600
 
606
601
  /**
607
602
  * @example
@@ -820,11 +815,27 @@ export type LemurQuestionAnswerResponse = LemurBaseResponse & {
820
815
  response: LemurQuestionAnswer[];
821
816
  };
822
817
 
823
- export type LemurResponse =
824
- | LemurTaskResponse
825
- | LemurSummaryResponse
826
- | LemurQuestionAnswerResponse
827
- | LemurActionItemsResponse;
818
+ export type LemurResponse = LemurStringResponse | LemurQuestionAnswerResponse;
819
+
820
+ /**
821
+ * @example
822
+ * ```js
823
+ * {
824
+ * "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e",
825
+ * "response": "Based on the transcript, the following locations were mentioned as being affected by wildfire smoke from Canada:\n\n- Maine\n- Maryland\n- Minnesota\n- Mid Atlantic region\n- Northeast region\n- New York City\n- Baltimore\n",
826
+ * "usage": {
827
+ * "input_tokens": 27,
828
+ * "output_tokens": 3
829
+ * }
830
+ * }
831
+ * ```
832
+ */
833
+ export type LemurStringResponse = {
834
+ /**
835
+ * The response generated by LeMUR.
836
+ */
837
+ response: string;
838
+ } & LemurBaseResponse;
828
839
 
829
840
  /**
830
841
  * @example
@@ -860,12 +871,7 @@ export type LemurSummaryParams = LemurBaseParams & {
860
871
  * }
861
872
  * ```
862
873
  */
863
- export type LemurSummaryResponse = LemurBaseResponse & {
864
- /**
865
- * The response generated by LeMUR
866
- */
867
- response: string;
868
- };
874
+ export type LemurSummaryResponse = LemurStringResponse;
869
875
 
870
876
  /**
871
877
  * @example
@@ -902,12 +908,7 @@ export type LemurTaskParams = {
902
908
  * }
903
909
  * ```
904
910
  */
905
- export type LemurTaskResponse = {
906
- /**
907
- * The response generated by LeMUR.
908
- */
909
- response: string;
910
- } & LemurBaseResponse;
911
+ export type LemurTaskResponse = LemurStringResponse;
911
912
 
912
913
  /**
913
914
  * The usage numbers for the LeMUR request
@@ -1379,7 +1380,7 @@ export type SeverityScoreSummary = {
1379
1380
  /**
1380
1381
  * The speech model to use for the transcription.
1381
1382
  */
1382
- export type SpeechModel = "best" | "nano" | "conformer-2";
1383
+ export type SpeechModel = "best" | "nano";
1383
1384
 
1384
1385
  /**
1385
1386
  * The replacement logic for detected PII, can be "entity_name" or "hash". See {@link https://www.assemblyai.com/docs/models/pii-redaction | PII redaction } for more details.