@eka-care/ekascribe-ts-sdk 1.4.55 → 1.4.57
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/api/upload-audio-with-presigned-url.js +0 -1
- package/dist/audio-chunker/audio-file-manager.js +0 -2
- package/dist/aws-services/translate-text-to-target-language.js +0 -1
- package/dist/fetch-client/index.js +0 -4
- package/dist/index.js +4 -16
- package/dist/main/end-recording.js +0 -1
- package/dist/main/init-transaction.js +1 -1
- package/dist/main/pause-recording.js +0 -1
- package/dist/main/resume-recording.js +0 -1
- package/dist/main/retry-upload-recording.js +0 -1
- package/dist/main/start-recording.js +0 -4
- package/dist/main/upload-full-audio-with-presigned-url.js +0 -3
- package/package.json +1 -1
|
@@ -14,7 +14,6 @@ async function uploadSingleFile(uploadData, folderPath, file, fileName) {
|
|
|
14
14
|
method: 'POST',
|
|
15
15
|
body: formData,
|
|
16
16
|
});
|
|
17
|
-
console.log('upload single audio file response ', response);
|
|
18
17
|
if (response.status === 204) {
|
|
19
18
|
// S3 returns 204 No Content on successful upload
|
|
20
19
|
return {
|
|
@@ -150,11 +150,9 @@ class AudioFileManager {
|
|
|
150
150
|
const workerResponse = event.data;
|
|
151
151
|
switch (workerResponse.action) {
|
|
152
152
|
case SHARED_WORKER_ACTION.CONFIGURE_AWS_SUCCESS: {
|
|
153
|
-
console.log('AWS configured successfully in worker');
|
|
154
153
|
return;
|
|
155
154
|
}
|
|
156
155
|
case SHARED_WORKER_ACTION.CONFIGURE_AWS_ERROR: {
|
|
157
|
-
console.error('Error configuring AWS in worker:', workerResponse.error);
|
|
158
156
|
return;
|
|
159
157
|
}
|
|
160
158
|
case SHARED_WORKER_ACTION.UPLOAD_FILE_WITH_WORKER_SUCCESS: {
|
|
@@ -10,7 +10,6 @@ export default async function fetchWrapper(url, options = {}, timeoutMs = API_TI
|
|
|
10
10
|
try {
|
|
11
11
|
// Set up timeout
|
|
12
12
|
timeoutId = setTimeout(() => {
|
|
13
|
-
console.log('request aborted due to timeout');
|
|
14
13
|
controller.abort();
|
|
15
14
|
}, timeoutMs);
|
|
16
15
|
const newHeaders = new Headers(options.headers);
|
|
@@ -34,9 +33,6 @@ export default async function fetchWrapper(url, options = {}, timeoutMs = API_TI
|
|
|
34
33
|
request: 'Request body: ' + JSON.stringify(options.body),
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
|
-
if (response.status === 401 || response.status === 403) {
|
|
38
|
-
console.log('unauthorized - fetch wrapper - SDK', response.status);
|
|
39
|
-
}
|
|
40
36
|
return response;
|
|
41
37
|
}
|
|
42
38
|
catch (error) {
|
package/dist/index.js
CHANGED
|
@@ -52,14 +52,12 @@ class EkaScribe {
|
|
|
52
52
|
value: void 0
|
|
53
53
|
});
|
|
54
54
|
this.audioFileManagerInstance = new AudioFileManager();
|
|
55
|
-
console.log('%c Line:48 🥕 this.audioFileManagerInstance', 'color:#b03734', this.audioFileManagerInstance);
|
|
56
55
|
EkaScribeStore.audioFileManagerInstance = this.audioFileManagerInstance;
|
|
57
56
|
this.audioBufferInstance = new AudioBufferManager(SAMPLING_RATE, AUDIO_BUFFER_SIZE_IN_S);
|
|
58
|
-
console.log('%c Line:50 🍇 this.audioBufferInstance', 'color:#fca650', this.audioBufferInstance);
|
|
59
57
|
EkaScribeStore.audioBufferInstance = this.audioBufferInstance;
|
|
60
58
|
this.vadInstance = new VadWebClient(PREF_CHUNK_LENGTH, DESP_CHUNK_LENGTH, MAX_CHUNK_LENGTH, FRAME_RATE);
|
|
61
59
|
EkaScribeStore.vadInstance = this.vadInstance;
|
|
62
|
-
console.log('
|
|
60
|
+
console.log('Initialising SDK: ', this.audioFileManagerInstance, this.audioBufferInstance, this.vadInstance);
|
|
63
61
|
}
|
|
64
62
|
// Static method to get the singleton instance with optional initialization
|
|
65
63
|
static getInstance({ access_token, env, clientId, }) {
|
|
@@ -70,9 +68,8 @@ class EkaScribe {
|
|
|
70
68
|
});
|
|
71
69
|
if (!EkaScribe.instance) {
|
|
72
70
|
EkaScribe.instance = new EkaScribe();
|
|
73
|
-
console.log('EkaScribe.instance', EkaScribe.instance);
|
|
74
|
-
// Initialize if params are provided
|
|
75
71
|
}
|
|
72
|
+
console.log('EkaScribe.instance', EkaScribe.instance);
|
|
76
73
|
return EkaScribe.instance;
|
|
77
74
|
}
|
|
78
75
|
// Method to reset the singleton instance (useful for testing)
|
|
@@ -80,7 +77,6 @@ class EkaScribe {
|
|
|
80
77
|
EkaScribe.instance = null;
|
|
81
78
|
}
|
|
82
79
|
async getEkascribeConfig() {
|
|
83
|
-
console.log('Fetching EkaScribe configuration...');
|
|
84
80
|
const response = await getConfigV2();
|
|
85
81
|
return response;
|
|
86
82
|
}
|
|
@@ -90,13 +86,11 @@ class EkaScribe {
|
|
|
90
86
|
});
|
|
91
87
|
}
|
|
92
88
|
async initTransaction(request) {
|
|
93
|
-
console.log('Initializing transaction...');
|
|
94
89
|
const initTransactionResponse = await initialiseTransaction(request);
|
|
95
90
|
console.log(initTransactionResponse, 'initTransactionResponse');
|
|
96
91
|
return initTransactionResponse;
|
|
97
92
|
}
|
|
98
93
|
async startRecording() {
|
|
99
|
-
console.log('Starting recording...');
|
|
100
94
|
const startResponse = await startVoiceRecording();
|
|
101
95
|
console.log('%c Line:110 🍓 startResponse', 'color:#465975', startResponse);
|
|
102
96
|
return startResponse;
|
|
@@ -108,25 +102,21 @@ class EkaScribe {
|
|
|
108
102
|
this.vadInstance.destroyVad();
|
|
109
103
|
}
|
|
110
104
|
pauseRecording() {
|
|
111
|
-
console.log('Pausing recording...');
|
|
112
105
|
const pauseRecordingResponse = pauseVoiceRecording();
|
|
113
106
|
console.log('%c Line:117 🍌 pauseRecordingResponse', 'color:#6ec1c2', pauseRecordingResponse);
|
|
114
107
|
return pauseRecordingResponse;
|
|
115
108
|
}
|
|
116
109
|
resumeRecording() {
|
|
117
|
-
console.log('Resuming recording...');
|
|
118
110
|
const resumeRecordingResponse = resumeVoiceRecording();
|
|
119
111
|
console.log('%c Line:124 🌶 resumeRecordingResponse', 'color:#33a5ff', resumeRecordingResponse);
|
|
120
112
|
return resumeRecordingResponse;
|
|
121
113
|
}
|
|
122
114
|
async endRecording() {
|
|
123
|
-
console.log('Ending recording...');
|
|
124
115
|
const endRecordingResponse = await endVoiceRecording();
|
|
125
116
|
console.log('%c Line:131 🍅 endRecordingResponse', 'color:#e41a6a', endRecordingResponse);
|
|
126
117
|
return endRecordingResponse;
|
|
127
118
|
}
|
|
128
119
|
async retryUploadRecording({ force_commit }) {
|
|
129
|
-
console.log('Retrying upload for failed files...');
|
|
130
120
|
const retryUploadResponse = await retryUploadFailedFiles({ force_commit });
|
|
131
121
|
console.log('%c Line:138 🍖 retryUploadResponse', 'color:#3f7cff', retryUploadResponse);
|
|
132
122
|
return retryUploadResponse;
|
|
@@ -142,7 +132,6 @@ class EkaScribe {
|
|
|
142
132
|
return patchTransactionResponse;
|
|
143
133
|
}
|
|
144
134
|
catch (error) {
|
|
145
|
-
console.error('Error cancelling recording session:', error);
|
|
146
135
|
return {
|
|
147
136
|
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
148
137
|
message: `Failed to cancel recording session, ${error}`,
|
|
@@ -192,7 +181,6 @@ class EkaScribe {
|
|
|
192
181
|
};
|
|
193
182
|
}
|
|
194
183
|
catch (error) {
|
|
195
|
-
console.error('Error in transaction commit: ', error);
|
|
196
184
|
return {
|
|
197
185
|
error_code: ERROR_CODE.INTERNAL_SERVER_ERROR,
|
|
198
186
|
status_code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
@@ -213,7 +201,6 @@ class EkaScribe {
|
|
|
213
201
|
return getStatusResponse;
|
|
214
202
|
}
|
|
215
203
|
catch (error) {
|
|
216
|
-
console.error('Error in fetching templates response: ', error);
|
|
217
204
|
return {
|
|
218
205
|
status_code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
219
206
|
message: `Failed to fetch output templates, ${error}`,
|
|
@@ -228,7 +215,6 @@ class EkaScribe {
|
|
|
228
215
|
return transactionsResponse;
|
|
229
216
|
}
|
|
230
217
|
catch (error) {
|
|
231
|
-
console.error('Error cancelling recording session:', error);
|
|
232
218
|
return {
|
|
233
219
|
status_code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
234
220
|
message: `Failed to fetch previous transactions, ${error}`,
|
|
@@ -245,10 +231,12 @@ class EkaScribe {
|
|
|
245
231
|
return this.audioFileManagerInstance.getTotalAudioChunks();
|
|
246
232
|
}
|
|
247
233
|
resetEkaScribe() {
|
|
234
|
+
console.log(this.audioFileManagerInstance, this.audioBufferInstance, this.vadInstance, EkaScribeStore, 'before reset ekascribe');
|
|
248
235
|
this.audioFileManagerInstance.resetFileManagerInstance();
|
|
249
236
|
this.audioBufferInstance.resetBufferManagerInstance();
|
|
250
237
|
this.vadInstance.resetVadWebInstance();
|
|
251
238
|
EkaScribeStore.resetStore();
|
|
239
|
+
console.log(this.audioFileManagerInstance, this.audioBufferInstance, this.vadInstance, EkaScribeStore, 'after reset ekascribe');
|
|
252
240
|
}
|
|
253
241
|
onError(callback) {
|
|
254
242
|
EkaScribeStore.errorCallback = callback;
|
|
@@ -94,7 +94,6 @@ const endVoiceRecording = async () => {
|
|
|
94
94
|
total_audio_files: audioFiles,
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
console.log(audioFiles, 'audio files in commit api call, end recording - SDK');
|
|
98
97
|
// call commit transaction api
|
|
99
98
|
if (EkaScribeStore.sessionStatus[txnID].api?.status === 'stop' ||
|
|
100
99
|
EkaScribeStore.sessionStatus[txnID].api?.status === 'commit') {
|
|
@@ -68,7 +68,7 @@ const initialiseTransaction = async (request) => {
|
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
catch (err) {
|
|
71
|
-
console.
|
|
71
|
+
console.error('%c Line:102 🍇 initialiseTransaction err', 'color:#b03734', err);
|
|
72
72
|
return {
|
|
73
73
|
error_code: ERROR_CODE.INTERNAL_SERVER_ERROR,
|
|
74
74
|
status_code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
@@ -9,7 +9,6 @@ const pauseVoiceRecording = () => {
|
|
|
9
9
|
if (!fileManagerInstance || !audioBufferInstance || !vadInstance) {
|
|
10
10
|
throw new Error('Class instances are not initialized');
|
|
11
11
|
}
|
|
12
|
-
console.log(vadInstance, 'vad in pause recording');
|
|
13
12
|
vadInstance.pauseVad();
|
|
14
13
|
const txn_id = EkaScribeStore.txnID;
|
|
15
14
|
EkaScribeStore.sessionStatus[txn_id] = {
|
|
@@ -7,7 +7,6 @@ const resumeVoiceRecording = () => {
|
|
|
7
7
|
if (!vadInstance) {
|
|
8
8
|
throw new Error('VAD instance is not initialized');
|
|
9
9
|
}
|
|
10
|
-
console.log(vadInstance, 'vad in resume recording');
|
|
11
10
|
vadInstance.startVad();
|
|
12
11
|
const txn_id = EkaScribeStore.txnID;
|
|
13
12
|
EkaScribeStore.sessionStatus[txn_id] = {
|
|
@@ -11,7 +11,6 @@ const retryUploadFailedFiles = async ({ force_commit, }) => {
|
|
|
11
11
|
const failedFiles = (await fileManagerInstance.retryFailedUploads()) || [];
|
|
12
12
|
const audioInfo = fileManagerInstance?.audioChunks;
|
|
13
13
|
const audioFiles = audioInfo.map((audio) => audio.fileName);
|
|
14
|
-
console.log(failedFiles, 'failed files in retry upload recording - SDK');
|
|
15
14
|
if (failedFiles.length > 0 && !force_commit) {
|
|
16
15
|
return {
|
|
17
16
|
error_code: ERROR_CODE.AUDIO_UPLOAD_FAILED,
|
|
@@ -15,15 +15,11 @@ const startVoiceRecording = async () => {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
await vadInstance?.initVad();
|
|
18
|
-
console.log(vadInstance, 'vad in start recording');
|
|
19
18
|
const micVad = vadInstance?.getMicVad();
|
|
20
|
-
console.log(micVad, 'mic vad in start recording');
|
|
21
19
|
const isVadLoading = vadInstance?.isVadLoading();
|
|
22
|
-
console.log(isVadLoading, 'is vad loading in start recording');
|
|
23
20
|
if (isVadLoading || !micVad || Object.keys(micVad).length === 0) {
|
|
24
21
|
// retry initiating vad once and if still is in loading return error
|
|
25
22
|
const reinitializeVadResponse = await vadInstance?.reinitializeVad();
|
|
26
|
-
console.log(reinitializeVadResponse, 'reinitialize vad response');
|
|
27
23
|
if (reinitializeVadResponse) {
|
|
28
24
|
return {
|
|
29
25
|
error_code: ERROR_CODE.VAD_NOT_INITIALIZED,
|
|
@@ -7,7 +7,6 @@ export async function postV1UploadAudioFiles({ audioFiles, audioFileNames, txn_i
|
|
|
7
7
|
try {
|
|
8
8
|
// Step 1: Get presigned URL
|
|
9
9
|
const presignedUrlResponse = await postV1FileUpload({ txn_id, action });
|
|
10
|
-
console.log('upload full audio -> presignedUrlResponse ', presignedUrlResponse);
|
|
11
10
|
if (presignedUrlResponse.code !== 200) {
|
|
12
11
|
return {
|
|
13
12
|
error_code: ERROR_CODE.GET_PRESIGNED_URL_FAILED,
|
|
@@ -21,7 +20,6 @@ export async function postV1UploadAudioFiles({ audioFiles, audioFileNames, txn_i
|
|
|
21
20
|
audioFileNames,
|
|
22
21
|
presignedUrlResponse,
|
|
23
22
|
});
|
|
24
|
-
console.log('upload full audio -> uploadResponse ', uploadResponse);
|
|
25
23
|
if (uploadResponse.code !== 200) {
|
|
26
24
|
return {
|
|
27
25
|
error_code: ERROR_CODE.AUDIO_UPLOAD_FAILED,
|
|
@@ -46,7 +44,6 @@ export async function postV1UploadAudioFiles({ audioFiles, audioFileNames, txn_i
|
|
|
46
44
|
batch_s3_url,
|
|
47
45
|
audio_file_names: audioFileNames,
|
|
48
46
|
});
|
|
49
|
-
console.log('upload full audio -> initTransactionResponse ', initTransactionResponse);
|
|
50
47
|
if (initTransactionResponse.code >= 400) {
|
|
51
48
|
return {
|
|
52
49
|
error_code: ERROR_CODE.TXN_INIT_FAILED,
|