@eka-care/ekascribe-ts-sdk 1.5.87 → 1.5.88
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/config/get-voice-api-v2-config-my-templates.js +22 -12
- package/dist/api/config/get-voice-api-v2-config.js +22 -12
- package/dist/api/config/patch-voice-api-v2-config.js +21 -13
- package/dist/api/post-cog-init.js +28 -15
- package/dist/api/post-v1-file-upload.js +38 -28
- package/dist/api/template-sections/delete-v1-template-section.js +37 -27
- package/dist/api/template-sections/get-v1-template-sections.js +37 -27
- package/dist/api/template-sections/patch-v1-template-section.js +46 -36
- package/dist/api/template-sections/post-v1-template-section.js +45 -35
- package/dist/api/templates/cook-v1-medai-ai-create-template.js +35 -25
- package/dist/api/templates/delete-v1-template.js +37 -27
- package/dist/api/templates/get-v1-templates.js +37 -27
- package/dist/api/templates/patch-v1-template.js +44 -33
- package/dist/api/templates/post-convert-transcription-to-template.js +41 -31
- package/dist/api/templates/post-transaction-convert-to-template.js +38 -28
- package/dist/api/templates/post-v1-template.js +43 -33
- package/dist/api/transaction/get-transaction-history.js +20 -9
- package/dist/api/transaction/get-voice-api-v3-status-transcript.js +21 -8
- package/dist/api/transaction/get-voice-api-v3-status.js +21 -8
- package/dist/api/transaction/patch-transaction-status.js +23 -14
- package/dist/api/transaction/patch-voice-api-v3-status.js +22 -12
- package/dist/api/transaction/post-transaction-commit.js +41 -31
- package/dist/api/transaction/post-transaction-init.js +52 -47
- package/dist/api/transaction/post-transaction-stop.js +41 -31
- package/dist/api/upload-audio-with-presigned-url.js +67 -55
- package/dist/audio-chunker/audio-buffer-manager.js +5 -3
- package/dist/audio-chunker/audio-file-manager.js +353 -350
- package/dist/audio-chunker/vad-web.js +116 -97
- package/dist/aws-services/configure-aws.js +5 -2
- package/dist/aws-services/get-files-s3.js +20 -7
- package/dist/aws-services/s3-retry-wrapper.js +44 -31
- package/dist/aws-services/translate-text-to-target-language.js +28 -15
- package/dist/aws-services/upload-file-to-s3.js +17 -6
- package/dist/constants/constant.js +22 -19
- package/dist/constants/enums.js +15 -12
- package/dist/constants/setup-config.js +10 -7
- package/dist/constants/types.js +2 -1
- package/dist/fetch-client/helper.js +24 -11
- package/dist/fetch-client/index.js +61 -52
- package/dist/index.js +321 -254
- package/dist/main/end-recording.js +56 -53
- package/dist/main/init-transaction.js +36 -27
- package/dist/main/pause-recording.js +17 -18
- package/dist/main/poll-output-summary.js +21 -7
- package/dist/main/resume-recording.js +13 -14
- package/dist/main/retry-upload-recording.js +39 -30
- package/dist/main/start-recording.js +34 -26
- package/dist/main/upload-full-audio-with-presigned-url.js +84 -69
- package/dist/shared-worker/s3-file-upload.js +88 -79
- package/dist/store/store.js +3 -1
- package/dist/utils/compress-mp3-audio.js +6 -4
- package/dist/utils/get-worker-url.js +12 -7
- package/dist/utils/search-past-sessions.js +23 -9
- package/package.json +1 -1
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const vad_web_1 = require("@ricky0123/vad-web");
|
|
13
|
+
const constant_1 = require("../constants/constant");
|
|
14
|
+
const store_1 = require("../store/store");
|
|
15
|
+
const enums_1 = require("../constants/enums");
|
|
5
16
|
class VadWebClient {
|
|
6
17
|
/**
|
|
7
18
|
* Class that handle Vad functions and manages audio chunk
|
|
@@ -120,10 +131,10 @@ class VadWebClient {
|
|
|
120
131
|
this.pref_length_samples = pref_length * sr;
|
|
121
132
|
this.desp_length_samples = desp_length * sr;
|
|
122
133
|
this.max_length_samples = max_length * sr;
|
|
123
|
-
this.shor_thsld = SHORT_SILENCE_THRESHOLD * sr;
|
|
124
|
-
this.long_thsld = LONG_SILENCE_THRESHOLD * sr;
|
|
125
|
-
this.frame_size = FRAME_SIZE;
|
|
126
|
-
this.speech_pad_frames = PRE_SPEECH_PAD_FRAMES;
|
|
134
|
+
this.shor_thsld = constant_1.SHORT_SILENCE_THRESHOLD * sr;
|
|
135
|
+
this.long_thsld = constant_1.LONG_SILENCE_THRESHOLD * sr;
|
|
136
|
+
this.frame_size = constant_1.FRAME_SIZE;
|
|
137
|
+
this.speech_pad_frames = constant_1.PRE_SPEECH_PAD_FRAMES;
|
|
127
138
|
this.micVad = {};
|
|
128
139
|
}
|
|
129
140
|
/**
|
|
@@ -134,7 +145,7 @@ class VadWebClient {
|
|
|
134
145
|
if (!this.recording_started)
|
|
135
146
|
return;
|
|
136
147
|
const now = Date.now();
|
|
137
|
-
const onVadCallback =
|
|
148
|
+
const onVadCallback = store_1.default.vadFramesCallback;
|
|
138
149
|
const silenceThreshold = 10000; // 10 seconds
|
|
139
150
|
if (isSpeech === 0) {
|
|
140
151
|
if (this.noSpeechStartTime === null) {
|
|
@@ -150,8 +161,8 @@ class VadWebClient {
|
|
|
150
161
|
if (onVadCallback) {
|
|
151
162
|
onVadCallback({
|
|
152
163
|
message: 'No audio detected for a while. Please talk or stop the recording if done.',
|
|
153
|
-
error_code: ERROR_CODE.NO_AUDIO_CAPTURE,
|
|
154
|
-
status_code: SDK_STATUS_CODE.AUDIO_ERROR,
|
|
164
|
+
error_code: enums_1.ERROR_CODE.NO_AUDIO_CAPTURE,
|
|
165
|
+
status_code: constant_1.SDK_STATUS_CODE.AUDIO_ERROR,
|
|
155
166
|
});
|
|
156
167
|
}
|
|
157
168
|
this.lastWarningTime = now;
|
|
@@ -168,8 +179,8 @@ class VadWebClient {
|
|
|
168
179
|
if (onVadCallback) {
|
|
169
180
|
onVadCallback({
|
|
170
181
|
message: 'Audio captured. Recording continues.',
|
|
171
|
-
error_code: ERROR_CODE.SPEECH_DETECTED,
|
|
172
|
-
status_code: SDK_STATUS_CODE.SUCCESS,
|
|
182
|
+
error_code: enums_1.ERROR_CODE.SPEECH_DETECTED,
|
|
183
|
+
status_code: constant_1.SDK_STATUS_CODE.SUCCESS,
|
|
173
184
|
});
|
|
174
185
|
}
|
|
175
186
|
}
|
|
@@ -234,94 +245,102 @@ class VadWebClient {
|
|
|
234
245
|
/**
|
|
235
246
|
* initialize the VAD instance
|
|
236
247
|
*/
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
vadFrameProcessedCallback
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
248
|
+
initVad() {
|
|
249
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
250
|
+
const audioFileManager = store_1.default.audioFileManagerInstance;
|
|
251
|
+
const audioBuffer = store_1.default.audioBufferInstance;
|
|
252
|
+
this.is_vad_loading = true;
|
|
253
|
+
const vad = yield vad_web_1.MicVAD.new({
|
|
254
|
+
frameSamples: this.frame_size,
|
|
255
|
+
preSpeechPadFrames: this.speech_pad_frames,
|
|
256
|
+
onFrameProcessed: (prob, frames) => {
|
|
257
|
+
// Get callback dynamically to ensure it's always up to date
|
|
258
|
+
const vadFrameProcessedCallback = store_1.default.vadFrameProcessedCallback;
|
|
259
|
+
if (vadFrameProcessedCallback) {
|
|
260
|
+
vadFrameProcessedCallback({ probabilities: prob, frame: frames });
|
|
261
|
+
}
|
|
262
|
+
// Only process frames internally when recording is active
|
|
263
|
+
if (!this.recording_started) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
audioFileManager === null || audioFileManager === void 0 ? void 0 : audioFileManager.incrementTotalRawSamples(frames);
|
|
267
|
+
audioBuffer === null || audioBuffer === void 0 ? void 0 : audioBuffer.append(frames);
|
|
268
|
+
// Check if audio chunk needs to be clipped
|
|
269
|
+
const { isSpeech } = prob;
|
|
270
|
+
let vad_dec = 0;
|
|
271
|
+
if (isSpeech >= 0.5) {
|
|
272
|
+
vad_dec = 1;
|
|
273
|
+
}
|
|
274
|
+
// Call the new checkNoSpeech function
|
|
275
|
+
this.checkNoSpeech(vad_dec);
|
|
276
|
+
const vadResponse = this.processVadFrame(vad_dec);
|
|
277
|
+
const is_clip_point = vadResponse[0];
|
|
278
|
+
if (is_clip_point) {
|
|
279
|
+
// audio chunk is of float32 Array <ArrayBuffer>
|
|
280
|
+
const activeAudioChunk = audioBuffer === null || audioBuffer === void 0 ? void 0 : audioBuffer.getAudioData();
|
|
281
|
+
this.processAudioChunk({ audioFrames: activeAudioChunk });
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
onSpeechStart: () => {
|
|
285
|
+
var _a;
|
|
286
|
+
(_a = store_1.default.userSpeechCallback) === null || _a === void 0 ? void 0 : _a.call(store_1.default, true);
|
|
287
|
+
},
|
|
288
|
+
onSpeechEnd: () => {
|
|
289
|
+
var _a;
|
|
290
|
+
(_a = store_1.default.userSpeechCallback) === null || _a === void 0 ? void 0 : _a.call(store_1.default, false);
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
this.is_vad_loading = false;
|
|
294
|
+
this.micVad = vad;
|
|
295
|
+
return this.is_vad_loading;
|
|
278
296
|
});
|
|
279
|
-
this.is_vad_loading = false;
|
|
280
|
-
this.micVad = vad;
|
|
281
|
-
return this.is_vad_loading;
|
|
282
297
|
}
|
|
283
298
|
/**
|
|
284
299
|
* reinitialize the vad instance
|
|
285
300
|
*/
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
301
|
+
reinitializeVad() {
|
|
302
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
303
|
+
const response = yield this.initVad();
|
|
304
|
+
return response;
|
|
305
|
+
});
|
|
289
306
|
}
|
|
290
307
|
/**
|
|
291
308
|
* process and upload audio chunk to s3
|
|
292
309
|
*/
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
310
|
+
processAudioChunk(_a) {
|
|
311
|
+
return __awaiter(this, arguments, void 0, function* ({ audioFrames }) {
|
|
312
|
+
const audioFileManager = store_1.default.audioFileManagerInstance;
|
|
313
|
+
const audioBuffer = store_1.default.audioBufferInstance;
|
|
314
|
+
if (!audioFrames || !audioFileManager || !audioBuffer)
|
|
315
|
+
return;
|
|
316
|
+
// get the number of chunks already processed
|
|
317
|
+
const filenumber = (audioFileManager.audioChunks.length || 0) + 1;
|
|
318
|
+
const fileName = `${filenumber}.${constant_1.OUTPUT_FORMAT}`;
|
|
319
|
+
const rawSampleDetails = audioFileManager.getRawSampleDetails();
|
|
320
|
+
const chunkTimestamps = audioBuffer === null || audioBuffer === void 0 ? void 0 : audioBuffer.calculateChunkTimestamps(rawSampleDetails.totalRawSamples);
|
|
321
|
+
try {
|
|
322
|
+
const chunkInfo = {
|
|
323
|
+
fileName,
|
|
324
|
+
timestamp: {
|
|
325
|
+
st: chunkTimestamps.start,
|
|
326
|
+
et: chunkTimestamps.end,
|
|
327
|
+
},
|
|
328
|
+
status: 'pending',
|
|
329
|
+
audioFrames,
|
|
330
|
+
};
|
|
331
|
+
const audioChunkLength = audioFileManager.updateAudioInfo(chunkInfo);
|
|
332
|
+
audioFileManager === null || audioFileManager === void 0 ? void 0 : audioFileManager.incrementInsertedSamples(audioBuffer.getCurrentSampleLength(), audioBuffer.getCurrentFrameLength());
|
|
333
|
+
audioBuffer.resetBufferState();
|
|
334
|
+
yield audioFileManager.uploadAudioToS3({
|
|
335
|
+
audioFrames,
|
|
336
|
+
fileName,
|
|
337
|
+
chunkIndex: audioChunkLength - 1,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
catch (error) {
|
|
341
|
+
console.error('Error uploading audio chunk:', error);
|
|
342
|
+
}
|
|
343
|
+
});
|
|
325
344
|
}
|
|
326
345
|
/**
|
|
327
346
|
* Start VAD
|
|
@@ -378,16 +397,16 @@ class VadWebClient {
|
|
|
378
397
|
* monitor initial audio capture within starting 4 seconds
|
|
379
398
|
*/
|
|
380
399
|
monitorAudioCapture() {
|
|
381
|
-
const audioBuffer =
|
|
382
|
-
const onVadCallback =
|
|
400
|
+
const audioBuffer = store_1.default.audioBufferInstance;
|
|
401
|
+
const onVadCallback = store_1.default.vadFramesCallback;
|
|
383
402
|
setTimeout(() => {
|
|
384
403
|
if (audioBuffer && audioBuffer.getCurrentSampleLength() <= 0) {
|
|
385
404
|
this.micVad.pause();
|
|
386
405
|
if (onVadCallback) {
|
|
387
406
|
onVadCallback({
|
|
388
407
|
message: 'No audio is being captured. Please check your microphone.',
|
|
389
|
-
error_code: ERROR_CODE.NO_AUDIO_CAPTURE,
|
|
390
|
-
status_code: SDK_STATUS_CODE.AUDIO_ERROR,
|
|
408
|
+
error_code: enums_1.ERROR_CODE.NO_AUDIO_CAPTURE,
|
|
409
|
+
status_code: constant_1.SDK_STATUS_CODE.AUDIO_ERROR,
|
|
391
410
|
});
|
|
392
411
|
}
|
|
393
412
|
return false;
|
|
@@ -408,4 +427,4 @@ class VadWebClient {
|
|
|
408
427
|
this.speech_pad_frames = pre_speech_pad_frames;
|
|
409
428
|
}
|
|
410
429
|
}
|
|
411
|
-
|
|
430
|
+
exports.default = VadWebClient;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configureAWS = configureAWS;
|
|
4
|
+
const AWS = require("aws-sdk");
|
|
5
|
+
function configureAWS({ accessKeyId, secretKey, sessionToken, }) {
|
|
3
6
|
try {
|
|
4
7
|
AWS.config.update({
|
|
5
8
|
sessionToken,
|
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getFilesS3 = void 0;
|
|
13
|
+
const AWS = require("aws-sdk");
|
|
14
|
+
const s3_retry_wrapper_1 = require("./s3-retry-wrapper");
|
|
15
|
+
const helper_1 = require("../fetch-client/helper");
|
|
16
|
+
const getFilesS3 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ fileName, maxPollingTime, }) {
|
|
5
17
|
try {
|
|
6
18
|
const requestBody = {
|
|
7
|
-
Bucket: GET_S3_BUCKET_NAME(),
|
|
19
|
+
Bucket: (0, helper_1.GET_S3_BUCKET_NAME)(),
|
|
8
20
|
Key: fileName,
|
|
9
21
|
};
|
|
10
22
|
const getFileCall = () => new Promise((resolve, reject) => {
|
|
@@ -19,7 +31,7 @@ export const getFilesS3 = async ({ fileName, maxPollingTime, }) => {
|
|
|
19
31
|
});
|
|
20
32
|
});
|
|
21
33
|
// retry upload with s3RetryWrapper
|
|
22
|
-
const result =
|
|
34
|
+
const result = yield (0, s3_retry_wrapper_1.default)(getFileCall, maxPollingTime, 1000, 0);
|
|
23
35
|
return {
|
|
24
36
|
response: result,
|
|
25
37
|
};
|
|
@@ -28,4 +40,5 @@ export const getFilesS3 = async ({ fileName, maxPollingTime, }) => {
|
|
|
28
40
|
console.error('getFilesS3 =>', error);
|
|
29
41
|
throw error;
|
|
30
42
|
}
|
|
31
|
-
};
|
|
43
|
+
});
|
|
44
|
+
exports.getFilesS3 = getFilesS3;
|
|
@@ -1,38 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const post_cog_init_1 = require("../api/post-cog-init");
|
|
13
|
+
const configure_aws_1 = require("./configure-aws");
|
|
14
|
+
function s3RetryWrapper(s3Fn_1, maxRetryCount_1, delay_1, retryAttempt_1) {
|
|
15
|
+
return __awaiter(this, arguments, void 0, function* (s3Fn, maxRetryCount, delay, retryAttempt, is_shared_worker = false) {
|
|
16
|
+
try {
|
|
17
|
+
return yield s3Fn();
|
|
10
18
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
if (error.statusCode >= 400) {
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (retryAttempt >= maxRetryCount) {
|
|
15
21
|
throw error;
|
|
16
22
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
23
|
+
if (is_shared_worker) {
|
|
24
|
+
// eslint-disable-next-line
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
if (error.statusCode >= 400) {
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// eslint-disable-next-line
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
if (error.code === 'ExpiredToken') {
|
|
34
|
+
const cogResponse = yield (0, post_cog_init_1.default)();
|
|
35
|
+
const { credentials } = cogResponse;
|
|
36
|
+
if (credentials) {
|
|
37
|
+
(0, configure_aws_1.configureAWS)({
|
|
38
|
+
accessKeyId: credentials.AccessKeyId,
|
|
39
|
+
secretKey: credentials.SecretKey,
|
|
40
|
+
sessionToken: credentials.SessionToken,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
30
43
|
}
|
|
31
44
|
}
|
|
45
|
+
yield new Promise((resolve) => setTimeout(resolve, delay));
|
|
46
|
+
// Retry the operation
|
|
47
|
+
return s3RetryWrapper(s3Fn, maxRetryCount, delay, retryAttempt + 1);
|
|
32
48
|
}
|
|
33
|
-
|
|
34
|
-
// Retry the operation
|
|
35
|
-
return s3RetryWrapper(s3Fn, maxRetryCount, delay, retryAttempt + 1);
|
|
36
|
-
}
|
|
49
|
+
});
|
|
37
50
|
}
|
|
38
|
-
|
|
51
|
+
exports.default = s3RetryWrapper;
|
|
@@ -1,17 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const client_translate_1 = require("@aws-sdk/client-translate");
|
|
13
|
+
const translateClient = new client_translate_1.TranslateClient({ region: 'ap-south-1' }); // e.g., "us-east-1"
|
|
14
|
+
function awsTranslateText(_a) {
|
|
15
|
+
return __awaiter(this, arguments, void 0, function* ({ source_language, target_language, content, }) {
|
|
16
|
+
const command = new client_translate_1.TranslateTextCommand({
|
|
17
|
+
SourceLanguageCode: source_language,
|
|
18
|
+
TargetLanguageCode: target_language,
|
|
19
|
+
Text: content,
|
|
20
|
+
});
|
|
21
|
+
try {
|
|
22
|
+
const result = yield translateClient.send(command);
|
|
23
|
+
console.log('Translated text:', result.TranslatedText);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
console.error('Translation error:', error);
|
|
27
|
+
}
|
|
8
28
|
});
|
|
9
|
-
try {
|
|
10
|
-
const result = await translateClient.send(command);
|
|
11
|
-
console.log('Translated text:', result.TranslatedText);
|
|
12
|
-
}
|
|
13
|
-
catch (error) {
|
|
14
|
-
console.error('Translation error:', error);
|
|
15
|
-
}
|
|
16
29
|
}
|
|
17
|
-
|
|
30
|
+
exports.default = awsTranslateText;
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
12
|
// @ts-nocheck
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const pushFileToS3 =
|
|
13
|
+
const AWS = require("aws-sdk");
|
|
14
|
+
const s3_retry_wrapper_1 = require("./s3-retry-wrapper");
|
|
15
|
+
const pushFileToS3 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ s3BucketName, fileBlob, fileName, txnID, businessID, is_shared_worker = false, }) {
|
|
5
16
|
try {
|
|
6
17
|
const requestBody = {
|
|
7
18
|
Bucket: s3BucketName,
|
|
@@ -24,7 +35,7 @@ const pushFileToS3 = async ({ s3BucketName, fileBlob, fileName, txnID, businessI
|
|
|
24
35
|
});
|
|
25
36
|
});
|
|
26
37
|
// retry upload with s3RetryWrapper
|
|
27
|
-
const result =
|
|
38
|
+
const result = yield (0, s3_retry_wrapper_1.default)(uploadCall, 3, 2000, 0, is_shared_worker);
|
|
28
39
|
// Return success with the data
|
|
29
40
|
return { success: result.ETag || 'Upload successful' };
|
|
30
41
|
}
|
|
@@ -43,5 +54,5 @@ const pushFileToS3 = async ({ s3BucketName, fileBlob, fileName, txnID, businessI
|
|
|
43
54
|
code: error.statusCode || error.code,
|
|
44
55
|
};
|
|
45
56
|
}
|
|
46
|
-
};
|
|
47
|
-
|
|
57
|
+
});
|
|
58
|
+
exports.default = pushFileToS3;
|
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SDK_STATUS_CODE = exports.AUDIO_EXTENSION_TYPE_MAP = exports.OUTPUT_FORMAT = exports.AUDIO_BUFFER_SIZE_IN_S = exports.CHANNELS = exports.QUALITY = exports.BITRATE = exports.PRE_SPEECH_PAD_FRAMES = exports.SPEECH_DETECTION_THRESHOLD = exports.LONG_SILENCE_THRESHOLD = exports.SHORT_SILENCE_THRESHOLD = exports.FRAME_RATE = exports.SILENCE_THRESHOLD = exports.DURATION_PER_FRAME = exports.SAMPLING_RATE = exports.FRAME_SIZE = exports.MAX_CHUNK_LENGTH = exports.DESP_CHUNK_LENGTH = exports.PREF_CHUNK_LENGTH = void 0;
|
|
4
|
+
exports.PREF_CHUNK_LENGTH = 10;
|
|
5
|
+
exports.DESP_CHUNK_LENGTH = 20;
|
|
6
|
+
exports.MAX_CHUNK_LENGTH = 25;
|
|
7
|
+
exports.FRAME_SIZE = 1024;
|
|
8
|
+
exports.SAMPLING_RATE = 16000;
|
|
9
|
+
exports.DURATION_PER_FRAME = exports.FRAME_SIZE / exports.SAMPLING_RATE;
|
|
10
|
+
exports.SILENCE_THRESHOLD = 0.01;
|
|
11
|
+
exports.FRAME_RATE = exports.SAMPLING_RATE / exports.FRAME_SIZE;
|
|
12
|
+
exports.SHORT_SILENCE_THRESHOLD = 0.1;
|
|
13
|
+
exports.LONG_SILENCE_THRESHOLD = 0.5;
|
|
14
|
+
exports.SPEECH_DETECTION_THRESHOLD = 0.5;
|
|
12
15
|
// export const REDEMPTION_FRAMES = 10;
|
|
13
|
-
|
|
16
|
+
exports.PRE_SPEECH_PAD_FRAMES = 20;
|
|
14
17
|
// export const MIN_SPEECH_FRAMES = 80;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
exports.BITRATE = 128;
|
|
19
|
+
exports.QUALITY = 0;
|
|
20
|
+
exports.CHANNELS = 1;
|
|
21
|
+
exports.AUDIO_BUFFER_SIZE_IN_S = exports.DESP_CHUNK_LENGTH + 5;
|
|
22
|
+
exports.OUTPUT_FORMAT = 'mp3';
|
|
23
|
+
exports.AUDIO_EXTENSION_TYPE_MAP = {
|
|
21
24
|
m4a: 'audio/m4a',
|
|
22
25
|
wav: 'audio/wav',
|
|
23
26
|
mp3: 'audio/mpeg',
|
|
24
27
|
};
|
|
25
|
-
|
|
28
|
+
exports.SDK_STATUS_CODE = {
|
|
26
29
|
AUDIO_ERROR: 1001,
|
|
27
30
|
SUCCESS: 200,
|
|
28
31
|
TXN_ERROR: 1003,
|
package/dist/constants/enums.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CALLBACK_TYPE = exports.SHARED_WORKER_ACTION = exports.PROCESSING_STATUS = exports.ERROR_CODE = exports.RESULT_STATUS = exports.TEMPLATE_ID = void 0;
|
|
4
|
+
var TEMPLATE_ID;
|
|
2
5
|
(function (TEMPLATE_ID) {
|
|
3
6
|
TEMPLATE_ID["EKA_EMR_TEMPLATE"] = "eka_emr_template";
|
|
4
7
|
TEMPLATE_ID["CLINICAL_NOTE_TEMPLATE"] = "clinical_notes_template";
|
|
5
8
|
TEMPLATE_ID["TRANSCRIPT_TEMPLATE"] = "transcript_template";
|
|
6
9
|
TEMPLATE_ID["EKA_EMR_TO_FHIR_TEMPLATE"] = "eka_emr_to_fhir_template";
|
|
7
10
|
TEMPLATE_ID["NIC_TEMPLATE"] = "nic_template";
|
|
8
|
-
})(TEMPLATE_ID || (TEMPLATE_ID = {}));
|
|
9
|
-
|
|
11
|
+
})(TEMPLATE_ID || (exports.TEMPLATE_ID = TEMPLATE_ID = {}));
|
|
12
|
+
var RESULT_STATUS;
|
|
10
13
|
(function (RESULT_STATUS) {
|
|
11
14
|
RESULT_STATUS["SUCCESS"] = "success";
|
|
12
15
|
RESULT_STATUS["FAILURE"] = "failure";
|
|
13
16
|
RESULT_STATUS["PARTIAL_COMPLETE"] = "partial_complete";
|
|
14
17
|
RESULT_STATUS["IN_PROGRESS"] = "in-progress";
|
|
15
|
-
})(RESULT_STATUS || (RESULT_STATUS = {}));
|
|
16
|
-
|
|
18
|
+
})(RESULT_STATUS || (exports.RESULT_STATUS = RESULT_STATUS = {}));
|
|
19
|
+
var ERROR_CODE;
|
|
17
20
|
(function (ERROR_CODE) {
|
|
18
21
|
ERROR_CODE["MICROPHONE"] = "microphone";
|
|
19
22
|
ERROR_CODE["TXN_INIT_FAILED"] = "txn_init_failed";
|
|
@@ -32,15 +35,15 @@ export var ERROR_CODE;
|
|
|
32
35
|
ERROR_CODE["UPLOAD_FULL_AUDIO"] = "upload_full_audio";
|
|
33
36
|
ERROR_CODE["FETCH_WRAPPER_RESPONSE"] = "fetch_wrapper_response";
|
|
34
37
|
ERROR_CODE["FETCH_WRAPPER_ERROR"] = "fetch_wrapper_error";
|
|
35
|
-
})(ERROR_CODE || (ERROR_CODE = {}));
|
|
36
|
-
|
|
38
|
+
})(ERROR_CODE || (exports.ERROR_CODE = ERROR_CODE = {}));
|
|
39
|
+
var PROCESSING_STATUS;
|
|
37
40
|
(function (PROCESSING_STATUS) {
|
|
38
41
|
PROCESSING_STATUS["SUCCESS"] = "success";
|
|
39
42
|
PROCESSING_STATUS["IN_PROGRESS"] = "in-progress";
|
|
40
43
|
PROCESSING_STATUS["FAILED"] = "failed";
|
|
41
44
|
PROCESSING_STATUS["CANCELLED"] = "cancelled";
|
|
42
|
-
})(PROCESSING_STATUS || (PROCESSING_STATUS = {}));
|
|
43
|
-
|
|
45
|
+
})(PROCESSING_STATUS || (exports.PROCESSING_STATUS = PROCESSING_STATUS = {}));
|
|
46
|
+
var SHARED_WORKER_ACTION;
|
|
44
47
|
(function (SHARED_WORKER_ACTION) {
|
|
45
48
|
SHARED_WORKER_ACTION["UPLOAD_FILE_WITH_WORKER"] = "upload_file_with_worker";
|
|
46
49
|
SHARED_WORKER_ACTION["UPLOAD_FILE_WITH_WORKER_SUCCESS"] = "upload_file_with_worker_success";
|
|
@@ -52,8 +55,8 @@ export var SHARED_WORKER_ACTION;
|
|
|
52
55
|
SHARED_WORKER_ACTION["WAIT_FOR_ALL_UPLOADS"] = "wait_for_all_uploads";
|
|
53
56
|
SHARED_WORKER_ACTION["WAIT_FOR_ALL_UPLOADS_SUCCESS"] = "wait_for_all_uploads_success";
|
|
54
57
|
SHARED_WORKER_ACTION["WAIT_FOR_ALL_UPLOADS_ERROR"] = "wait_for_all_uploads_error";
|
|
55
|
-
})(SHARED_WORKER_ACTION || (SHARED_WORKER_ACTION = {}));
|
|
56
|
-
|
|
58
|
+
})(SHARED_WORKER_ACTION || (exports.SHARED_WORKER_ACTION = SHARED_WORKER_ACTION = {}));
|
|
59
|
+
var CALLBACK_TYPE;
|
|
57
60
|
(function (CALLBACK_TYPE) {
|
|
58
61
|
CALLBACK_TYPE["AWS_CONFIGURE_STATUS"] = "aws_configure_status";
|
|
59
62
|
CALLBACK_TYPE["FILE_UPLOAD_STATUS"] = "file_upload_status";
|
|
@@ -62,4 +65,4 @@ export var CALLBACK_TYPE;
|
|
|
62
65
|
CALLBACK_TYPE["AUTHENTICATION_STATUS"] = "authentication_status";
|
|
63
66
|
CALLBACK_TYPE["NETWORK_STATUS"] = "network_status";
|
|
64
67
|
CALLBACK_TYPE["STORAGE_STATUS"] = "storage_status";
|
|
65
|
-
})(CALLBACK_TYPE || (CALLBACK_TYPE = {}));
|
|
68
|
+
})(CALLBACK_TYPE || (exports.CALLBACK_TYPE = CALLBACK_TYPE = {}));
|