@eka-care/ekascribe-ts-sdk 1.5.19 → 1.5.21

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.
@@ -163,7 +163,6 @@ class AudioFileManager {
163
163
  }
164
164
  case SHARED_WORKER_ACTION.UPLOAD_FILE_WITH_WORKER_SUCCESS: {
165
165
  const { fileCount: fileName, chunkIndex, fileBlob, compressedAudioBuffer, } = workerResponse.requestBody;
166
- console.log(workerResponse.response, 'SDK response');
167
166
  if (onEventCallback && compressedAudioBuffer) {
168
167
  onEventCallback({
169
168
  callback_type: CALLBACK_TYPE.FILE_UPLOAD_STATUS,
@@ -190,9 +189,7 @@ class AudioFileManager {
190
189
  response: workerResponse.response.success,
191
190
  };
192
191
  }
193
- console.log(onEventCallback, '182 - SDK');
194
192
  if (onEventCallback) {
195
- console.log(onEventCallback, '184 - SDK');
196
193
  onEventCallback({
197
194
  callback_type: CALLBACK_TYPE.FILE_UPLOAD_STATUS,
198
195
  status: 'success',
@@ -1,7 +1,7 @@
1
1
  import { MicVAD } from '@ricky0123/vad-web';
2
2
  import { FRAME_SIZE, LONG_SILENCE_THRESHOLD, OUTPUT_FORMAT, PRE_SPEECH_PAD_FRAMES, SDK_STATUS_CODE, SHORT_SILENCE_THRESHOLD, } from '../constants/constant';
3
3
  import EkaScribeStore from '../store/store';
4
- import { CALLBACK_TYPE, ERROR_CODE } from '../constants/enums';
4
+ import { ERROR_CODE } from '../constants/enums';
5
5
  class VadWebClient {
6
6
  /**
7
7
  * Class that handle Vad functions and manages audio chunk
@@ -134,7 +134,7 @@ class VadWebClient {
134
134
  if (!this.recording_started)
135
135
  return;
136
136
  const now = Date.now();
137
- const onEventCallback = EkaScribeStore.eventCallback;
137
+ const onVadCallback = EkaScribeStore.vadFramesCallback;
138
138
  const silenceThreshold = 10000; // 10 seconds
139
139
  if (isSpeech === 0) {
140
140
  if (this.noSpeechStartTime === null) {
@@ -147,16 +147,11 @@ class VadWebClient {
147
147
  // Check if enough time has passed since the last warning (cooldown period)
148
148
  if (this.lastWarningTime === null ||
149
149
  now - this.lastWarningTime >= this.warningCooldownPeriod) {
150
- if (onEventCallback) {
151
- onEventCallback({
152
- callback_type: CALLBACK_TYPE.VAD_AUDIO_STATUS,
153
- status: 'info',
150
+ if (onVadCallback) {
151
+ onVadCallback({
154
152
  message: 'No audio detected for a while. Please talk or stop the recording if done.',
155
- timestamp: new Date().toISOString(),
156
- data: {
157
- error_code: ERROR_CODE.NO_AUDIO_CAPTURE,
158
- status_code: SDK_STATUS_CODE.AUDIO_ERROR,
159
- },
153
+ error_code: ERROR_CODE.NO_AUDIO_CAPTURE,
154
+ status_code: SDK_STATUS_CODE.AUDIO_ERROR,
160
155
  });
161
156
  }
162
157
  this.lastWarningTime = now;
@@ -170,16 +165,11 @@ class VadWebClient {
170
165
  // Reset timers when speech is detected
171
166
  this.noSpeechStartTime = null;
172
167
  this.lastWarningTime = null;
173
- if (onEventCallback) {
174
- onEventCallback({
175
- callback_type: CALLBACK_TYPE.VAD_AUDIO_STATUS,
176
- status: 'info',
168
+ if (onVadCallback) {
169
+ onVadCallback({
177
170
  message: 'Audio captured. Recording continues.',
178
- timestamp: new Date().toISOString(),
179
- data: {
180
- error_code: ERROR_CODE.SPEECH_DETECTED,
181
- status_code: SDK_STATUS_CODE.SUCCESS,
182
- },
171
+ error_code: ERROR_CODE.SPEECH_DETECTED,
172
+ status_code: SDK_STATUS_CODE.SUCCESS,
183
173
  });
184
174
  }
185
175
  }
@@ -377,20 +367,15 @@ class VadWebClient {
377
367
  */
378
368
  monitorAudioCapture() {
379
369
  const audioBuffer = EkaScribeStore.audioBufferInstance;
380
- const onEventCallback = EkaScribeStore.eventCallback;
370
+ const onVadCallback = EkaScribeStore.vadFramesCallback;
381
371
  setTimeout(() => {
382
372
  if (audioBuffer && audioBuffer.getCurrentSampleLength() <= 0) {
383
373
  this.micVad.pause();
384
- if (onEventCallback) {
385
- onEventCallback({
386
- callback_type: CALLBACK_TYPE.VAD_AUDIO_STATUS,
387
- status: 'info',
374
+ if (onVadCallback) {
375
+ onVadCallback({
388
376
  message: 'No audio is being captured. Please check your microphone.',
389
- timestamp: new Date().toISOString(),
390
- data: {
391
- error_code: ERROR_CODE.NO_AUDIO_CAPTURE,
392
- status_code: SDK_STATUS_CODE.AUDIO_ERROR,
393
- },
377
+ error_code: ERROR_CODE.NO_AUDIO_CAPTURE,
378
+ status_code: SDK_STATUS_CODE.AUDIO_ERROR,
394
379
  });
395
380
  }
396
381
  return false;
@@ -36,12 +36,12 @@ const pushFileToS3 = async ({ fileBlob, fileName, txnID, businessID, is_shared_w
36
36
  return {
37
37
  error: `Expired token! ${err}`,
38
38
  errorCode: 'ExpiredToken',
39
- code: error.statusCode,
39
+ code: error.statusCode || error.code,
40
40
  };
41
41
  }
42
42
  return {
43
43
  error: `Something went wrong! ${err}`,
44
- code: error.statusCode,
44
+ code: error.statusCode || error.code,
45
45
  };
46
46
  }
47
47
  };
@@ -55,6 +55,5 @@ export declare enum CALLBACK_TYPE {
55
55
  TEMPLATE_OPERATION_STATUS = "template_operation_status",
56
56
  AUTHENTICATION_STATUS = "authentication_status",
57
57
  NETWORK_STATUS = "network_status",
58
- STORAGE_STATUS = "storage_status",
59
- VAD_AUDIO_STATUS = "vad_audio_status"
58
+ STORAGE_STATUS = "storage_status"
60
59
  }
@@ -62,5 +62,4 @@ export var CALLBACK_TYPE;
62
62
  CALLBACK_TYPE["AUTHENTICATION_STATUS"] = "authentication_status";
63
63
  CALLBACK_TYPE["NETWORK_STATUS"] = "network_status";
64
64
  CALLBACK_TYPE["STORAGE_STATUS"] = "storage_status";
65
- CALLBACK_TYPE["VAD_AUDIO_STATUS"] = "vad_audio_status";
66
65
  })(CALLBACK_TYPE || (CALLBACK_TYPE = {}));
@@ -224,11 +224,10 @@ export type TAudioChunksInfo = {
224
224
  audioFrames?: undefined;
225
225
  });
226
226
  export type UploadProgressCallback = (success: string[], total: number) => void;
227
- export type TErrorCallback = (args: {
227
+ export type TVadFramesCallback = (args: {
228
228
  error_code?: ERROR_CODE;
229
229
  status_code: number;
230
- success_message?: string;
231
- error_message?: string;
230
+ message?: string;
232
231
  request?: string;
233
232
  }) => void;
234
233
  export type TSessionStatus = {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { TGetStatusResponse } from './api/transaction/get-voice-api-v3-status';
2
- import { TEndRecordingResponse, TEventCallback, TGetTransactionHistoryResponse, TPatchTransactionRequest, TPatchVoiceApiV2ConfigRequest, TPatchVoiceApiV3StatusRequest, TPostTransactionResponse, TPostV1ConvertToTemplateRequest, TPostV1TemplateRequest, TPostV1TemplateSectionRequest, TPostV1UploadAudioFilesRequest, TStartRecordingRequest } from './constants/types';
2
+ import { TEndRecordingResponse, TEventCallback, TGetTransactionHistoryResponse, TPatchTransactionRequest, TPatchVoiceApiV2ConfigRequest, TPatchVoiceApiV3StatusRequest, TPostTransactionResponse, TPostV1ConvertToTemplateRequest, TPostV1TemplateRequest, TPostV1TemplateSectionRequest, TPostV1UploadAudioFilesRequest, TStartRecordingRequest, TVadFramesCallback } from './constants/types';
3
3
  import { TSearchSessionsByPatientRequest } from './utils/search-sessions-by-patient-name';
4
4
  declare class EkaScribe {
5
5
  private static instance;
@@ -43,6 +43,7 @@ declare class EkaScribe {
43
43
  resetEkaScribe(): void;
44
44
  onUserSpeechCallback(callback: (isSpeech: boolean) => void): void;
45
45
  onEventCallback(callback: TEventCallback): void;
46
+ onVadFramesCallback(callback: TVadFramesCallback): void;
46
47
  configureVadConstants({ pref_length, desp_length, max_length, sr, frame_size, pre_speech_pad_frames, short_thsld, long_thsld, }: {
47
48
  pref_length: number;
48
49
  desp_length: number;
package/dist/index.js CHANGED
@@ -270,6 +270,9 @@ class EkaScribe {
270
270
  EkaScribeStore.eventCallback = callback;
271
271
  // this.audioFileManagerInstance.setProgressCallback(callback);
272
272
  }
273
+ onVadFramesCallback(callback) {
274
+ EkaScribeStore.vadFramesCallback = callback;
275
+ }
273
276
  configureVadConstants({ pref_length, desp_length, max_length, sr, frame_size, pre_speech_pad_frames, short_thsld, long_thsld, }) {
274
277
  return this.vadInstance.configureVadConstants({
275
278
  pref_length,
@@ -1,7 +1,7 @@
1
1
  import AudioBufferManager from '../audio-chunker/audio-buffer-manager';
2
2
  import AudioFileManager from '../audio-chunker/audio-file-manager';
3
3
  import VadWebClient from '../audio-chunker/vad-web';
4
- import { TEventCallback, TSessionStatus } from '../constants/types';
4
+ import { TEventCallback, TSessionStatus, TVadFramesCallback } from '../constants/types';
5
5
  declare class EkaScribeStore {
6
6
  private static instance;
7
7
  private _txnID;
@@ -12,6 +12,7 @@ declare class EkaScribeStore {
12
12
  private _sessionStatus;
13
13
  private _userSpeechCallback;
14
14
  private _eventCallback;
15
+ private _vadFramesCallback;
15
16
  static getInstance(): EkaScribeStore;
16
17
  get vadInstance(): VadWebClient | null;
17
18
  set vadInstance(value: VadWebClient);
@@ -29,6 +30,8 @@ declare class EkaScribeStore {
29
30
  set userSpeechCallback(callback: ((isSpeech: boolean) => void) | null);
30
31
  get eventCallback(): TEventCallback | null;
31
32
  set eventCallback(callback: TEventCallback | null);
33
+ get vadFramesCallback(): TVadFramesCallback | null;
34
+ set vadFramesCallback(callback: TVadFramesCallback | null);
32
35
  resetStore(): void;
33
36
  }
34
37
  declare const _default: EkaScribeStore;
@@ -48,6 +48,12 @@ class EkaScribeStore {
48
48
  writable: true,
49
49
  value: null
50
50
  });
51
+ Object.defineProperty(this, "_vadFramesCallback", {
52
+ enumerable: true,
53
+ configurable: true,
54
+ writable: true,
55
+ value: null
56
+ });
51
57
  }
52
58
  static getInstance() {
53
59
  if (!EkaScribeStore.instance) {
@@ -111,6 +117,13 @@ class EkaScribeStore {
111
117
  set eventCallback(callback) {
112
118
  this._eventCallback = callback;
113
119
  }
120
+ // Vad Frames Callback
121
+ get vadFramesCallback() {
122
+ return this._vadFramesCallback;
123
+ }
124
+ set vadFramesCallback(callback) {
125
+ this._vadFramesCallback = callback;
126
+ }
114
127
  // Reset store to initial state
115
128
  resetStore() {
116
129
  this._txnID = '';
@@ -119,6 +132,7 @@ class EkaScribeStore {
119
132
  // Clear callbacks
120
133
  this._userSpeechCallback = null;
121
134
  this._eventCallback = null;
135
+ this._vadFramesCallback = null;
122
136
  }
123
137
  }
124
138
  export default EkaScribeStore.getInstance();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eka-care/ekascribe-ts-sdk",
3
- "version": "1.5.19",
3
+ "version": "1.5.21",
4
4
  "main": "dist/index.js",
5
5
  "repository": "git@github.com:eka-care/eka-js-sdk.git",
6
6
  "author": "Sanikagoyal28 <sanikagoyal9@gmail.com>",