assemblyai 4.3.3 → 4.4.0

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,39 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.4.0] - 2024-04-12
4
+
5
+ ### Added
6
+
7
+ - Add `disablePartialTranscripts` parameter to `CreateRealtimeTranscriberParams`
8
+ - Add `enableExtraSessionInformation` parameter to `CreateRealtimeTranscriberParams`
9
+ - Add `session_information` event to `RealtimeTranscriber.on()`
10
+
11
+ ### Updated
12
+
13
+ - ⚠️ Deprecate `conformer-2` literal for `TranscriptParams.speech_model` property
14
+
15
+ ### Fixed
16
+
17
+ - Add missing `status` property to `AutoHighlightsResult`
18
+
19
+ ## [4.3.4] - 2024-04-02
20
+
21
+ ### Added
22
+
23
+ - `SpeechModel.Best` enum
24
+ - `TranscriptListItem.error` property
25
+
26
+ ### Updated
27
+
28
+ - Make `PageDetails.prev_url` nullable
29
+ - Rename Realtime to Streaming inside code documentation
30
+ - More inline code documentation
31
+
32
+ ### Fixed
33
+
34
+ - Rename `SubstitutionPolicy` literal "entity_type" to "entity_name"
35
+ - Fix the pagination example in "List transcripts" sample on README
36
+
3
37
  ## [4.3.3] - 2024-03-18
4
38
 
5
39
  ### Added
package/README.md CHANGED
@@ -185,13 +185,18 @@ const page = await client.transcripts.list();
185
185
  You can also paginate over all pages.
186
186
 
187
187
  ```typescript
188
- let nextPageUrl: string | null = null;
188
+ let previousPageUrl: string | null = null;
189
189
  do {
190
- const page = await client.transcripts.list(nextPageUrl);
191
- nextPageUrl = page.page_details.next_url;
192
- } while (nextPageUrl !== null);
190
+ const page = await client.transcripts.list(previousPageUrl);
191
+ previousPageUrl = page.page_details.prev_url;
192
+ } while (previousPageUrl !== null);
193
193
  ```
194
194
 
195
+ > [!NOTE]
196
+ > To paginate over all pages, you need to use the `page.page_details.prev_url`
197
+ > because the transcripts are returned in descending order by creation date and time.
198
+ > The first page is are the most recent transcript, and each "previous" page are older transcripts.
199
+
195
200
  </details>
196
201
 
197
202
  <details>
@@ -241,9 +246,9 @@ You can configure the following events.
241
246
  ```typescript
242
247
  rt.on("open", ({ sessionId, expiresAt }) => console.log('Session ID:', sessionId, 'Expires at:', expiresAt));
243
248
  rt.on("close", (code: number, reason: string) => console.log('Closed', code, reason));
244
- rt.on("transcript", (transcript: RealtimeTranscript) => console.log('Transcript:', transcript));
245
- rt.on("transcript.partial", (transcript: PartialTranscript) => console.log('Partial transcript:', transcript));
246
- rt.on("transcript.final", (transcript: FinalTranscript) => console.log('Final transcript:', transcript));
249
+ rt.on("transcript", (transcript: TranscriptMessage) => console.log('Transcript:', transcript));
250
+ rt.on("transcript.partial", (transcript: PartialTranscriptMessage) => console.log('Partial transcript:', transcript));
251
+ rt.on("transcript.final", (transcript: FinalTranscriptMessage) => console.log('Final transcript:', transcript));
247
252
  rt.on("error", (error: Error) => console.error('Error', error));
248
253
  ```
249
254
 
@@ -206,6 +206,8 @@
206
206
  this.wordBoost = params.wordBoost;
207
207
  this.encoding = params.encoding;
208
208
  this.endUtteranceSilenceThreshold = params.endUtteranceSilenceThreshold;
209
+ this.enableExtraSessionInformation = params.enableExtraSessionInformation;
210
+ this.disablePartialTranscripts = params.disablePartialTranscripts;
209
211
  if ("token" in params && params.token)
210
212
  this.token = params.token;
211
213
  if ("apiKey" in params && params.apiKey)
@@ -230,6 +232,12 @@
230
232
  if (this.encoding) {
231
233
  searchParams.set("encoding", this.encoding);
232
234
  }
235
+ if (this.enableExtraSessionInformation) {
236
+ searchParams.set("enable_extra_session_information", this.enableExtraSessionInformation.toString());
237
+ }
238
+ if (this.disablePartialTranscripts) {
239
+ searchParams.set("disable_partial_transcripts", this.disablePartialTranscripts.toString());
240
+ }
233
241
  url.search = searchParams.toString();
234
242
  return url;
235
243
  }
@@ -276,7 +284,7 @@
276
284
  (_d = (_c = this.listeners).error) === null || _d === void 0 ? void 0 : _d.call(_c, new Error(event.message));
277
285
  };
278
286
  this.socket.onmessage = ({ data }) => {
279
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
287
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
280
288
  const message = JSON.parse(data.toString());
281
289
  if ("error" in message) {
282
290
  (_b = (_a = this.listeners).error) === null || _b === void 0 ? void 0 : _b.call(_a, new RealtimeError(message.error));
@@ -306,8 +314,12 @@
306
314
  (_m = (_l = this.listeners)["transcript.final"]) === null || _m === void 0 ? void 0 : _m.call(_l, message);
307
315
  break;
308
316
  }
317
+ case "SessionInformation": {
318
+ (_p = (_o = this.listeners).session_information) === null || _p === void 0 ? void 0 : _p.call(_o, message);
319
+ break;
320
+ }
309
321
  case "SessionTerminated": {
310
- (_o = this.sessionTerminatedResolve) === null || _o === void 0 ? void 0 : _o.call(this);
322
+ (_q = this.sessionTerminatedResolve) === null || _q === void 0 ? void 0 : _q.call(this);
311
323
  break;
312
324
  }
313
325
  }
@@ -433,6 +445,7 @@
433
445
  */
434
446
  transcribe(params, options) {
435
447
  return __awaiter(this, void 0, void 0, function* () {
448
+ deprecateConformer2(params);
436
449
  const transcript = yield this.submit(params);
437
450
  return yield this.waitUntilReady(transcript.id, options);
438
451
  });
@@ -444,6 +457,7 @@
444
457
  */
445
458
  submit(params) {
446
459
  return __awaiter(this, void 0, void 0, function* () {
460
+ deprecateConformer2(params);
447
461
  let audioUrl;
448
462
  let transcriptParams = undefined;
449
463
  if ("audio" in params) {
@@ -485,6 +499,7 @@
485
499
  create(params, options) {
486
500
  return __awaiter(this, void 0, void 0, function* () {
487
501
  var _a;
502
+ deprecateConformer2(params);
488
503
  const path = getPath(params.audio_url);
489
504
  if (path !== null) {
490
505
  const uploadUrl = yield this.files.upload(path);
@@ -628,6 +643,13 @@
628
643
  return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
629
644
  }
630
645
  }
646
+ function deprecateConformer2(params) {
647
+ if (!params)
648
+ return;
649
+ if (params.speech_model === "conformer-2") {
650
+ console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
651
+ }
652
+ }
631
653
 
632
654
  const readFile = function (
633
655
  // 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;class s{constructor(e){this.params=e}fetch(e,s){return t(this,void 0,void 0,(function*(){var t;(s=null!=s?s:{}).headers=null!==(t=s.headers)&&void 0!==t?t:{},s.headers=Object.assign({Authorization:this.params.apiKey,"Content-Type":"application/json"},s.headers),e.startsWith("http")||(e=this.params.baseUrl+e);const i=yield fetch(e,s);if(i.status>=400){let e;const t=yield i.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: ${i.status} ${i.statusText}`)}return i}))}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(){return t(this,arguments,void 0,(function*(e=!0){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*(){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=f(i);t=null!==e?yield this.files.upload(e):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=f(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.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){return t(this,void 0,void 0,(function*(){var t;(s=null!=s?s:{}).headers=null!==(t=s.headers)&&void 0!==t?t:{},s.headers=Object.assign({Authorization:this.params.apiKey,"Content-Type":"application/json"},s.headers),e.startsWith("http")||(e=this.params.baseUrl+e);const i=yield fetch(e,s);if(i.status>=400){let e;const t=yield i.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: ${i.status} ${i.statusText}`)}return i}))}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,this.enableExtraSessionInformation=e.enableExtraSessionInformation,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),this.enableExtraSessionInformation&&t.set("enable_extra_session_information",this.enableExtraSessionInformation.toString()),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=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,y,S;const v=JSON.parse(t.toString());if("error"in v)null===(i=(s=this.listeners).error)||void 0===i||i.call(s,new l(v.error));else switch(v.message_type){case"SessionBegins":{const t={sessionId:v.session_id,expiresAt:new Date(v.expires_at)};e(t),null===(o=(n=this.listeners).open)||void 0===o||o.call(n,t);break}case"PartialTranscript":v.created=new Date(v.created),null===(a=(r=this.listeners).transcript)||void 0===a||a.call(r,v),null===(d=(c=this.listeners)["transcript.partial"])||void 0===d||d.call(c,v);break;case"FinalTranscript":v.created=new Date(v.created),null===(u=(h=this.listeners).transcript)||void 0===u||u.call(h,v),null===(p=(f=this.listeners)["transcript.final"])||void 0===p||p.call(f,v);break;case"SessionInformation":null===(y=(m=this.listeners).session_information)||void 0===y||y.call(m,v);break;case"SessionTerminated":null===(S=this.sessionTerminatedResolve)||void 0===S||S.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(){return t(this,arguments,void 0,(function*(e=!0){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*(){m(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(m(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=f(i);t=null!==e?yield this.files.upload(e):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;m(e);const i=f(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.fetchJson(`/v2/transcript/${e}/redacted-audio`)}}function m(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 y 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 y(e),this.transcripts=new p(e,this.files),this.lemur=new i(e),this.realtime=new u(e)}},e.FileService=y,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
@@ -140,6 +140,8 @@ class RealtimeTranscriber {
140
140
  this.wordBoost = params.wordBoost;
141
141
  this.encoding = params.encoding;
142
142
  this.endUtteranceSilenceThreshold = params.endUtteranceSilenceThreshold;
143
+ this.enableExtraSessionInformation = params.enableExtraSessionInformation;
144
+ this.disablePartialTranscripts = params.disablePartialTranscripts;
143
145
  if ("token" in params && params.token)
144
146
  this.token = params.token;
145
147
  if ("apiKey" in params && params.apiKey)
@@ -164,6 +166,12 @@ class RealtimeTranscriber {
164
166
  if (this.encoding) {
165
167
  searchParams.set("encoding", this.encoding);
166
168
  }
169
+ if (this.enableExtraSessionInformation) {
170
+ searchParams.set("enable_extra_session_information", this.enableExtraSessionInformation.toString());
171
+ }
172
+ if (this.disablePartialTranscripts) {
173
+ searchParams.set("disable_partial_transcripts", this.disablePartialTranscripts.toString());
174
+ }
167
175
  url.search = searchParams.toString();
168
176
  return url;
169
177
  }
@@ -237,6 +245,10 @@ class RealtimeTranscriber {
237
245
  this.listeners["transcript.final"]?.(message);
238
246
  break;
239
247
  }
248
+ case "SessionInformation": {
249
+ this.listeners.session_information?.(message);
250
+ break;
251
+ }
240
252
  case "SessionTerminated": {
241
253
  this.sessionTerminatedResolve?.();
242
254
  break;
@@ -359,6 +371,7 @@ class TranscriptService extends BaseService {
359
371
  * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
360
372
  */
361
373
  async transcribe(params, options) {
374
+ deprecateConformer2(params);
362
375
  const transcript = await this.submit(params);
363
376
  return await this.waitUntilReady(transcript.id, options);
364
377
  }
@@ -368,6 +381,7 @@ class TranscriptService extends BaseService {
368
381
  * @returns A promise that resolves to the queued transcript.
369
382
  */
370
383
  async submit(params) {
384
+ deprecateConformer2(params);
371
385
  let audioUrl;
372
386
  let transcriptParams = undefined;
373
387
  if ("audio" in params) {
@@ -406,6 +420,7 @@ class TranscriptService extends BaseService {
406
420
  * @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
407
421
  */
408
422
  async create(params, options) {
423
+ deprecateConformer2(params);
409
424
  const path = getPath(params.audio_url);
410
425
  if (path !== null) {
411
426
  const uploadUrl = await this.files.upload(path);
@@ -538,6 +553,13 @@ class TranscriptService extends BaseService {
538
553
  return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
539
554
  }
540
555
  }
556
+ function deprecateConformer2(params) {
557
+ if (!params)
558
+ return;
559
+ if (params.speech_model === "conformer-2") {
560
+ console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
561
+ }
562
+ }
541
563
 
542
564
  const readFile = async (path) => Bun.file(path).stream();
543
565
 
package/dist/deno.mjs CHANGED
@@ -140,6 +140,8 @@ class RealtimeTranscriber {
140
140
  this.wordBoost = params.wordBoost;
141
141
  this.encoding = params.encoding;
142
142
  this.endUtteranceSilenceThreshold = params.endUtteranceSilenceThreshold;
143
+ this.enableExtraSessionInformation = params.enableExtraSessionInformation;
144
+ this.disablePartialTranscripts = params.disablePartialTranscripts;
143
145
  if ("token" in params && params.token)
144
146
  this.token = params.token;
145
147
  if ("apiKey" in params && params.apiKey)
@@ -164,6 +166,12 @@ class RealtimeTranscriber {
164
166
  if (this.encoding) {
165
167
  searchParams.set("encoding", this.encoding);
166
168
  }
169
+ if (this.enableExtraSessionInformation) {
170
+ searchParams.set("enable_extra_session_information", this.enableExtraSessionInformation.toString());
171
+ }
172
+ if (this.disablePartialTranscripts) {
173
+ searchParams.set("disable_partial_transcripts", this.disablePartialTranscripts.toString());
174
+ }
167
175
  url.search = searchParams.toString();
168
176
  return url;
169
177
  }
@@ -237,6 +245,10 @@ class RealtimeTranscriber {
237
245
  this.listeners["transcript.final"]?.(message);
238
246
  break;
239
247
  }
248
+ case "SessionInformation": {
249
+ this.listeners.session_information?.(message);
250
+ break;
251
+ }
240
252
  case "SessionTerminated": {
241
253
  this.sessionTerminatedResolve?.();
242
254
  break;
@@ -359,6 +371,7 @@ class TranscriptService extends BaseService {
359
371
  * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
360
372
  */
361
373
  async transcribe(params, options) {
374
+ deprecateConformer2(params);
362
375
  const transcript = await this.submit(params);
363
376
  return await this.waitUntilReady(transcript.id, options);
364
377
  }
@@ -368,6 +381,7 @@ class TranscriptService extends BaseService {
368
381
  * @returns A promise that resolves to the queued transcript.
369
382
  */
370
383
  async submit(params) {
384
+ deprecateConformer2(params);
371
385
  let audioUrl;
372
386
  let transcriptParams = undefined;
373
387
  if ("audio" in params) {
@@ -406,6 +420,7 @@ class TranscriptService extends BaseService {
406
420
  * @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
407
421
  */
408
422
  async create(params, options) {
423
+ deprecateConformer2(params);
409
424
  const path = getPath(params.audio_url);
410
425
  if (path !== null) {
411
426
  const uploadUrl = await this.files.upload(path);
@@ -538,6 +553,13 @@ class TranscriptService extends BaseService {
538
553
  return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
539
554
  }
540
555
  }
556
+ function deprecateConformer2(params) {
557
+ if (!params)
558
+ return;
559
+ if (params.speech_model === "conformer-2") {
560
+ console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
561
+ }
562
+ }
541
563
 
542
564
  const readFile = async (path) => (await Deno.open(path)).readable;
543
565
 
package/dist/index.cjs CHANGED
@@ -188,6 +188,8 @@ class RealtimeTranscriber {
188
188
  this.wordBoost = params.wordBoost;
189
189
  this.encoding = params.encoding;
190
190
  this.endUtteranceSilenceThreshold = params.endUtteranceSilenceThreshold;
191
+ this.enableExtraSessionInformation = params.enableExtraSessionInformation;
192
+ this.disablePartialTranscripts = params.disablePartialTranscripts;
191
193
  if ("token" in params && params.token)
192
194
  this.token = params.token;
193
195
  if ("apiKey" in params && params.apiKey)
@@ -212,6 +214,12 @@ class RealtimeTranscriber {
212
214
  if (this.encoding) {
213
215
  searchParams.set("encoding", this.encoding);
214
216
  }
217
+ if (this.enableExtraSessionInformation) {
218
+ searchParams.set("enable_extra_session_information", this.enableExtraSessionInformation.toString());
219
+ }
220
+ if (this.disablePartialTranscripts) {
221
+ searchParams.set("disable_partial_transcripts", this.disablePartialTranscripts.toString());
222
+ }
215
223
  url.search = searchParams.toString();
216
224
  return url;
217
225
  }
@@ -258,7 +266,7 @@ class RealtimeTranscriber {
258
266
  (_d = (_c = this.listeners).error) === null || _d === void 0 ? void 0 : _d.call(_c, new Error(event.message));
259
267
  };
260
268
  this.socket.onmessage = ({ data }) => {
261
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
269
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
262
270
  const message = JSON.parse(data.toString());
263
271
  if ("error" in message) {
264
272
  (_b = (_a = this.listeners).error) === null || _b === void 0 ? void 0 : _b.call(_a, new RealtimeError(message.error));
@@ -288,8 +296,12 @@ class RealtimeTranscriber {
288
296
  (_m = (_l = this.listeners)["transcript.final"]) === null || _m === void 0 ? void 0 : _m.call(_l, message);
289
297
  break;
290
298
  }
299
+ case "SessionInformation": {
300
+ (_p = (_o = this.listeners).session_information) === null || _p === void 0 ? void 0 : _p.call(_o, message);
301
+ break;
302
+ }
291
303
  case "SessionTerminated": {
292
- (_o = this.sessionTerminatedResolve) === null || _o === void 0 ? void 0 : _o.call(this);
304
+ (_q = this.sessionTerminatedResolve) === null || _q === void 0 ? void 0 : _q.call(this);
293
305
  break;
294
306
  }
295
307
  }
@@ -415,6 +427,7 @@ class TranscriptService extends BaseService {
415
427
  */
416
428
  transcribe(params, options) {
417
429
  return __awaiter(this, void 0, void 0, function* () {
430
+ deprecateConformer2(params);
418
431
  const transcript = yield this.submit(params);
419
432
  return yield this.waitUntilReady(transcript.id, options);
420
433
  });
@@ -426,6 +439,7 @@ class TranscriptService extends BaseService {
426
439
  */
427
440
  submit(params) {
428
441
  return __awaiter(this, void 0, void 0, function* () {
442
+ deprecateConformer2(params);
429
443
  let audioUrl;
430
444
  let transcriptParams = undefined;
431
445
  if ("audio" in params) {
@@ -467,6 +481,7 @@ class TranscriptService extends BaseService {
467
481
  create(params, options) {
468
482
  return __awaiter(this, void 0, void 0, function* () {
469
483
  var _a;
484
+ deprecateConformer2(params);
470
485
  const path = getPath(params.audio_url);
471
486
  if (path !== null) {
472
487
  const uploadUrl = yield this.files.upload(path);
@@ -610,6 +625,13 @@ class TranscriptService extends BaseService {
610
625
  return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
611
626
  }
612
627
  }
628
+ function deprecateConformer2(params) {
629
+ if (!params)
630
+ return;
631
+ if (params.speech_model === "conformer-2") {
632
+ console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
633
+ }
634
+ }
613
635
 
614
636
  const readFile = function (
615
637
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
package/dist/index.mjs CHANGED
@@ -186,6 +186,8 @@ class RealtimeTranscriber {
186
186
  this.wordBoost = params.wordBoost;
187
187
  this.encoding = params.encoding;
188
188
  this.endUtteranceSilenceThreshold = params.endUtteranceSilenceThreshold;
189
+ this.enableExtraSessionInformation = params.enableExtraSessionInformation;
190
+ this.disablePartialTranscripts = params.disablePartialTranscripts;
189
191
  if ("token" in params && params.token)
190
192
  this.token = params.token;
191
193
  if ("apiKey" in params && params.apiKey)
@@ -210,6 +212,12 @@ class RealtimeTranscriber {
210
212
  if (this.encoding) {
211
213
  searchParams.set("encoding", this.encoding);
212
214
  }
215
+ if (this.enableExtraSessionInformation) {
216
+ searchParams.set("enable_extra_session_information", this.enableExtraSessionInformation.toString());
217
+ }
218
+ if (this.disablePartialTranscripts) {
219
+ searchParams.set("disable_partial_transcripts", this.disablePartialTranscripts.toString());
220
+ }
213
221
  url.search = searchParams.toString();
214
222
  return url;
215
223
  }
@@ -256,7 +264,7 @@ class RealtimeTranscriber {
256
264
  (_d = (_c = this.listeners).error) === null || _d === void 0 ? void 0 : _d.call(_c, new Error(event.message));
257
265
  };
258
266
  this.socket.onmessage = ({ data }) => {
259
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
267
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
260
268
  const message = JSON.parse(data.toString());
261
269
  if ("error" in message) {
262
270
  (_b = (_a = this.listeners).error) === null || _b === void 0 ? void 0 : _b.call(_a, new RealtimeError(message.error));
@@ -286,8 +294,12 @@ class RealtimeTranscriber {
286
294
  (_m = (_l = this.listeners)["transcript.final"]) === null || _m === void 0 ? void 0 : _m.call(_l, message);
287
295
  break;
288
296
  }
297
+ case "SessionInformation": {
298
+ (_p = (_o = this.listeners).session_information) === null || _p === void 0 ? void 0 : _p.call(_o, message);
299
+ break;
300
+ }
289
301
  case "SessionTerminated": {
290
- (_o = this.sessionTerminatedResolve) === null || _o === void 0 ? void 0 : _o.call(this);
302
+ (_q = this.sessionTerminatedResolve) === null || _q === void 0 ? void 0 : _q.call(this);
291
303
  break;
292
304
  }
293
305
  }
@@ -413,6 +425,7 @@ class TranscriptService extends BaseService {
413
425
  */
414
426
  transcribe(params, options) {
415
427
  return __awaiter(this, void 0, void 0, function* () {
428
+ deprecateConformer2(params);
416
429
  const transcript = yield this.submit(params);
417
430
  return yield this.waitUntilReady(transcript.id, options);
418
431
  });
@@ -424,6 +437,7 @@ class TranscriptService extends BaseService {
424
437
  */
425
438
  submit(params) {
426
439
  return __awaiter(this, void 0, void 0, function* () {
440
+ deprecateConformer2(params);
427
441
  let audioUrl;
428
442
  let transcriptParams = undefined;
429
443
  if ("audio" in params) {
@@ -465,6 +479,7 @@ class TranscriptService extends BaseService {
465
479
  create(params, options) {
466
480
  return __awaiter(this, void 0, void 0, function* () {
467
481
  var _a;
482
+ deprecateConformer2(params);
468
483
  const path = getPath(params.audio_url);
469
484
  if (path !== null) {
470
485
  const uploadUrl = yield this.files.upload(path);
@@ -608,6 +623,13 @@ class TranscriptService extends BaseService {
608
623
  return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
609
624
  }
610
625
  }
626
+ function deprecateConformer2(params) {
627
+ if (!params)
628
+ return;
629
+ if (params.speech_model === "conformer-2") {
630
+ console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
631
+ }
632
+ }
611
633
 
612
634
  const readFile = function (
613
635
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
package/dist/node.cjs CHANGED
@@ -139,6 +139,8 @@ class RealtimeTranscriber {
139
139
  this.wordBoost = params.wordBoost;
140
140
  this.encoding = params.encoding;
141
141
  this.endUtteranceSilenceThreshold = params.endUtteranceSilenceThreshold;
142
+ this.enableExtraSessionInformation = params.enableExtraSessionInformation;
143
+ this.disablePartialTranscripts = params.disablePartialTranscripts;
142
144
  if ("token" in params && params.token)
143
145
  this.token = params.token;
144
146
  if ("apiKey" in params && params.apiKey)
@@ -163,6 +165,12 @@ class RealtimeTranscriber {
163
165
  if (this.encoding) {
164
166
  searchParams.set("encoding", this.encoding);
165
167
  }
168
+ if (this.enableExtraSessionInformation) {
169
+ searchParams.set("enable_extra_session_information", this.enableExtraSessionInformation.toString());
170
+ }
171
+ if (this.disablePartialTranscripts) {
172
+ searchParams.set("disable_partial_transcripts", this.disablePartialTranscripts.toString());
173
+ }
166
174
  url.search = searchParams.toString();
167
175
  return url;
168
176
  }
@@ -236,6 +244,10 @@ class RealtimeTranscriber {
236
244
  this.listeners["transcript.final"]?.(message);
237
245
  break;
238
246
  }
247
+ case "SessionInformation": {
248
+ this.listeners.session_information?.(message);
249
+ break;
250
+ }
239
251
  case "SessionTerminated": {
240
252
  this.sessionTerminatedResolve?.();
241
253
  break;
@@ -358,6 +370,7 @@ class TranscriptService extends BaseService {
358
370
  * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
359
371
  */
360
372
  async transcribe(params, options) {
373
+ deprecateConformer2(params);
361
374
  const transcript = await this.submit(params);
362
375
  return await this.waitUntilReady(transcript.id, options);
363
376
  }
@@ -367,6 +380,7 @@ class TranscriptService extends BaseService {
367
380
  * @returns A promise that resolves to the queued transcript.
368
381
  */
369
382
  async submit(params) {
383
+ deprecateConformer2(params);
370
384
  let audioUrl;
371
385
  let transcriptParams = undefined;
372
386
  if ("audio" in params) {
@@ -405,6 +419,7 @@ class TranscriptService extends BaseService {
405
419
  * @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
406
420
  */
407
421
  async create(params, options) {
422
+ deprecateConformer2(params);
408
423
  const path = getPath(params.audio_url);
409
424
  if (path !== null) {
410
425
  const uploadUrl = await this.files.upload(path);
@@ -537,6 +552,13 @@ class TranscriptService extends BaseService {
537
552
  return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
538
553
  }
539
554
  }
555
+ function deprecateConformer2(params) {
556
+ if (!params)
557
+ return;
558
+ if (params.speech_model === "conformer-2") {
559
+ console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
560
+ }
561
+ }
540
562
 
541
563
  const readFile = async (path) => stream.Readable.toWeb(fs.createReadStream(path));
542
564
 
package/dist/node.mjs CHANGED
@@ -137,6 +137,8 @@ class RealtimeTranscriber {
137
137
  this.wordBoost = params.wordBoost;
138
138
  this.encoding = params.encoding;
139
139
  this.endUtteranceSilenceThreshold = params.endUtteranceSilenceThreshold;
140
+ this.enableExtraSessionInformation = params.enableExtraSessionInformation;
141
+ this.disablePartialTranscripts = params.disablePartialTranscripts;
140
142
  if ("token" in params && params.token)
141
143
  this.token = params.token;
142
144
  if ("apiKey" in params && params.apiKey)
@@ -161,6 +163,12 @@ class RealtimeTranscriber {
161
163
  if (this.encoding) {
162
164
  searchParams.set("encoding", this.encoding);
163
165
  }
166
+ if (this.enableExtraSessionInformation) {
167
+ searchParams.set("enable_extra_session_information", this.enableExtraSessionInformation.toString());
168
+ }
169
+ if (this.disablePartialTranscripts) {
170
+ searchParams.set("disable_partial_transcripts", this.disablePartialTranscripts.toString());
171
+ }
164
172
  url.search = searchParams.toString();
165
173
  return url;
166
174
  }
@@ -234,6 +242,10 @@ class RealtimeTranscriber {
234
242
  this.listeners["transcript.final"]?.(message);
235
243
  break;
236
244
  }
245
+ case "SessionInformation": {
246
+ this.listeners.session_information?.(message);
247
+ break;
248
+ }
237
249
  case "SessionTerminated": {
238
250
  this.sessionTerminatedResolve?.();
239
251
  break;
@@ -356,6 +368,7 @@ class TranscriptService extends BaseService {
356
368
  * @returns A promise that resolves to the transcript. The transcript status is "completed" or "error".
357
369
  */
358
370
  async transcribe(params, options) {
371
+ deprecateConformer2(params);
359
372
  const transcript = await this.submit(params);
360
373
  return await this.waitUntilReady(transcript.id, options);
361
374
  }
@@ -365,6 +378,7 @@ class TranscriptService extends BaseService {
365
378
  * @returns A promise that resolves to the queued transcript.
366
379
  */
367
380
  async submit(params) {
381
+ deprecateConformer2(params);
368
382
  let audioUrl;
369
383
  let transcriptParams = undefined;
370
384
  if ("audio" in params) {
@@ -403,6 +417,7 @@ class TranscriptService extends BaseService {
403
417
  * @deprecated Use `transcribe` instead to transcribe a audio file that includes polling, or `submit` to transcribe a audio file without polling.
404
418
  */
405
419
  async create(params, options) {
420
+ deprecateConformer2(params);
406
421
  const path = getPath(params.audio_url);
407
422
  if (path !== null) {
408
423
  const uploadUrl = await this.files.upload(path);
@@ -535,6 +550,13 @@ class TranscriptService extends BaseService {
535
550
  return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
536
551
  }
537
552
  }
553
+ function deprecateConformer2(params) {
554
+ if (!params)
555
+ return;
556
+ if (params.speech_model === "conformer-2") {
557
+ console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.");
558
+ }
559
+ }
538
560
 
539
561
  const readFile = async (path) => Readable.toWeb(createReadStream(path));
540
562