@eka-care/ekascribe-ts-sdk 1.4.57 → 1.4.58
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.
|
@@ -150,13 +150,15 @@ class AudioFileManager {
|
|
|
150
150
|
const workerResponse = event.data;
|
|
151
151
|
switch (workerResponse.action) {
|
|
152
152
|
case SHARED_WORKER_ACTION.CONFIGURE_AWS_SUCCESS: {
|
|
153
|
+
// Callback
|
|
153
154
|
return;
|
|
154
155
|
}
|
|
155
156
|
case SHARED_WORKER_ACTION.CONFIGURE_AWS_ERROR: {
|
|
157
|
+
// Callback
|
|
156
158
|
return;
|
|
157
159
|
}
|
|
158
160
|
case SHARED_WORKER_ACTION.UPLOAD_FILE_WITH_WORKER_SUCCESS: {
|
|
159
|
-
|
|
161
|
+
// Callback
|
|
160
162
|
const { fileCount: fileName, chunkIndex, fileBlob, compressedAudioBuffer, } = workerResponse.requestBody;
|
|
161
163
|
if (this.onProgressCallback && compressedAudioBuffer) {
|
|
162
164
|
this.onProgressCallback({
|
|
@@ -287,6 +289,7 @@ class AudioFileManager {
|
|
|
287
289
|
businessID: this.businessID,
|
|
288
290
|
is_shared_worker: false,
|
|
289
291
|
}).then((response) => {
|
|
292
|
+
// callback
|
|
290
293
|
if (response.success) {
|
|
291
294
|
this.successfulUploads.push(fileName);
|
|
292
295
|
// update file status if file uploaded successfully
|
|
@@ -496,6 +499,7 @@ class AudioFileManager {
|
|
|
496
499
|
this.audioChunks.forEach((chunk, index) => {
|
|
497
500
|
const { fileName, fileBlob, status, audioFrames } = chunk;
|
|
498
501
|
if (status != 'success') {
|
|
502
|
+
// callback
|
|
499
503
|
this.sharedWorkerInstance?.port.postMessage({
|
|
500
504
|
action: SHARED_WORKER_ACTION.UPLOAD_FILE_WITH_WORKER,
|
|
501
505
|
payload: {
|
|
@@ -522,6 +526,7 @@ class AudioFileManager {
|
|
|
522
526
|
this.audioChunks.forEach((chunk, index) => {
|
|
523
527
|
const { fileName, fileBlob, status, audioFrames } = chunk;
|
|
524
528
|
if (status != 'success') {
|
|
529
|
+
// callback
|
|
525
530
|
let failedFileBlob;
|
|
526
531
|
if (status === 'failure') {
|
|
527
532
|
failedFileBlob = fileBlob;
|
|
@@ -571,7 +576,24 @@ class AudioFileManager {
|
|
|
571
576
|
* Reset the upload state
|
|
572
577
|
*/
|
|
573
578
|
resetFileManagerInstance() {
|
|
579
|
+
// Cancel all pending uploads
|
|
580
|
+
this.uploadPromises.forEach((promise) => {
|
|
581
|
+
// Note: Promises can't be cancelled, but we can ignore their results
|
|
582
|
+
promise.catch(() => { }); // Prevent unhandled rejections
|
|
583
|
+
});
|
|
584
|
+
// Terminate SharedWorker
|
|
585
|
+
if (this.sharedWorkerInstance) {
|
|
586
|
+
this.sharedWorkerInstance.port.close();
|
|
587
|
+
this.sharedWorkerInstance = null;
|
|
588
|
+
}
|
|
589
|
+
// Clear all state
|
|
574
590
|
this.initialiseClassInstance();
|
|
591
|
+
// Reset additional properties not covered by initialiseClassInstance
|
|
592
|
+
this.txnID = '';
|
|
593
|
+
this.filePath = '';
|
|
594
|
+
this.businessID = '';
|
|
595
|
+
this.isAWSConfigured = false;
|
|
596
|
+
this.onProgressCallback = undefined;
|
|
575
597
|
}
|
|
576
598
|
}
|
|
577
599
|
export default AudioFileManager;
|
|
@@ -340,6 +340,11 @@ class VadWebClient {
|
|
|
340
340
|
* reset vadWeb instance
|
|
341
341
|
*/
|
|
342
342
|
resetVadWebInstance() {
|
|
343
|
+
// Properly destroy MicVAD instance
|
|
344
|
+
if (this.micVad && typeof this.micVad.destroy === 'function') {
|
|
345
|
+
this.micVad.destroy();
|
|
346
|
+
}
|
|
347
|
+
// Reset VAD state
|
|
343
348
|
this.vad_past = [];
|
|
344
349
|
this.last_clip_index = 0;
|
|
345
350
|
this.clip_points = [0];
|
|
@@ -347,7 +352,8 @@ class VadWebClient {
|
|
|
347
352
|
this.noSpeechStartTime = null;
|
|
348
353
|
this.lastWarningTime = null;
|
|
349
354
|
this.recording_started = false;
|
|
350
|
-
|
|
355
|
+
this.is_vad_loading = true; // Reset to initial state
|
|
356
|
+
this.micVad = {}; // Clear the instance
|
|
351
357
|
if (EkaScribeStore.errorCallback) {
|
|
352
358
|
EkaScribeStore.errorCallback({
|
|
353
359
|
error_code: ERROR_CODE.SPEECH_DETECTED,
|
package/dist/index.js
CHANGED
|
@@ -232,6 +232,10 @@ class EkaScribe {
|
|
|
232
232
|
}
|
|
233
233
|
resetEkaScribe() {
|
|
234
234
|
console.log(this.audioFileManagerInstance, this.audioBufferInstance, this.vadInstance, EkaScribeStore, 'before reset ekascribe');
|
|
235
|
+
// First, stop any ongoing operations
|
|
236
|
+
if (this.vadInstance) {
|
|
237
|
+
this.vadInstance.pauseVad(); // Stop recording first
|
|
238
|
+
}
|
|
235
239
|
this.audioFileManagerInstance.resetFileManagerInstance();
|
|
236
240
|
this.audioBufferInstance.resetBufferManagerInstance();
|
|
237
241
|
this.vadInstance.resetVadWebInstance();
|
package/dist/store/store.js
CHANGED
|
@@ -116,6 +116,9 @@ class EkaScribeStore {
|
|
|
116
116
|
this._txnID = '';
|
|
117
117
|
this._sessionBucketPath = '';
|
|
118
118
|
this._sessionStatus = {};
|
|
119
|
+
// Clear callbacks
|
|
120
|
+
this._errorCallback = null;
|
|
121
|
+
this._userSpeechCallback = null;
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
124
|
export default EkaScribeStore.getInstance();
|