@eka-care/ekascribe-ts-sdk 2.1.37 → 2.1.39
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 +3 -1
- package/dist/index.mjs +24 -44
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -665,7 +665,7 @@ function configureAWS({ accessKeyId: s, secretKey: n, sessionToken: i }) {
|
|
|
665
665
|
sessionToken: i
|
|
666
666
|
};
|
|
667
667
|
} catch (c) {
|
|
668
|
-
throw
|
|
668
|
+
throw c;
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
671
|
function getConfiguredAwsCredentials() {
|
|
@@ -745,7 +745,7 @@ async function uploadFileToS3(s, n = {}) {
|
|
|
745
745
|
for (let f = 0; f <= i; f++)
|
|
746
746
|
try {
|
|
747
747
|
if (!getConfiguredAwsCredentials()) {
|
|
748
|
-
|
|
748
|
+
f + 1;
|
|
749
749
|
const p = await fetchAndConfigureCredentials();
|
|
750
750
|
if (!p.success) {
|
|
751
751
|
if (p.isPermanent)
|
|
@@ -763,11 +763,7 @@ async function uploadFileToS3(s, n = {}) {
|
|
|
763
763
|
};
|
|
764
764
|
} catch (u) {
|
|
765
765
|
const d = classifyError(u);
|
|
766
|
-
if (l = d,
|
|
767
|
-
`[S3UploadService] Attempt ${f + 1}/${i + 1} failed:`,
|
|
768
|
-
d.message,
|
|
769
|
-
`(permanent: ${d.isPermanent})`
|
|
770
|
-
), d.isPermanent)
|
|
766
|
+
if (l = d, f + 1, i + 1, d.message, `${d.isPermanent}`, d.isPermanent)
|
|
771
767
|
return {
|
|
772
768
|
error: d.message,
|
|
773
769
|
code: d.code,
|
|
@@ -775,7 +771,6 @@ async function uploadFileToS3(s, n = {}) {
|
|
|
775
771
|
};
|
|
776
772
|
if (f >= i)
|
|
777
773
|
break;
|
|
778
|
-
console.log("[S3UploadService] Refreshing credentials before retry...");
|
|
779
774
|
const _ = await fetchAndConfigureCredentials();
|
|
780
775
|
if (!_.success && _.isPermanent)
|
|
781
776
|
return {
|
|
@@ -784,7 +779,7 @@ async function uploadFileToS3(s, n = {}) {
|
|
|
784
779
|
canRetry: !1
|
|
785
780
|
};
|
|
786
781
|
const p = c * Math.pow(2, f);
|
|
787
|
-
|
|
782
|
+
await new Promise((a) => setTimeout(a, p));
|
|
788
783
|
}
|
|
789
784
|
return {
|
|
790
785
|
error: l?.message || "Upload failed after all retries",
|
|
@@ -859,7 +854,6 @@ W1.arraycopy = function(s, n, i, c, l) {
|
|
|
859
854
|
};
|
|
860
855
|
W1.out = {};
|
|
861
856
|
W1.out.println = function(s) {
|
|
862
|
-
console.log(s);
|
|
863
857
|
};
|
|
864
858
|
W1.out.printf = function() {
|
|
865
859
|
console.log.apply(console, arguments);
|
|
@@ -10535,7 +10529,6 @@ class AudioFileManager {
|
|
|
10535
10529
|
return;
|
|
10536
10530
|
}
|
|
10537
10531
|
case SHARED_WORKER_ACTION.REQUEST_TOKEN_REFRESH: {
|
|
10538
|
-
console.log("[AudioFileManager] Worker requested token refresh");
|
|
10539
10532
|
try {
|
|
10540
10533
|
const u = await postCogInit(), { credentials: d, is_session_expired: _ } = u;
|
|
10541
10534
|
if (_ || !d) {
|
|
@@ -10553,7 +10546,7 @@ class AudioFileManager {
|
|
|
10553
10546
|
secretKey: a,
|
|
10554
10547
|
sessionToken: t
|
|
10555
10548
|
}
|
|
10556
|
-
})
|
|
10549
|
+
});
|
|
10557
10550
|
} catch (u) {
|
|
10558
10551
|
console.error("[AudioFileManager] Token refresh failed:", u), this.sharedWorkerInstance?.port.postMessage({
|
|
10559
10552
|
action: SHARED_WORKER_ACTION.TOKEN_REFRESH_ERROR,
|
|
@@ -10731,7 +10724,7 @@ class AudioFileManager {
|
|
|
10731
10724
|
};
|
|
10732
10725
|
}
|
|
10733
10726
|
async uploadAudioToS3({ audioFrames: n, fileName: i, chunkIndex: c }) {
|
|
10734
|
-
typeof SharedWorker > "u" || !SharedWorker || !this.sharedWorkerInstance ?
|
|
10727
|
+
typeof SharedWorker > "u" || !SharedWorker || !this.sharedWorkerInstance ? await this.uploadAudioChunkInMain({ audioFrames: n, fileName: i, chunkIndex: c }) : await this.uploadAudioChunkInWorker({ audioFrames: n, fileName: i, chunkIndex: c });
|
|
10735
10728
|
}
|
|
10736
10729
|
/**
|
|
10737
10730
|
* Download audio as a file to the user's device (for debugging)
|
|
@@ -11469,7 +11462,7 @@ function requireOrtWeb_min() {
|
|
|
11469
11462
|
var ht = t.INITIAL_MEMORY || 16777216;
|
|
11470
11463
|
if (x) Z = t.wasmMemory, k = t.buffer;
|
|
11471
11464
|
else if (t.wasmMemory) Z = t.wasmMemory;
|
|
11472
|
-
else if (!((Z = new WebAssembly.Memory({ initial: ht / 65536, maximum: 65536, shared: !0 })).buffer instanceof SharedArrayBuffer)) throw V("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),
|
|
11465
|
+
else if (!((Z = new WebAssembly.Memory({ initial: ht / 65536, maximum: 65536, shared: !0 })).buffer instanceof SharedArrayBuffer)) throw V("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"), Error("bad memory");
|
|
11473
11466
|
Z && (k = Z.buffer), ht = k.byteLength, mt(k);
|
|
11474
11467
|
var Et, Ot = [], Ht = [], nn = [], C = [];
|
|
11475
11468
|
function U() {
|
|
@@ -20831,7 +20824,7 @@ ${a}`);
|
|
|
20831
20824
|
}
|
|
20832
20825
|
}(), console: new class {
|
|
20833
20826
|
log(a, t, e) {
|
|
20834
|
-
|
|
20827
|
+
`${this.color(a)}`, e && "" + e, `${t}`;
|
|
20835
20828
|
}
|
|
20836
20829
|
color(a) {
|
|
20837
20830
|
switch (a) {
|
|
@@ -24692,12 +24685,12 @@ function requireUtils() {
|
|
|
24692
24685
|
const h = p.result;
|
|
24693
24686
|
_.decodeAudioData(h, (b) => {
|
|
24694
24687
|
a = b, _.startRendering().then((g) => {
|
|
24695
|
-
|
|
24688
|
+
r();
|
|
24696
24689
|
}).catch((g) => {
|
|
24697
24690
|
console.error(`Rendering failed: ${g}`);
|
|
24698
24691
|
});
|
|
24699
24692
|
}, (b) => {
|
|
24700
|
-
|
|
24693
|
+
`${b}`;
|
|
24701
24694
|
});
|
|
24702
24695
|
}), p.readAsArrayBuffer(d);
|
|
24703
24696
|
}), a === null)
|
|
@@ -24863,7 +24856,6 @@ function requireRealTimeVad() {
|
|
|
24863
24856
|
};
|
|
24864
24857
|
return;
|
|
24865
24858
|
} catch (T) {
|
|
24866
|
-
console.log("AudioWorklet setup failed, falling back to ScriptProcessor", T);
|
|
24867
24859
|
}
|
|
24868
24860
|
this.resampler = new a.Resampler({
|
|
24869
24861
|
nativeSampleRate: this.ctx.sampleRate,
|
|
@@ -29541,13 +29533,7 @@ class VadWebClient {
|
|
|
29541
29533
|
let i = !1;
|
|
29542
29534
|
this.vad_frame_count > 0 && (n === 0 && (this.sil_duration_acc = Math.min(this.sil_duration_acc + 1, this.max_length_samples * 2)), n === 1 && (this.sil_duration_acc = 0));
|
|
29543
29535
|
const c = this.vad_frame_count - this.last_clip_index;
|
|
29544
|
-
return c >= this.max_length_samples && (
|
|
29545
|
-
`[VAD] Max length exceeded: sample_passed=${c}. Clipping at frame ${this.vad_frame_count}.`
|
|
29546
|
-
), this.last_clip_reason = "max_forced", this.last_sil_at_clip = this.sil_duration_acc, this.last_clip_index = this.vad_frame_count, this.last_clip_point = this.last_clip_index, this.sil_duration_acc = 0, i = !0), c > this.desp_length_samples && (console.log(`[VAD] Checking clip point: sample_passed=${c} > desperate length`), this.sil_duration_acc > this.shor_thsld && (console.log(
|
|
29547
|
-
`[VAD] Short silence detected: sil_duration_acc=${this.sil_duration_acc}. Clipping at frame ${this.vad_frame_count}.`
|
|
29548
|
-
), this.last_clip_reason = "desperate_silence", this.last_sil_at_clip = this.sil_duration_acc, this.last_clip_index = this.vad_frame_count - Math.min(Math.floor(this.sil_duration_acc / 2), 5), this.last_clip_point = this.last_clip_index, this.sil_duration_acc = 0, i = !0)), c > this.pref_length_samples && (console.log(`[VAD] Checking clip point: sample_passed=${c} > preferred length`), this.sil_duration_acc > this.long_thsld && (console.log(
|
|
29549
|
-
`[VAD] Long silence detected: sil_duration_acc=${this.sil_duration_acc}. Clipping at frame ${this.vad_frame_count}.`
|
|
29550
|
-
), this.last_clip_reason = "preferred_silence", this.last_sil_at_clip = this.sil_duration_acc, this.last_clip_index = this.vad_frame_count - Math.min(Math.floor(this.sil_duration_acc / 2), 5), this.last_clip_point = this.last_clip_index, this.sil_duration_acc = 0, i = !0)), this.vad_frame_count++, i ? [!0, this.last_clip_point] : [!1, this.last_clip_point];
|
|
29536
|
+
return c >= this.max_length_samples && (`${c}${this.vad_frame_count}`, this.last_clip_reason = "max_forced", this.last_sil_at_clip = this.sil_duration_acc, this.last_clip_index = this.vad_frame_count, this.last_clip_point = this.last_clip_index, this.sil_duration_acc = 0, i = !0), c > this.desp_length_samples && this.sil_duration_acc > this.shor_thsld && (`${this.sil_duration_acc}${this.vad_frame_count}`, this.last_clip_reason = "desperate_silence", this.last_sil_at_clip = this.sil_duration_acc, this.last_clip_index = this.vad_frame_count - Math.min(Math.floor(this.sil_duration_acc / 2), 5), this.last_clip_point = this.last_clip_index, this.sil_duration_acc = 0, i = !0), c > this.pref_length_samples && this.sil_duration_acc > this.long_thsld && (`${this.sil_duration_acc}${this.vad_frame_count}`, this.last_clip_reason = "preferred_silence", this.last_sil_at_clip = this.sil_duration_acc, this.last_clip_index = this.vad_frame_count - Math.min(Math.floor(this.sil_duration_acc / 2), 5), this.last_clip_point = this.last_clip_index, this.sil_duration_acc = 0, i = !0), this.vad_frame_count++, i ? [!0, this.last_clip_point] : [!1, this.last_clip_point];
|
|
29551
29537
|
}
|
|
29552
29538
|
/**
|
|
29553
29539
|
* initialize the VAD instance
|
|
@@ -29593,9 +29579,7 @@ class VadWebClient {
|
|
|
29593
29579
|
let a = 0;
|
|
29594
29580
|
if (p >= 0.5 && (a = 1), this.checkNoSpeech(a), this.processVadFrame(a)[0]) {
|
|
29595
29581
|
const r = c?.getAudioData();
|
|
29596
|
-
|
|
29597
|
-
`[VAD] Clip point detected at sample length ${c?.getCurrentSampleLength()}. Processing audio chunk.`
|
|
29598
|
-
), addBreadcrumb("vad.clip", "Clip point triggered", {
|
|
29582
|
+
`${c?.getCurrentSampleLength()}`, addBreadcrumb("vad.clip", "Clip point triggered", {
|
|
29599
29583
|
clip_reason: this.last_clip_reason,
|
|
29600
29584
|
actual_duration_s: ((c?.getCurrentSampleLength() ?? 0) / 16e3).toFixed(2),
|
|
29601
29585
|
sil_at_clip_frames: this.last_sil_at_clip,
|
|
@@ -29800,7 +29784,7 @@ const endVoiceRecording = async () => {
|
|
|
29800
29784
|
}
|
|
29801
29785
|
await n.waitForAllUploads();
|
|
29802
29786
|
const u = (n?.audioChunks).map((a) => a.fileName);
|
|
29803
|
-
if (
|
|
29787
|
+
if (EkaScribeStore$1.sessionStatus[c].api?.status === API_STATUS.INIT) {
|
|
29804
29788
|
const { message: a, code: t } = await postTransactionStop({
|
|
29805
29789
|
audioFiles: u,
|
|
29806
29790
|
txnId: c
|
|
@@ -29828,7 +29812,7 @@ const endVoiceRecording = async () => {
|
|
|
29828
29812
|
};
|
|
29829
29813
|
const d = n.getFailedUploads() || [];
|
|
29830
29814
|
let _ = [];
|
|
29831
|
-
if (
|
|
29815
|
+
if (d.length > 0 && (_ = await n.retryFailedUploads()), _.length > 0)
|
|
29832
29816
|
return {
|
|
29833
29817
|
error_code: ERROR_CODE.AUDIO_UPLOAD_FAILED,
|
|
29834
29818
|
status_code: SDK_STATUS_CODE.AUDIO_ERROR,
|
|
@@ -30509,7 +30493,7 @@ async function postV1FileUpload({
|
|
|
30509
30493
|
code: l.status
|
|
30510
30494
|
}, f;
|
|
30511
30495
|
} catch (i) {
|
|
30512
|
-
return
|
|
30496
|
+
return {
|
|
30513
30497
|
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
30514
30498
|
message: `Something went wrong! ${i}`
|
|
30515
30499
|
};
|
|
@@ -30872,7 +30856,7 @@ const decodeApiResponse = (s) => {
|
|
|
30872
30856
|
poll_status: "in-progress"
|
|
30873
30857
|
}), b >= 400) {
|
|
30874
30858
|
if (a++, a >= 3) {
|
|
30875
|
-
const S = g?.error?.
|
|
30859
|
+
const S = g?.error?.message || "We encountered a backend error while fetching results. Please try again.";
|
|
30876
30860
|
return d(b, null, S, "failed");
|
|
30877
30861
|
}
|
|
30878
30862
|
} else
|
|
@@ -30898,7 +30882,7 @@ const decodeApiResponse = (s) => {
|
|
|
30898
30882
|
}, e = [];
|
|
30899
30883
|
i && e.push(`template_id=${i}`), c && e.push(`document_id=${c}`), l && e.push("dlp=true");
|
|
30900
30884
|
const r = e.join("&");
|
|
30901
|
-
return
|
|
30885
|
+
return t(r);
|
|
30902
30886
|
} catch (_) {
|
|
30903
30887
|
return _ instanceof Error && _.name === "AbortError" ? d(-1, null, "Request was aborted due to timeout.", "timeout") : d(
|
|
30904
30888
|
-1,
|
|
@@ -31167,7 +31151,7 @@ class SystemCompatibilityManager {
|
|
|
31167
31151
|
{ supported: !1, workerCreated: !1 }
|
|
31168
31152
|
);
|
|
31169
31153
|
} catch (i) {
|
|
31170
|
-
return
|
|
31154
|
+
return this.createTestResult(
|
|
31171
31155
|
n,
|
|
31172
31156
|
COMPATIBILITY_TEST_STATUS.WARNING,
|
|
31173
31157
|
"SharedWorker supported but failed to create",
|
|
@@ -31739,14 +31723,13 @@ const _n = class _n {
|
|
|
31739
31723
|
audioChunks_count: EkaScribeStore$1.audioFileManagerInstance?.audioChunks?.length ?? null
|
|
31740
31724
|
});
|
|
31741
31725
|
const c = await initialiseTransaction(n);
|
|
31742
|
-
return
|
|
31726
|
+
return captureEvent("Session started", {
|
|
31743
31727
|
txn_id: EkaScribeStore$1.txnID,
|
|
31744
31728
|
status_code: c.status_code
|
|
31745
31729
|
}), c;
|
|
31746
31730
|
}
|
|
31747
31731
|
async startRecording(n) {
|
|
31748
|
-
|
|
31749
|
-
return console.log("%c Line:110 🍓 startResponse", "color:#465975", i), i;
|
|
31732
|
+
return await startVoiceRecording(n);
|
|
31750
31733
|
}
|
|
31751
31734
|
reinitializeVad() {
|
|
31752
31735
|
this.vadInstance.reinitializeVad();
|
|
@@ -31758,12 +31741,10 @@ const _n = class _n {
|
|
|
31758
31741
|
this.vadInstance.pauseVad();
|
|
31759
31742
|
}
|
|
31760
31743
|
pauseRecording() {
|
|
31761
|
-
|
|
31762
|
-
return console.log("%c Line:117 🍌 pauseRecordingResponse", "color:#6ec1c2", n), n;
|
|
31744
|
+
return pauseVoiceRecording();
|
|
31763
31745
|
}
|
|
31764
31746
|
resumeRecording() {
|
|
31765
|
-
|
|
31766
|
-
return console.log("%c Line:124 🌶 resumeRecordingResponse", "color:#33a5ff", n), n;
|
|
31747
|
+
return resumeVoiceRecording();
|
|
31767
31748
|
}
|
|
31768
31749
|
async endRecording() {
|
|
31769
31750
|
addBreadcrumb("instance.check", "endRecording", {
|
|
@@ -31780,11 +31761,10 @@ const _n = class _n {
|
|
|
31780
31761
|
status_code: n.status_code,
|
|
31781
31762
|
error_code: n.error_code ?? null,
|
|
31782
31763
|
total_chunks: EkaScribeStore$1.audioFileManagerInstance?.audioChunks?.length ?? null
|
|
31783
|
-
}),
|
|
31764
|
+
}), n;
|
|
31784
31765
|
}
|
|
31785
31766
|
async retryUploadRecording({ force_commit: n }) {
|
|
31786
|
-
|
|
31787
|
-
return console.log("%c Line:138 🍖 retryUploadResponse", "color:#3f7cff", i), i;
|
|
31767
|
+
return await retryUploadFailedFiles({ force_commit: n });
|
|
31788
31768
|
}
|
|
31789
31769
|
async patchSessionStatus(n) {
|
|
31790
31770
|
try {
|