@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
package/dist/index.js
CHANGED
|
@@ -1,40 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// ekascribe main Class having all the methods - Entry point
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.getEkaScribeInstance = void 0;
|
|
14
|
+
const get_voice_api_v2_config_1 = require("./api/config/get-voice-api-v2-config");
|
|
15
|
+
const get_voice_api_v3_status_1 = require("./api/transaction/get-voice-api-v3-status");
|
|
16
|
+
const patch_transaction_status_1 = require("./api/transaction/patch-transaction-status");
|
|
17
|
+
const post_transaction_commit_1 = require("./api/transaction/post-transaction-commit");
|
|
18
|
+
const audio_buffer_manager_1 = require("./audio-chunker/audio-buffer-manager");
|
|
19
|
+
const audio_file_manager_1 = require("./audio-chunker/audio-file-manager");
|
|
20
|
+
const vad_web_1 = require("./audio-chunker/vad-web");
|
|
21
|
+
const constant_1 = require("./constants/constant");
|
|
22
|
+
const enums_1 = require("./constants/enums");
|
|
23
|
+
const helper_1 = require("./fetch-client/helper");
|
|
24
|
+
const end_recording_1 = require("./main/end-recording");
|
|
25
|
+
const pause_recording_1 = require("./main/pause-recording");
|
|
26
|
+
const resume_recording_1 = require("./main/resume-recording");
|
|
27
|
+
const retry_upload_recording_1 = require("./main/retry-upload-recording");
|
|
28
|
+
const start_recording_1 = require("./main/start-recording");
|
|
29
|
+
const store_1 = require("./store/store");
|
|
30
|
+
const init_transaction_1 = require("./main/init-transaction");
|
|
31
|
+
const get_transaction_history_1 = require("./api/transaction/get-transaction-history");
|
|
32
|
+
const get_v1_templates_1 = require("./api/templates/get-v1-templates");
|
|
33
|
+
const post_v1_template_1 = require("./api/templates/post-v1-template");
|
|
34
|
+
const patch_v1_template_1 = require("./api/templates/patch-v1-template");
|
|
35
|
+
const delete_v1_template_1 = require("./api/templates/delete-v1-template");
|
|
36
|
+
const get_v1_template_sections_1 = require("./api/template-sections/get-v1-template-sections");
|
|
37
|
+
const post_v1_template_section_1 = require("./api/template-sections/post-v1-template-section");
|
|
38
|
+
const patch_v1_template_section_1 = require("./api/template-sections/patch-v1-template-section");
|
|
39
|
+
const delete_v1_template_section_1 = require("./api/template-sections/delete-v1-template-section");
|
|
40
|
+
const cook_v1_medai_ai_create_template_1 = require("./api/templates/cook-v1-medai-ai-create-template");
|
|
41
|
+
const post_transaction_convert_to_template_1 = require("./api/templates/post-transaction-convert-to-template");
|
|
42
|
+
const upload_full_audio_with_presigned_url_1 = require("./main/upload-full-audio-with-presigned-url");
|
|
43
|
+
const patch_voice_api_v3_status_1 = require("./api/transaction/patch-voice-api-v3-status");
|
|
44
|
+
const search_past_sessions_1 = require("./utils/search-past-sessions");
|
|
45
|
+
const get_voice_api_v2_config_my_templates_1 = require("./api/config/get-voice-api-v2-config-my-templates");
|
|
46
|
+
const patch_voice_api_v2_config_1 = require("./api/config/patch-voice-api-v2-config");
|
|
47
|
+
const post_convert_transcription_to_template_1 = require("./api/templates/post-convert-transcription-to-template");
|
|
48
|
+
const get_voice_api_v3_status_transcript_1 = require("./api/transaction/get-voice-api-v3-status-transcript");
|
|
49
|
+
const poll_output_summary_1 = require("./main/poll-output-summary");
|
|
38
50
|
class EkaScribe {
|
|
39
51
|
// Private constructor to prevent direct instantiation
|
|
40
52
|
constructor() {
|
|
@@ -56,21 +68,17 @@ class EkaScribe {
|
|
|
56
68
|
writable: true,
|
|
57
69
|
value: void 0
|
|
58
70
|
});
|
|
59
|
-
this.audioFileManagerInstance = new
|
|
60
|
-
|
|
61
|
-
this.audioBufferInstance = new
|
|
62
|
-
|
|
63
|
-
this.vadInstance = new
|
|
64
|
-
|
|
71
|
+
this.audioFileManagerInstance = new audio_file_manager_1.default();
|
|
72
|
+
store_1.default.audioFileManagerInstance = this.audioFileManagerInstance;
|
|
73
|
+
this.audioBufferInstance = new audio_buffer_manager_1.default(constant_1.SAMPLING_RATE, constant_1.AUDIO_BUFFER_SIZE_IN_S);
|
|
74
|
+
store_1.default.audioBufferInstance = this.audioBufferInstance;
|
|
75
|
+
this.vadInstance = new vad_web_1.default(constant_1.PREF_CHUNK_LENGTH, constant_1.DESP_CHUNK_LENGTH, constant_1.MAX_CHUNK_LENGTH, constant_1.FRAME_RATE);
|
|
76
|
+
store_1.default.vadInstance = this.vadInstance;
|
|
65
77
|
console.log('Initialising SDK: ', this.audioFileManagerInstance, this.audioBufferInstance, this.vadInstance);
|
|
66
78
|
}
|
|
67
79
|
// Static method to get the singleton instance with optional initialization
|
|
68
80
|
static getInstance({ access_token, env, clientId, }) {
|
|
69
|
-
|
|
70
|
-
...(access_token ? { auth_token: access_token } : {}),
|
|
71
|
-
...(env ? { env } : {}),
|
|
72
|
-
...(clientId ? { clientId } : {}),
|
|
73
|
-
});
|
|
81
|
+
(0, helper_1.default)(Object.assign(Object.assign(Object.assign({}, (access_token ? { auth_token: access_token } : {})), (env ? { env } : {})), (clientId ? { clientId } : {})));
|
|
74
82
|
if (!EkaScribe.instance) {
|
|
75
83
|
EkaScribe.instance = new EkaScribe();
|
|
76
84
|
}
|
|
@@ -80,24 +88,30 @@ class EkaScribe {
|
|
|
80
88
|
static resetInstance() {
|
|
81
89
|
EkaScribe.instance = null;
|
|
82
90
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
getEkascribeConfig() {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
const response = yield (0, get_voice_api_v2_config_1.getConfigV2)();
|
|
94
|
+
return response;
|
|
95
|
+
});
|
|
86
96
|
}
|
|
87
97
|
updateAuthTokens({ access_token }) {
|
|
88
|
-
|
|
98
|
+
(0, helper_1.default)({
|
|
89
99
|
auth_token: access_token,
|
|
90
100
|
});
|
|
91
101
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
102
|
+
initTransaction(request) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
const initTransactionResponse = yield (0, init_transaction_1.default)(request);
|
|
105
|
+
console.log(initTransactionResponse, 'initTransactionResponse');
|
|
106
|
+
return initTransactionResponse;
|
|
107
|
+
});
|
|
96
108
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
109
|
+
startRecording() {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const startResponse = yield (0, start_recording_1.default)();
|
|
112
|
+
console.log('%c Line:110 🍓 startResponse', 'color:#465975', startResponse);
|
|
113
|
+
return startResponse;
|
|
114
|
+
});
|
|
101
115
|
}
|
|
102
116
|
reinitializeVad() {
|
|
103
117
|
this.vadInstance.reinitializeVad();
|
|
@@ -109,166 +123,182 @@ class EkaScribe {
|
|
|
109
123
|
this.vadInstance.pauseVad();
|
|
110
124
|
}
|
|
111
125
|
pauseRecording() {
|
|
112
|
-
const pauseRecordingResponse =
|
|
126
|
+
const pauseRecordingResponse = (0, pause_recording_1.default)();
|
|
113
127
|
console.log('%c Line:117 🍌 pauseRecordingResponse', 'color:#6ec1c2', pauseRecordingResponse);
|
|
114
128
|
return pauseRecordingResponse;
|
|
115
129
|
}
|
|
116
130
|
resumeRecording() {
|
|
117
|
-
const resumeRecordingResponse =
|
|
131
|
+
const resumeRecordingResponse = (0, resume_recording_1.default)();
|
|
118
132
|
console.log('%c Line:124 🌶 resumeRecordingResponse', 'color:#33a5ff', resumeRecordingResponse);
|
|
119
133
|
return resumeRecordingResponse;
|
|
120
134
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const retryUploadResponse = await retryUploadFailedFiles({ force_commit });
|
|
128
|
-
console.log('%c Line:138 🍖 retryUploadResponse', 'color:#3f7cff', retryUploadResponse);
|
|
129
|
-
return retryUploadResponse;
|
|
130
|
-
}
|
|
131
|
-
async patchSessionStatus({ sessionId, processing_status, processing_error, }) {
|
|
132
|
-
try {
|
|
133
|
-
const onEventCallback = EkaScribeStore.eventCallback;
|
|
134
|
-
console.log('mic vad', this.vadInstance.getMicVad());
|
|
135
|
-
this.vadInstance.pauseVad();
|
|
136
|
-
console.log('mic vad paused', this.vadInstance.getMicVad());
|
|
137
|
-
const patchTransactionResponse = await patchTransactionStatus({
|
|
138
|
-
sessionId,
|
|
139
|
-
processing_status,
|
|
140
|
-
processing_error,
|
|
141
|
-
});
|
|
142
|
-
if (onEventCallback) {
|
|
143
|
-
onEventCallback({
|
|
144
|
-
callback_type: CALLBACK_TYPE.TRANSACTION_STATUS,
|
|
145
|
-
status: 'info',
|
|
146
|
-
message: `Transaction cancel status: ${patchTransactionResponse.code}`,
|
|
147
|
-
timestamp: new Date().toISOString(),
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
this.resetEkaScribe();
|
|
151
|
-
return patchTransactionResponse;
|
|
152
|
-
}
|
|
153
|
-
catch (error) {
|
|
154
|
-
return {
|
|
155
|
-
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
156
|
-
message: `Failed to cancel recording session, ${error}`,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
135
|
+
endRecording() {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
const endRecordingResponse = yield (0, end_recording_1.default)();
|
|
138
|
+
console.log('%c Line:131 🍅 endRecordingResponse', 'color:#e41a6a', endRecordingResponse);
|
|
139
|
+
return endRecordingResponse;
|
|
140
|
+
});
|
|
159
141
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
142
|
+
retryUploadRecording(_a) {
|
|
143
|
+
return __awaiter(this, arguments, void 0, function* ({ force_commit }) {
|
|
144
|
+
const retryUploadResponse = yield (0, retry_upload_recording_1.default)({ force_commit });
|
|
145
|
+
console.log('%c Line:138 🍖 retryUploadResponse', 'color:#3f7cff', retryUploadResponse);
|
|
146
|
+
return retryUploadResponse;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
patchSessionStatus(_a) {
|
|
150
|
+
return __awaiter(this, arguments, void 0, function* ({ sessionId, processing_status, processing_error, }) {
|
|
151
|
+
try {
|
|
152
|
+
const onEventCallback = store_1.default.eventCallback;
|
|
153
|
+
console.log('mic vad', this.vadInstance.getMicVad());
|
|
154
|
+
this.vadInstance.pauseVad();
|
|
155
|
+
console.log('mic vad paused', this.vadInstance.getMicVad());
|
|
156
|
+
const patchTransactionResponse = yield (0, patch_transaction_status_1.default)({
|
|
157
|
+
sessionId,
|
|
158
|
+
processing_status,
|
|
159
|
+
processing_error,
|
|
172
160
|
});
|
|
173
|
-
txnCommitMsg = message;
|
|
174
161
|
if (onEventCallback) {
|
|
175
162
|
onEventCallback({
|
|
176
|
-
callback_type: CALLBACK_TYPE.TRANSACTION_STATUS,
|
|
163
|
+
callback_type: enums_1.CALLBACK_TYPE.TRANSACTION_STATUS,
|
|
177
164
|
status: 'info',
|
|
178
|
-
message: `Transaction
|
|
165
|
+
message: `Transaction cancel status: ${patchTransactionResponse.code}`,
|
|
179
166
|
timestamp: new Date().toISOString(),
|
|
180
|
-
data: {
|
|
181
|
-
request: audioFiles,
|
|
182
|
-
},
|
|
183
167
|
});
|
|
184
168
|
}
|
|
185
|
-
|
|
169
|
+
this.resetEkaScribe();
|
|
170
|
+
return patchTransactionResponse;
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
return {
|
|
174
|
+
code: constant_1.SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
175
|
+
message: `Failed to cancel recording session, ${error}`,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
commitTransactionCall() {
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
var _a, _b, _c;
|
|
183
|
+
try {
|
|
184
|
+
const txnID = store_1.default.txnID;
|
|
185
|
+
const onEventCallback = store_1.default.eventCallback;
|
|
186
|
+
let txnCommitMsg = '';
|
|
187
|
+
if (((_a = store_1.default.sessionStatus[txnID].api) === null || _a === void 0 ? void 0 : _a.status) === 'stop' ||
|
|
188
|
+
((_b = store_1.default.sessionStatus[txnID].api) === null || _b === void 0 ? void 0 : _b.status) === 'commit') {
|
|
189
|
+
const audioInfo = (_c = this.audioFileManagerInstance) === null || _c === void 0 ? void 0 : _c.audioChunks;
|
|
190
|
+
const audioFiles = audioInfo.map((audio) => audio.fileName);
|
|
191
|
+
const { message, code: txnCommitStatusCode } = yield (0, post_transaction_commit_1.default)({
|
|
192
|
+
audioFiles,
|
|
193
|
+
txnId: store_1.default.txnID,
|
|
194
|
+
});
|
|
195
|
+
txnCommitMsg = message;
|
|
196
|
+
if (onEventCallback) {
|
|
197
|
+
onEventCallback({
|
|
198
|
+
callback_type: enums_1.CALLBACK_TYPE.TRANSACTION_STATUS,
|
|
199
|
+
status: 'info',
|
|
200
|
+
message: `Transaction commit status: ${txnCommitStatusCode}`,
|
|
201
|
+
timestamp: new Date().toISOString(),
|
|
202
|
+
data: {
|
|
203
|
+
request: audioFiles,
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
if (txnCommitStatusCode != 200) {
|
|
208
|
+
return {
|
|
209
|
+
error_code: enums_1.ERROR_CODE.TXN_COMMIT_FAILED,
|
|
210
|
+
status_code: txnCommitStatusCode,
|
|
211
|
+
message: txnCommitMsg || 'Transaction commit failed.',
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
store_1.default.sessionStatus[txnID] = Object.assign(Object.assign({}, store_1.default.sessionStatus[txnID]), { api: {
|
|
215
|
+
status: 'commit',
|
|
216
|
+
code: txnCommitStatusCode,
|
|
217
|
+
response: txnCommitMsg,
|
|
218
|
+
} });
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
// transaction is not stopped or committed
|
|
186
222
|
return {
|
|
187
|
-
error_code: ERROR_CODE.
|
|
188
|
-
status_code:
|
|
189
|
-
message:
|
|
223
|
+
error_code: enums_1.ERROR_CODE.TXN_STATUS_MISMATCH,
|
|
224
|
+
status_code: constant_1.SDK_STATUS_CODE.TXN_ERROR,
|
|
225
|
+
message: 'Transaction is not initialised or stopped. Cannot end recording.',
|
|
190
226
|
};
|
|
191
227
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
status: 'commit',
|
|
196
|
-
code: txnCommitStatusCode,
|
|
197
|
-
response: txnCommitMsg,
|
|
198
|
-
},
|
|
228
|
+
return {
|
|
229
|
+
status_code: constant_1.SDK_STATUS_CODE.SUCCESS,
|
|
230
|
+
message: txnCommitMsg || 'Transaction committed successfully.',
|
|
199
231
|
};
|
|
200
232
|
}
|
|
201
|
-
|
|
202
|
-
// transaction is not stopped or committed
|
|
233
|
+
catch (error) {
|
|
203
234
|
return {
|
|
204
|
-
error_code: ERROR_CODE.
|
|
205
|
-
status_code: SDK_STATUS_CODE.
|
|
206
|
-
message:
|
|
235
|
+
error_code: enums_1.ERROR_CODE.INTERNAL_SERVER_ERROR,
|
|
236
|
+
status_code: constant_1.SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
237
|
+
message: `Failed to cancel recording session, ${error}`,
|
|
207
238
|
};
|
|
208
239
|
}
|
|
209
|
-
|
|
210
|
-
status_code: SDK_STATUS_CODE.SUCCESS,
|
|
211
|
-
message: txnCommitMsg || 'Transaction committed successfully.',
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
catch (error) {
|
|
215
|
-
return {
|
|
216
|
-
error_code: ERROR_CODE.INTERNAL_SERVER_ERROR,
|
|
217
|
-
status_code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
218
|
-
message: `Failed to cancel recording session, ${error}`,
|
|
219
|
-
};
|
|
220
|
-
}
|
|
240
|
+
});
|
|
221
241
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
try {
|
|
229
|
-
const getStatusResponse = await getVoiceApiV3Status({
|
|
230
|
-
txnId: txn_id,
|
|
231
|
-
});
|
|
232
|
-
return getStatusResponse;
|
|
233
|
-
}
|
|
234
|
-
catch (error) {
|
|
235
|
-
return {
|
|
236
|
-
status_code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
237
|
-
message: `Failed to fetch output templates, ${error}`,
|
|
238
|
-
};
|
|
239
|
-
}
|
|
242
|
+
stopTransactionCall() {
|
|
243
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
244
|
+
// call endRecording method since all the steps are same
|
|
245
|
+
const endRecordingResponse = yield (0, end_recording_1.default)();
|
|
246
|
+
return endRecordingResponse;
|
|
247
|
+
});
|
|
240
248
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
249
|
+
getTemplateOutput(_a) {
|
|
250
|
+
return __awaiter(this, arguments, void 0, function* ({ txn_id }) {
|
|
251
|
+
try {
|
|
252
|
+
const getStatusResponse = yield (0, get_voice_api_v3_status_1.getVoiceApiV3Status)({
|
|
253
|
+
txnId: txn_id,
|
|
254
|
+
});
|
|
255
|
+
return getStatusResponse;
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
return {
|
|
259
|
+
status_code: constant_1.SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
260
|
+
message: `Failed to fetch output templates, ${error}`,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
});
|
|
254
264
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
265
|
+
getOutputTranscription(_a) {
|
|
266
|
+
return __awaiter(this, arguments, void 0, function* ({ txn_id }) {
|
|
267
|
+
try {
|
|
268
|
+
const getStatusResponse = yield (0, get_voice_api_v3_status_transcript_1.getVoiceApiV3StatusTranscript)({
|
|
269
|
+
txnId: txn_id,
|
|
270
|
+
});
|
|
271
|
+
return getStatusResponse;
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
return {
|
|
275
|
+
status_code: constant_1.SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
276
|
+
message: `Failed to fetch output templates, ${error}`,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
});
|
|
258
280
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
281
|
+
pollSessionOutput(request) {
|
|
282
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
283
|
+
const pollingResponse = yield (0, poll_output_summary_1.pollOutputSummary)(request);
|
|
284
|
+
return pollingResponse;
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
getSessionHistory(_a) {
|
|
288
|
+
return __awaiter(this, arguments, void 0, function* ({ txn_count }) {
|
|
289
|
+
try {
|
|
290
|
+
const transactionsResponse = yield (0, get_transaction_history_1.default)({
|
|
291
|
+
txn_count,
|
|
292
|
+
});
|
|
293
|
+
return transactionsResponse;
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
return {
|
|
297
|
+
status_code: constant_1.SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
298
|
+
message: `Failed to fetch previous transactions, ${error}`,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
});
|
|
272
302
|
}
|
|
273
303
|
getSuccessFiles() {
|
|
274
304
|
return this.audioFileManagerInstance.getSuccessfulUploads();
|
|
@@ -280,25 +310,25 @@ class EkaScribe {
|
|
|
280
310
|
return this.audioFileManagerInstance.getTotalAudioChunks();
|
|
281
311
|
}
|
|
282
312
|
resetEkaScribe() {
|
|
283
|
-
console.log(this.audioFileManagerInstance, this.audioBufferInstance, this.vadInstance,
|
|
313
|
+
console.log(this.audioFileManagerInstance, this.audioBufferInstance, this.vadInstance, store_1.default, 'before reset ekascribe');
|
|
284
314
|
this.audioFileManagerInstance.resetFileManagerInstance();
|
|
285
315
|
this.audioBufferInstance.resetBufferManagerInstance();
|
|
286
316
|
this.vadInstance.resetVadWebInstance();
|
|
287
|
-
|
|
288
|
-
console.log(this.audioFileManagerInstance, this.audioBufferInstance, this.vadInstance,
|
|
317
|
+
store_1.default.resetStore();
|
|
318
|
+
console.log(this.audioFileManagerInstance, this.audioBufferInstance, this.vadInstance, store_1.default, 'after reset ekascribe');
|
|
289
319
|
}
|
|
290
320
|
onUserSpeechCallback(callback) {
|
|
291
|
-
|
|
321
|
+
store_1.default.userSpeechCallback = callback;
|
|
292
322
|
}
|
|
293
323
|
onEventCallback(callback) {
|
|
294
|
-
|
|
324
|
+
store_1.default.eventCallback = callback;
|
|
295
325
|
// this.audioFileManagerInstance.setProgressCallback(callback);
|
|
296
326
|
}
|
|
297
327
|
onVadFramesCallback(callback) {
|
|
298
|
-
|
|
328
|
+
store_1.default.vadFramesCallback = callback;
|
|
299
329
|
}
|
|
300
330
|
onVadFrameProcessedCallback(callback) {
|
|
301
|
-
|
|
331
|
+
store_1.default.vadFrameProcessedCallback = callback;
|
|
302
332
|
}
|
|
303
333
|
configureVadConstants({ pref_length, desp_length, max_length, sr, frame_size, pre_speech_pad_frames, short_thsld, long_thsld, }) {
|
|
304
334
|
return this.vadInstance.configureVadConstants({
|
|
@@ -313,78 +343,114 @@ class EkaScribe {
|
|
|
313
343
|
});
|
|
314
344
|
}
|
|
315
345
|
// Template SDK methods
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
346
|
+
getAllTemplates() {
|
|
347
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
348
|
+
const templatesResponse = yield (0, get_v1_templates_1.default)();
|
|
349
|
+
return templatesResponse;
|
|
350
|
+
});
|
|
319
351
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
352
|
+
createTemplate(template) {
|
|
353
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
354
|
+
const templatesResponse = yield (0, post_v1_template_1.default)(template);
|
|
355
|
+
return templatesResponse;
|
|
356
|
+
});
|
|
323
357
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
358
|
+
updateTemplate(template) {
|
|
359
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
360
|
+
const templatesResponse = yield (0, patch_v1_template_1.default)(template);
|
|
361
|
+
return templatesResponse;
|
|
362
|
+
});
|
|
327
363
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
364
|
+
deleteTemplate(template_id) {
|
|
365
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
366
|
+
const templatesResponse = yield (0, delete_v1_template_1.default)(template_id);
|
|
367
|
+
return templatesResponse;
|
|
368
|
+
});
|
|
331
369
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
370
|
+
aiGenerateTemplate(formData) {
|
|
371
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
372
|
+
const templatesResponse = yield (0, cook_v1_medai_ai_create_template_1.default)(formData);
|
|
373
|
+
return templatesResponse;
|
|
374
|
+
});
|
|
335
375
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
376
|
+
updateConfig(request) {
|
|
377
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
378
|
+
const configResponse = yield (0, patch_voice_api_v2_config_1.default)(request);
|
|
379
|
+
return configResponse;
|
|
380
|
+
});
|
|
339
381
|
}
|
|
340
382
|
// Template Section SDK methods
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
383
|
+
getAllTemplateSections() {
|
|
384
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
385
|
+
const templateSectionsResponse = yield (0, get_v1_template_sections_1.default)();
|
|
386
|
+
return templateSectionsResponse;
|
|
387
|
+
});
|
|
344
388
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
389
|
+
createTemplateSection(templateSection) {
|
|
390
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
391
|
+
const templateSectionsResponse = yield (0, post_v1_template_section_1.default)(templateSection);
|
|
392
|
+
return templateSectionsResponse;
|
|
393
|
+
});
|
|
348
394
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
395
|
+
updateTemplateSection(templateSection) {
|
|
396
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
397
|
+
const templateSectionsResponse = yield (0, patch_v1_template_section_1.default)(templateSection);
|
|
398
|
+
return templateSectionsResponse;
|
|
399
|
+
});
|
|
352
400
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
401
|
+
deleteTemplateSection(section_id) {
|
|
402
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
403
|
+
const templateSectionsResponse = yield (0, delete_v1_template_section_1.default)(section_id);
|
|
404
|
+
return templateSectionsResponse;
|
|
405
|
+
});
|
|
356
406
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
407
|
+
postTransactionConvertToTemplate(_a) {
|
|
408
|
+
return __awaiter(this, arguments, void 0, function* ({ txn_id, template_id }) {
|
|
409
|
+
const convertToTemplateResponse = yield (0, post_transaction_convert_to_template_1.default)({ txn_id, template_id });
|
|
410
|
+
return convertToTemplateResponse;
|
|
411
|
+
});
|
|
360
412
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
413
|
+
convertTranscriptionToTemplate(request) {
|
|
414
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
415
|
+
const convertToTemplateResponse = yield (0, post_convert_transcription_to_template_1.default)(request);
|
|
416
|
+
return convertToTemplateResponse;
|
|
417
|
+
});
|
|
364
418
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
419
|
+
searchPastSessions(request) {
|
|
420
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
421
|
+
const searchSessionsResponse = yield (0, search_past_sessions_1.default)(request);
|
|
422
|
+
return searchSessionsResponse;
|
|
423
|
+
});
|
|
368
424
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
425
|
+
searchSessionsByPatientName(request) {
|
|
426
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
427
|
+
const searchSessionsByPatientNameResponse = yield (0, search_past_sessions_1.searchSessionsByPatient)(request);
|
|
428
|
+
return searchSessionsByPatientNameResponse;
|
|
429
|
+
});
|
|
372
430
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
431
|
+
searchSessionsBySessionId(request) {
|
|
432
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
433
|
+
const searchSessionsBySessionIdResponse = yield (0, search_past_sessions_1.searchSessionsBySessionId)(request);
|
|
434
|
+
return searchSessionsBySessionIdResponse;
|
|
435
|
+
});
|
|
376
436
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
437
|
+
uploadAudioWithPresignedUrl(request) {
|
|
438
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
439
|
+
const uploadAudioFilesResponse = yield (0, upload_full_audio_with_presigned_url_1.postV1UploadAudioFiles)(request);
|
|
440
|
+
return uploadAudioFilesResponse;
|
|
441
|
+
});
|
|
380
442
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
443
|
+
updateResultSummary(request) {
|
|
444
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
445
|
+
const updateResultSummaryResponse = yield (0, patch_voice_api_v3_status_1.patchVoiceApiV3Status)(request);
|
|
446
|
+
return updateResultSummaryResponse;
|
|
447
|
+
});
|
|
384
448
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
449
|
+
getConfigMyTemplates() {
|
|
450
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
451
|
+
const configMyTemplatesResponse = yield (0, get_voice_api_v2_config_my_templates_1.getConfigV2MyTemplates)();
|
|
452
|
+
return configMyTemplatesResponse;
|
|
453
|
+
});
|
|
388
454
|
}
|
|
389
455
|
}
|
|
390
456
|
Object.defineProperty(EkaScribe, "instance", {
|
|
@@ -394,4 +460,5 @@ Object.defineProperty(EkaScribe, "instance", {
|
|
|
394
460
|
value: null
|
|
395
461
|
});
|
|
396
462
|
// Export the singleton instance getter with optional initialization
|
|
397
|
-
|
|
463
|
+
const getEkaScribeInstance = ({ access_token, env, clientId, }) => EkaScribe.getInstance({ access_token, env, clientId });
|
|
464
|
+
exports.getEkaScribeInstance = getEkaScribeInstance;
|