assemblyai 4.3.4 → 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,21 @@
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
+
3
19
  ## [4.3.4] - 2024-04-02
4
20
 
5
21
  ### Added
package/README.md CHANGED
@@ -19,6 +19,7 @@ It is written primarily for Node.js in TypeScript with all types exported, but a
19
19
  ## Documentation
20
20
 
21
21
  Visit the [AssemblyAI documentation](https://www.assemblyai.com/docs) for step-by-step instructions and a lot more details about our AI models and API.
22
+ Explore the [SDK API reference](https://assemblyai.github.io/assemblyai-node-sdk/) for more details on the SDK types, functions, and classes.
22
23
 
23
24
  ## Quickstart
24
25
 
@@ -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
 
@@ -1,4 +1,4 @@
1
- import { RealtimeTranscriberParams, RealtimeTranscript, PartialTranscript, FinalTranscript, SessionBeginsEventData, AudioData } from "../..";
1
+ import { RealtimeTranscriberParams, RealtimeTranscript, PartialTranscript, FinalTranscript, SessionBeginsEventData, AudioData, SessionInformation } from "../..";
2
2
  export declare class RealtimeTranscriber {
3
3
  private realtimeUrl;
4
4
  private sampleRate;
@@ -7,6 +7,8 @@ export declare class RealtimeTranscriber {
7
7
  private apiKey?;
8
8
  private token?;
9
9
  private endUtteranceSilenceThreshold?;
10
+ private enableExtraSessionInformation?;
11
+ private disablePartialTranscripts?;
10
12
  private socket?;
11
13
  private listeners;
12
14
  private sessionTerminatedResolve?;
@@ -16,6 +18,7 @@ export declare class RealtimeTranscriber {
16
18
  on(event: "transcript", listener: (transcript: RealtimeTranscript) => void): void;
17
19
  on(event: "transcript.partial", listener: (transcript: PartialTranscript) => void): void;
18
20
  on(event: "transcript.final", listener: (transcript: FinalTranscript) => void): void;
21
+ on(event: "session_information", listener: (info: SessionInformation) => void): void;
19
22
  on(event: "error", listener: (error: Error) => void): void;
20
23
  on(event: "close", listener: (code: number, reason: string) => void): void;
21
24
  connect(): Promise<SessionBeginsEventData>;
@@ -16,6 +16,9 @@ export type ConfigureEndUtteranceSilenceThreshold = {
16
16
  */
17
17
  end_utterance_silence_threshold: number;
18
18
  };
19
+ /**
20
+ * Transcript text at the end of an utterance with punctuation and casing.
21
+ */
19
22
  export type FinalTranscript = RealtimeBaseTranscript & {
20
23
  /**
21
24
  * Describes the type of message
@@ -39,7 +42,10 @@ export type ForceEndUtterance = {
39
42
  */
40
43
  force_end_utterance: boolean;
41
44
  };
42
- export type MessageType = "SessionBegins" | "PartialTranscript" | "FinalTranscript" | "SessionTerminated";
45
+ export type MessageType = "SessionBegins" | "PartialTranscript" | "FinalTranscript" | "SessionInformation" | "SessionTerminated";
46
+ /**
47
+ * As you send audio data to the API, the API immediately starts responding with Partial Transcript results.
48
+ */
43
49
  export type PartialTranscript = RealtimeBaseTranscript & {
44
50
  /**
45
51
  * Describes the type of message
@@ -79,12 +85,18 @@ export type RealtimeBaseTranscript = {
79
85
  */
80
86
  words: Word[];
81
87
  };
88
+ /**
89
+ * Error message
90
+ */
82
91
  export type RealtimeError = {
83
92
  error: string;
84
93
  };
85
- export type RealtimeMessage = SessionBegins | PartialTranscript | FinalTranscript | SessionTerminated | RealtimeError;
94
+ export type RealtimeMessage = SessionBegins | PartialTranscript | FinalTranscript | SessionInformation | SessionTerminated | RealtimeError;
86
95
  export type RealtimeTranscript = PartialTranscript | FinalTranscript;
87
96
  export type RealtimeTranscriptType = "PartialTranscript" | "FinalTranscript";
97
+ /**
98
+ * Session start
99
+ */
88
100
  export type SessionBegins = RealtimeBaseMessage & {
89
101
  /**
90
102
  * Timestamp when this session will expire
@@ -99,12 +111,33 @@ export type SessionBegins = RealtimeBaseMessage & {
99
111
  */
100
112
  session_id: string;
101
113
  };
114
+ /**
115
+ * Information about the session
116
+ * Information about the session that is concluding.
117
+ * This message is sent at the end of the session, before the SessionTerminated message.
118
+ */
119
+ export type SessionInformation = RealtimeBaseMessage & {
120
+ /**
121
+ * The total duration of the audio in seconds
122
+ */
123
+ audio_duration_seconds: number;
124
+ /**
125
+ * Describes the type of the message
126
+ */
127
+ message_type: "SessionInformation";
128
+ };
129
+ /**
130
+ * Session terminated
131
+ */
102
132
  export type SessionTerminated = RealtimeBaseMessage & {
103
133
  /**
104
134
  * Describes the type of the message
105
135
  */
106
136
  message_type: "SessionTerminated";
107
137
  };
138
+ /**
139
+ * Terminate session
140
+ */
108
141
  export type TerminateSession = {
109
142
  /**
110
143
  * Set to true to end your streaming session forever
@@ -258,6 +258,10 @@ export type AutoHighlightsResult = {
258
258
  * A temporally-sequential array of Key Phrases
259
259
  */
260
260
  results: AutoHighlightResult[];
261
+ /**
262
+ * The status of the Key Phrases model. Either success, or unavailable in the rare case that the model failed.
263
+ */
264
+ status: AudioIntelligenceModelStatus;
261
265
  };
262
266
  /**
263
267
  * Chapter of the audio file
@@ -1,4 +1,4 @@
1
- import { AudioEncoding, FinalTranscript, PartialTranscript, RealtimeTranscript, RealtimeTranscriptType } from "../asyncapi.generated";
1
+ import { AudioEncoding, FinalTranscript, PartialTranscript, RealtimeTranscript, RealtimeTranscriptType, SessionInformation } from "../asyncapi.generated";
2
2
  type CreateRealtimeTranscriberParams = {
3
3
  /**
4
4
  * The WebSocket URL that the RealtimeTranscriber connects to
@@ -20,6 +20,18 @@ type CreateRealtimeTranscriberParams = {
20
20
  * The duration of the end utterance silence threshold in milliseconds
21
21
  */
22
22
  endUtteranceSilenceThreshold?: number;
23
+ /**
24
+ * Disable partial transcripts.
25
+ * Set to `true` to not receive partial transcripts. Defaults to `false`.
26
+ * @defaultValue false
27
+ */
28
+ disablePartialTranscripts?: boolean;
29
+ /**
30
+ * Enable extra session information.
31
+ * Set to `true` to receive the `session_information` message before the session ends. Defaults to `false`.
32
+ * @defaultValue false
33
+ */
34
+ enableExtraSessionInformation?: boolean;
23
35
  } & ({
24
36
  /**
25
37
  * The API key used to authenticate the RealtimeTranscriber
@@ -57,6 +69,18 @@ type RealtimeTranscriberParams = {
57
69
  * The duration of the end utterance silence threshold in milliseconds
58
70
  */
59
71
  endUtteranceSilenceThreshold?: number;
72
+ /**
73
+ * Disable partial transcripts.
74
+ * Set to `true` to not receive partial transcripts. Defaults to `false`.
75
+ * @defaultValue false
76
+ */
77
+ disablePartialTranscripts?: boolean;
78
+ /**
79
+ * Enable extra session information.
80
+ * Set to `true` to receive the `session_information` message before the session ends. Defaults to `false`.
81
+ * @defaultValue false
82
+ */
83
+ enableExtraSessionInformation?: boolean;
60
84
  } & ({
61
85
  /**
62
86
  * The API key used to authenticate the RealtimeTranscriber.
@@ -73,7 +97,7 @@ type RealtimeTranscriberParams = {
73
97
  * @deprecated Use RealtimeTranscriberParams instead
74
98
  */
75
99
  type RealtimeServiceParams = RealtimeTranscriberParams;
76
- type RealtimeEvents = "open" | "close" | "transcript" | "transcript.partial" | "transcript.final" | "error";
100
+ type RealtimeEvents = "open" | "close" | "transcript" | "transcript.partial" | "transcript.final" | "session_information" | "error";
77
101
  type SessionBeginsEventData = {
78
102
  sessionId: string;
79
103
  expiresAt: Date;
@@ -84,6 +108,7 @@ type RealtimeListeners = {
84
108
  transcript?: (transcript: RealtimeTranscript) => void;
85
109
  "transcript.partial"?: (transcript: PartialTranscript) => void;
86
110
  "transcript.final"?: (transcript: FinalTranscript) => void;
111
+ session_information?: (info: SessionInformation) => void;
87
112
  error?: (error: Error) => void;
88
113
  };
89
114
  type RealtimeTokenParams = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assemblyai",
3
- "version": "4.3.4",
3
+ "version": "4.4.0",
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"
@@ -69,9 +69,12 @@
69
69
  "build": "pnpm clean && pnpm rollup -c",
70
70
  "clean": "rimraf dist/* && rimraf temp/* && rimraf temp-docs/*",
71
71
  "lint": "eslint -c .eslintrc.json '{src,tests}/**/*.{js,ts}' && publint && tsc --noEmit -p tsconfig.json",
72
- "test": "jest --config jest.config.js",
72
+ "test": "pnpm run test:unit && pnpm run test:integration",
73
+ "test:unit": "jest --config jest.unit.config.js",
74
+ "test:integration": "jest --config jest.integration.config.js --testTimeout 360000",
73
75
  "format": "prettier '**/*' --write",
74
- "generate-types": "tsx ./scripts/generate-types.ts && pnpm format",
76
+ "generate:types": "tsx ./scripts/generate-types.ts && prettier 'src/types/*.generated.ts' --write",
77
+ "generate:reference": "typedoc",
75
78
  "copybara:dry-run": "./copybara.sh dry_run --init-history",
76
79
  "copybara:pr": "./copybara.sh sync_out --init-history"
77
80
  },
@@ -125,7 +128,8 @@
125
128
  "ts-jest": "^29.1.2",
126
129
  "tslib": "^2.5.3",
127
130
  "typescript": "^5.4.2",
128
- "typedoc": "^0.25.12"
131
+ "typedoc": "^0.25.12",
132
+ "typedoc-plugin-extras": "^3.0.0"
129
133
  },
130
134
  "dependencies": {
131
135
  "ws": "^8.16.0"
@@ -12,6 +12,7 @@ import {
12
12
  SessionBeginsEventData,
13
13
  AudioEncoding,
14
14
  AudioData,
15
+ SessionInformation,
15
16
  } from "../..";
16
17
  import {
17
18
  RealtimeError,
@@ -49,6 +50,9 @@ export class RealtimeTranscriber {
49
50
  private apiKey?: string;
50
51
  private token?: string;
51
52
  private endUtteranceSilenceThreshold?: number;
53
+ private enableExtraSessionInformation?: boolean;
54
+ private disablePartialTranscripts?: boolean;
55
+
52
56
  private socket?: WebSocket;
53
57
  private listeners: RealtimeListeners = {};
54
58
  private sessionTerminatedResolve?: () => void;
@@ -59,6 +63,8 @@ export class RealtimeTranscriber {
59
63
  this.wordBoost = params.wordBoost;
60
64
  this.encoding = params.encoding;
61
65
  this.endUtteranceSilenceThreshold = params.endUtteranceSilenceThreshold;
66
+ this.enableExtraSessionInformation = params.enableExtraSessionInformation;
67
+ this.disablePartialTranscripts = params.disablePartialTranscripts;
62
68
  if ("token" in params && params.token) this.token = params.token;
63
69
  if ("apiKey" in params && params.apiKey) this.apiKey = params.apiKey;
64
70
 
@@ -85,6 +91,18 @@ export class RealtimeTranscriber {
85
91
  if (this.encoding) {
86
92
  searchParams.set("encoding", this.encoding);
87
93
  }
94
+ if (this.enableExtraSessionInformation) {
95
+ searchParams.set(
96
+ "enable_extra_session_information",
97
+ this.enableExtraSessionInformation.toString(),
98
+ );
99
+ }
100
+ if (this.disablePartialTranscripts) {
101
+ searchParams.set(
102
+ "disable_partial_transcripts",
103
+ this.disablePartialTranscripts.toString(),
104
+ );
105
+ }
88
106
  url.search = searchParams.toString();
89
107
 
90
108
  return url;
@@ -103,6 +121,10 @@ export class RealtimeTranscriber {
103
121
  event: "transcript.final",
104
122
  listener: (transcript: FinalTranscript) => void,
105
123
  ): void;
124
+ on(
125
+ event: "session_information",
126
+ listener: (info: SessionInformation) => void,
127
+ ): void;
106
128
  on(event: "error", listener: (error: Error) => void): void;
107
129
  on(event: "close", listener: (code: number, reason: string) => void): void;
108
130
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -183,6 +205,10 @@ export class RealtimeTranscriber {
183
205
  this.listeners["transcript.final"]?.(message);
184
206
  break;
185
207
  }
208
+ case "SessionInformation": {
209
+ this.listeners.session_information?.(message);
210
+ break;
211
+ }
186
212
  case "SessionTerminated": {
187
213
  this.sessionTerminatedResolve?.();
188
214
  break;
@@ -15,6 +15,7 @@ import {
15
15
  TranscribeParams,
16
16
  TranscribeOptions,
17
17
  SubmitParams,
18
+ SpeechModel,
18
19
  } from "../..";
19
20
  import { FileService } from "../files";
20
21
  import { getPath } from "../../utils/path";
@@ -37,6 +38,7 @@ export class TranscriptService extends BaseService {
37
38
  params: TranscribeParams,
38
39
  options?: TranscribeOptions,
39
40
  ): Promise<Transcript> {
41
+ deprecateConformer2(params);
40
42
  const transcript = await this.submit(params);
41
43
  return await this.waitUntilReady(transcript.id, options);
42
44
  }
@@ -47,6 +49,7 @@ export class TranscriptService extends BaseService {
47
49
  * @returns A promise that resolves to the queued transcript.
48
50
  */
49
51
  async submit(params: SubmitParams): Promise<Transcript> {
52
+ deprecateConformer2(params);
50
53
  let audioUrl;
51
54
  let transcriptParams: TranscriptParams | undefined = undefined;
52
55
  if ("audio" in params) {
@@ -87,6 +90,7 @@ export class TranscriptService extends BaseService {
87
90
  params: TranscriptParams,
88
91
  options?: CreateTranscriptOptions,
89
92
  ): Promise<Transcript> {
93
+ deprecateConformer2(params);
90
94
  const path = getPath(params.audio_url);
91
95
  if (path !== null) {
92
96
  const uploadUrl = await this.files.upload(path);
@@ -246,3 +250,12 @@ export class TranscriptService extends BaseService {
246
250
  );
247
251
  }
248
252
  }
253
+
254
+ function deprecateConformer2(params: { speech_model?: SpeechModel | null }) {
255
+ if (!params) return;
256
+ if (params.speech_model === "conformer-2") {
257
+ console.warn(
258
+ "The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.",
259
+ );
260
+ }
261
+ }
@@ -37,6 +37,9 @@ export type ConfigureEndUtteranceSilenceThreshold = {
37
37
  end_utterance_silence_threshold: number;
38
38
  };
39
39
 
40
+ /**
41
+ * Transcript text at the end of an utterance with punctuation and casing.
42
+ */
40
43
  export type FinalTranscript = RealtimeBaseTranscript & {
41
44
  /**
42
45
  * Describes the type of message
@@ -66,8 +69,12 @@ export type MessageType =
66
69
  | "SessionBegins"
67
70
  | "PartialTranscript"
68
71
  | "FinalTranscript"
72
+ | "SessionInformation"
69
73
  | "SessionTerminated";
70
74
 
75
+ /**
76
+ * As you send audio data to the API, the API immediately starts responding with Partial Transcript results.
77
+ */
71
78
  export type PartialTranscript = RealtimeBaseTranscript & {
72
79
  /**
73
80
  * Describes the type of message
@@ -110,6 +117,9 @@ export type RealtimeBaseTranscript = {
110
117
  words: Word[];
111
118
  };
112
119
 
120
+ /**
121
+ * Error message
122
+ */
113
123
  export type RealtimeError = {
114
124
  error: string;
115
125
  };
@@ -118,6 +128,7 @@ export type RealtimeMessage =
118
128
  | SessionBegins
119
129
  | PartialTranscript
120
130
  | FinalTranscript
131
+ | SessionInformation
121
132
  | SessionTerminated
122
133
  | RealtimeError;
123
134
 
@@ -125,6 +136,9 @@ export type RealtimeTranscript = PartialTranscript | FinalTranscript;
125
136
 
126
137
  export type RealtimeTranscriptType = "PartialTranscript" | "FinalTranscript";
127
138
 
139
+ /**
140
+ * Session start
141
+ */
128
142
  export type SessionBegins = RealtimeBaseMessage & {
129
143
  /**
130
144
  * Timestamp when this session will expire
@@ -140,6 +154,25 @@ export type SessionBegins = RealtimeBaseMessage & {
140
154
  session_id: string;
141
155
  };
142
156
 
157
+ /**
158
+ * Information about the session
159
+ * Information about the session that is concluding.
160
+ * This message is sent at the end of the session, before the SessionTerminated message.
161
+ */
162
+ export type SessionInformation = RealtimeBaseMessage & {
163
+ /**
164
+ * The total duration of the audio in seconds
165
+ */
166
+ audio_duration_seconds: number;
167
+ /**
168
+ * Describes the type of the message
169
+ */
170
+ message_type: "SessionInformation";
171
+ };
172
+
173
+ /**
174
+ * Session terminated
175
+ */
143
176
  export type SessionTerminated = RealtimeBaseMessage & {
144
177
  /**
145
178
  * Describes the type of the message
@@ -147,6 +180,9 @@ export type SessionTerminated = RealtimeBaseMessage & {
147
180
  message_type: "SessionTerminated";
148
181
  };
149
182
 
183
+ /**
184
+ * Terminate session
185
+ */
150
186
  export type TerminateSession = {
151
187
  /**
152
188
  * Set to true to end your streaming session forever
@@ -271,6 +271,10 @@ export type AutoHighlightsResult = {
271
271
  * A temporally-sequential array of Key Phrases
272
272
  */
273
273
  results: AutoHighlightResult[];
274
+ /**
275
+ * The status of the Key Phrases model. Either success, or unavailable in the rare case that the model failed.
276
+ */
277
+ status: AudioIntelligenceModelStatus;
274
278
  };
275
279
 
276
280
  /**
@@ -4,6 +4,7 @@ import {
4
4
  PartialTranscript,
5
5
  RealtimeTranscript,
6
6
  RealtimeTranscriptType,
7
+ SessionInformation,
7
8
  } from "../asyncapi.generated";
8
9
 
9
10
  type CreateRealtimeTranscriberParams = {
@@ -27,6 +28,18 @@ type CreateRealtimeTranscriberParams = {
27
28
  * The duration of the end utterance silence threshold in milliseconds
28
29
  */
29
30
  endUtteranceSilenceThreshold?: number;
31
+ /**
32
+ * Disable partial transcripts.
33
+ * Set to `true` to not receive partial transcripts. Defaults to `false`.
34
+ * @defaultValue false
35
+ */
36
+ disablePartialTranscripts?: boolean;
37
+ /**
38
+ * Enable extra session information.
39
+ * Set to `true` to receive the `session_information` message before the session ends. Defaults to `false`.
40
+ * @defaultValue false
41
+ */
42
+ enableExtraSessionInformation?: boolean;
30
43
  } & (
31
44
  | {
32
45
  /**
@@ -69,6 +82,18 @@ type RealtimeTranscriberParams = {
69
82
  * The duration of the end utterance silence threshold in milliseconds
70
83
  */
71
84
  endUtteranceSilenceThreshold?: number;
85
+ /**
86
+ * Disable partial transcripts.
87
+ * Set to `true` to not receive partial transcripts. Defaults to `false`.
88
+ * @defaultValue false
89
+ */
90
+ disablePartialTranscripts?: boolean;
91
+ /**
92
+ * Enable extra session information.
93
+ * Set to `true` to receive the `session_information` message before the session ends. Defaults to `false`.
94
+ * @defaultValue false
95
+ */
96
+ enableExtraSessionInformation?: boolean;
72
97
  } & (
73
98
  | {
74
99
  /**
@@ -96,6 +121,7 @@ type RealtimeEvents =
96
121
  | "transcript"
97
122
  | "transcript.partial"
98
123
  | "transcript.final"
124
+ | "session_information"
99
125
  | "error";
100
126
 
101
127
  type SessionBeginsEventData = {
@@ -109,6 +135,7 @@ type RealtimeListeners = {
109
135
  transcript?: (transcript: RealtimeTranscript) => void;
110
136
  "transcript.partial"?: (transcript: PartialTranscript) => void;
111
137
  "transcript.final"?: (transcript: FinalTranscript) => void;
138
+ session_information?: (info: SessionInformation) => void;
112
139
  error?: (error: Error) => void;
113
140
  };
114
141