@eka-care/ekascribe-ts-sdk 2.1.47 → 2.1.49

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/dist/index.d.ts CHANGED
@@ -51,7 +51,7 @@ declare class EkaScribe {
51
51
  initTransaction(request: TPostTransactionInitRequest, sharedWorkerUrl?: string): Promise<TStartRecordingResponse>;
52
52
  startRecording(microphoneID?: string): Promise<TStartRecordingResponse>;
53
53
  startRecordingForExistingSession(request: TStartRecordingForExistingSessionRequest): Promise<TStartRecordingResponse>;
54
- reinitializeVad(): void;
54
+ reinitializeVad(): Promise<void>;
55
55
  destroyVad(): void;
56
56
  pauseVad(): void;
57
57
  pauseRecording(): TPauseRecordingResponse;
@@ -742,6 +742,7 @@ export declare type TPostV1DocumentRequest = {
742
742
  document_name?: string;
743
743
  type?: string;
744
744
  document_id?: string;
745
+ publish?: Record<string, unknown>;
745
746
  };
746
747
 
747
748
  export declare type TPostV1DocumentResponse = {
@@ -766,6 +767,7 @@ export declare type TPostV1DocumentResponse = {
766
767
  presigned_url: string;
767
768
  created_at: string;
768
769
  updated_at: number;
770
+ publish: Record<string, unknown>;
769
771
  };
770
772
  };
771
773
 
package/dist/index.mjs CHANGED
@@ -29617,7 +29617,11 @@ class VadWebClient {
29617
29617
  * reinitialize the vad instance
29618
29618
  */
29619
29619
  async reinitializeVad(n) {
29620
- return await this.initVad(n);
29620
+ try {
29621
+ return await this.initVad(n);
29622
+ } catch (i) {
29623
+ console.error("[EkaScribe] Error in reinitializeVad:", i);
29624
+ }
29621
29625
  }
29622
29626
  /**
29623
29627
  * process and upload audio chunk to s3
@@ -29682,36 +29686,60 @@ class VadWebClient {
29682
29686
  * Start VAD
29683
29687
  */
29684
29688
  startVad() {
29685
- this.recording_started || (this.micVad && typeof this.micVad.start == "function" && this.micVad.start(), this.recording_started = !0);
29689
+ try {
29690
+ if (this.recording_started) return;
29691
+ this.micVad && typeof this.micVad.start == "function" && this.micVad.start(), this.recording_started = !0;
29692
+ } catch (n) {
29693
+ console.error("[EkaScribe] Error in startVad:", n);
29694
+ }
29686
29695
  }
29687
29696
  /**
29688
29697
  * Pause VAD
29689
29698
  */
29690
29699
  pauseVad() {
29691
- this.recording_started && (this.micVad && typeof this.micVad.pause == "function" && this.micVad.pause(), this.recording_started = !1);
29700
+ try {
29701
+ if (!this.recording_started) return;
29702
+ this.micVad && typeof this.micVad.pause == "function" && this.micVad.pause(), this.recording_started = !1;
29703
+ } catch (n) {
29704
+ console.error("[EkaScribe] Error in pauseVad:", n);
29705
+ }
29692
29706
  }
29693
29707
  /**
29694
29708
  * End VAD
29695
29709
  */
29696
29710
  destroyVad() {
29697
- this.micVad && typeof this.micVad.destroy == "function" && this.micVad.destroy(), this.stopMicStream(), this.recording_started = !1;
29711
+ try {
29712
+ this.micVad && typeof this.micVad.destroy == "function" && this.micVad.destroy(), this.stopMicStream(), this.recording_started = !1;
29713
+ } catch (n) {
29714
+ console.error("[EkaScribe] Error in destroyVad:", n);
29715
+ }
29698
29716
  }
29699
29717
  /**
29700
29718
  * reset vadWeb instance
29701
29719
  */
29702
29720
  resetVadWebInstance() {
29703
- this.micVad && typeof this.micVad.destroy == "function" && this.micVad.destroy(), this.stopMicStream(), this.vad_frame_count = 0, this.last_clip_index = 0, this.last_clip_point = 0, this.sil_duration_acc = 0, this.noSpeechStartTime = null, this.lastWarningTime = null, this.recording_started = !1, this.is_vad_loading = !0;
29721
+ try {
29722
+ this.micVad && typeof this.micVad.destroy == "function" && this.micVad.destroy(), this.stopMicStream(), this.vad_frame_count = 0, this.last_clip_index = 0, this.last_clip_point = 0, this.sil_duration_acc = 0, this.noSpeechStartTime = null, this.lastWarningTime = null, this.recording_started = !1, this.is_vad_loading = !0;
29723
+ } catch (n) {
29724
+ console.error("[EkaScribe] Error in resetVadWebInstance:", n);
29725
+ }
29704
29726
  }
29705
29727
  /**
29706
29728
  * monitor initial audio capture within starting 4 seconds
29707
29729
  */
29708
29730
  monitorAudioCapture() {
29709
29731
  const n = EkaScribeStore$1.audioBufferInstance, i = EkaScribeStore$1.vadFramesCallback;
29710
- setTimeout(() => n && n.getCurrentSampleLength() <= 0 ? (this.micVad.pause(), i && i({
29711
- message: "No audio is being captured. Please check your microphone.",
29712
- error_code: ERROR_CODE.NO_AUDIO_CAPTURE,
29713
- status_code: SDK_STATUS_CODE.AUDIO_ERROR
29714
- }), !1) : !0, 5e3);
29732
+ setTimeout(() => {
29733
+ try {
29734
+ return n && n.getCurrentSampleLength() <= 0 ? (this.micVad && typeof this.micVad.pause == "function" && this.micVad.pause(), i && i({
29735
+ message: "No audio is being captured. Please check your microphone.",
29736
+ error_code: ERROR_CODE.NO_AUDIO_CAPTURE,
29737
+ status_code: SDK_STATUS_CODE.AUDIO_ERROR
29738
+ }), !1) : !0;
29739
+ } catch (c) {
29740
+ return console.error("[EkaScribe] Error in monitorAudioCapture:", c), !1;
29741
+ }
29742
+ }, 5e3);
29715
29743
  }
29716
29744
  /**
29717
29745
  * Callback to configure constants
@@ -31606,30 +31634,32 @@ async function postV1Document({
31606
31634
  session_id: s,
31607
31635
  document_name: n,
31608
31636
  type: i,
31609
- document_id: c
31637
+ document_id: c,
31638
+ publish: l
31610
31639
  }) {
31611
31640
  try {
31612
- const l = new Headers();
31613
- l.append("Content-Type", "application/json");
31614
- const f = {
31641
+ const f = new Headers();
31642
+ f.append("Content-Type", "application/json");
31643
+ const u = {
31615
31644
  session_id: s,
31616
31645
  type: i,
31617
31646
  ...n ? { document_name: n } : {},
31618
- ...c ? { document_id: c } : {}
31619
- }, u = {
31647
+ ...c ? { document_id: c } : {},
31648
+ ...l ? { publish: l } : {}
31649
+ }, d = {
31620
31650
  method: "POST",
31621
- headers: l,
31622
- body: JSON.stringify(f)
31623
- }, d = await fetchWrapper(`${GET_EKA_VOICE_HOST_V1()}/documents`, u);
31624
- let h = await d.json();
31625
- return h = {
31626
- ...h,
31627
- code: d.status
31628
- }, h;
31629
- } catch (l) {
31630
- return console.error("%c postV1Document -> error", "color:#f5ce50", l), {
31651
+ headers: f,
31652
+ body: JSON.stringify(u)
31653
+ }, h = await fetchWrapper(`${GET_EKA_VOICE_HOST_V1()}/documents`, d);
31654
+ let p = await h.json();
31655
+ return p = {
31656
+ ...p,
31657
+ code: h.status
31658
+ }, p;
31659
+ } catch (f) {
31660
+ return console.error("%c postV1Document -> error", "color:#f5ce50", f), {
31631
31661
  code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
31632
- message: `Something went wrong! ${l}`
31662
+ message: `Something went wrong! ${f}`
31633
31663
  };
31634
31664
  }
31635
31665
  }
@@ -31869,14 +31899,26 @@ const _n = class _n {
31869
31899
  async startRecordingForExistingSession(n) {
31870
31900
  return await startRecordingForExistingSession(n);
31871
31901
  }
31872
- reinitializeVad() {
31873
- this.vadInstance.reinitializeVad();
31902
+ async reinitializeVad() {
31903
+ try {
31904
+ await this.vadInstance.reinitializeVad();
31905
+ } catch (n) {
31906
+ console.error("[EkaScribe] Error in reinitializeVad:", n);
31907
+ }
31874
31908
  }
31875
31909
  destroyVad() {
31876
- this.vadInstance.destroyVad();
31910
+ try {
31911
+ this.vadInstance.destroyVad();
31912
+ } catch (n) {
31913
+ console.error("[EkaScribe] Error in destroyVad:", n);
31914
+ }
31877
31915
  }
31878
31916
  pauseVad() {
31879
- this.vadInstance.pauseVad();
31917
+ try {
31918
+ this.vadInstance.pauseVad();
31919
+ } catch (n) {
31920
+ console.error("[EkaScribe] Error in pauseVad:", n);
31921
+ }
31880
31922
  }
31881
31923
  pauseRecording() {
31882
31924
  return pauseVoiceRecording();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eka-care/ekascribe-ts-sdk",
3
- "version": "2.1.47",
3
+ "version": "2.1.49",
4
4
  "description": "EkaScribe TypeScript SDK - Modern ES2020 build",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",