Skip to content

Commit 1e68258

Browse files
committed
refactor: update vtc with newer version
1 parent ad7adb5 commit 1e68258

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+393
-183
lines changed

assets/js/asr-client-js-main/.github/ISSUE_TEMPLATE/bug_report.yml renamed to assets/js/asr-client-js-refactor-VAT-385-453/.github/ISSUE_TEMPLATE/bug_report.yml

+17
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,24 @@ body:
1616
description: Please specify what version of `@vatis-tech/asr-client-js` you are using, and also, please check if the issue is reproducible with the latest stable version of the plugin.
1717
multiple: true
1818
options:
19+
- 1.2.2
20+
- 1.2.1
21+
- 1.2.1-rc.1
22+
- 1.2.1-rc.0
23+
- 1.2.0
24+
- 1.1.1
25+
- 1.1.0
26+
- 1.1.0-rc.0
1927
- 1.0.0
28+
- 1.0.0-rc.8
29+
- 1.0.0-rc.7
30+
- 1.0.0-rc.6
31+
- 1.0.0-rc.5
32+
- 1.0.0-rc.4
33+
- 1.0.0-rc.3
34+
- 1.0.0-rc.2
35+
- 1.0.0-rc.1
36+
- 1.0.0-rc.0
2037
validations:
2138
required: true
2239
- type: dropdown

assets/js/asr-client-js-main/.github/ISSUE_TEMPLATE/help_wanted.yml renamed to assets/js/asr-client-js-refactor-VAT-385-453/.github/ISSUE_TEMPLATE/help_wanted.yml

+17
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,24 @@ body:
1616
description: Please specify what version of `@vatis-tech/asr-client-js` do you want to use.
1717
multiple: true
1818
options:
19+
- 1.2.2
20+
- 1.2.1
21+
- 1.2.1-rc.1
22+
- 1.2.1-rc.0
23+
- 1.2.0
24+
- 1.1.1
25+
- 1.1.0
26+
- 1.1.0-rc.0
1927
- 1.0.0
28+
- 1.0.0-rc.8
29+
- 1.0.0-rc.7
30+
- 1.0.0-rc.6
31+
- 1.0.0-rc.5
32+
- 1.0.0-rc.4
33+
- 1.0.0-rc.3
34+
- 1.0.0-rc.2
35+
- 1.0.0-rc.1
36+
- 1.0.0-rc.0
2037
validations:
2138
required: true
2239
- type: dropdown

assets/js/asr-client-js-main/CHANGELOG.md renamed to assets/js/asr-client-js-refactor-VAT-385-453/CHANGELOG.md

+18
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ No fixes were made.
5151

5252
Each time you add new changes to this file, please add them bellow this line - i.e. between the [insertion](#insterion) section and the last version added.
5353

54+
## [1.3.0] - 2022-05-03
55+
56+
### Added
57+
58+
No new features were added.
59+
60+
### Changed
61+
62+
- Right now, instead of sending one message and waiting for its full response, you can send up to `waitingAfterMessages` before waiting for full responses
63+
64+
### Removed
65+
66+
Nothing was removed.
67+
68+
### Fixed
69+
70+
No fixes were made.
71+
5472
## [1.2.0] - 2022-04-11
5573

5674
### Added

assets/js/asr-client-js-main/README.md renamed to assets/js/asr-client-js-refactor-VAT-385-453/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# @vatis-tech/asr-client-js
22

3-
![version](https://img.shields.io/badge/version-1.2.1-blue.svg)
3+
![version](https://img.shields.io/badge/version-1.3.0-blue.svg)
44
![license](https://img.shields.io/badge/license-MIT-blue.svg)
55
![GitHub issues open](https://img.shields.io/github/issues/Vatis-Tech/asr-client-js.svg)
66
![GitHub issues closed](https://img.shields.io/github/issues-closed-raw/Vatis-Tech/asr-client-js.svg)
@@ -244,6 +244,10 @@ Default is `0.3 seconds`.
244244

245245
Default is `0.3 seconds`.
246246

247+
### `waitingAfterMessages`
248+
249+
This is a **number** that needs to be _> 0_. It represents the number of message to be sent to the ASR Service, before waiting for a response. Default is `5`.
250+
247251
## Methods
248252

249253
### `destroy`

assets/js/asr-client-js-main/dist/CHANGELOG.md renamed to assets/js/asr-client-js-refactor-VAT-385-453/dist/CHANGELOG.md

+18
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ No fixes were made.
5151

5252
Each time you add new changes to this file, please add them bellow this line - i.e. between the [insertion](#insterion) section and the last version added.
5353

54+
## [1.3.0] - 2022-05-03
55+
56+
### Added
57+
58+
No new features were added.
59+
60+
### Changed
61+
62+
- Right now, instead of sending one message and waiting for its full response, you can send up to `waitingAfterMessages` before waiting for full responses
63+
64+
### Removed
65+
66+
Nothing was removed.
67+
68+
### Fixed
69+
70+
No fixes were made.
71+
5472
## [1.2.0] - 2022-04-11
5573

5674
### Added

assets/js/asr-client-js-main/dist/README.md renamed to assets/js/asr-client-js-refactor-VAT-385-453/dist/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# @vatis-tech/asr-client-js
22

3-
![version](https://img.shields.io/badge/version-1.2.1-blue.svg)
3+
![version](https://img.shields.io/badge/version-1.3.0-blue.svg)
44
![license](https://img.shields.io/badge/license-MIT-blue.svg)
55
![GitHub issues open](https://img.shields.io/github/issues/Vatis-Tech/asr-client-js.svg)
66
![GitHub issues closed](https://img.shields.io/github/issues-closed-raw/Vatis-Tech/asr-client-js.svg)
@@ -244,6 +244,10 @@ Default is `0.3 seconds`.
244244

245245
Default is `0.3 seconds`.
246246

247+
### `waitingAfterMessages`
248+
249+
This is a **number** that needs to be _> 0_. It represents the number of message to be sent to the ASR Service, before waiting for a response. Default is `5`.
250+
247251
## Methods
248252

249253
### `destroy`

assets/js/asr-client-js-main/dist/cjs/components/InstanceReservation.js renamed to assets/js/asr-client-js-refactor-VAT-385-453/dist/cjs/components/InstanceReservation.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ var InstanceReservation = /*#__PURE__*/function () {
7373
key: "onLoad",
7474
value: function onLoad() {
7575
if (this.xmlHttp.status !== 200) {
76-
this.onError(JSON.parse(this.xmlHttp.responseText));
76+
this.onError({
77+
status: this.xmlHttp.status
78+
});
7779
return;
7880
}
7981

assets/js/asr-client-js-main/dist/cjs/components/MicrophoneGenerator.js renamed to assets/js/asr-client-js-refactor-VAT-385-453/dist/cjs/components/MicrophoneGenerator.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ var MicrophoneGenerator = /*#__PURE__*/function () {
6060
value: function destroy() {
6161
if (this.mediaRecorder && this.mediaRecorder.state !== "inactive") {
6262
this.mediaRecorder.stop();
63+
this.onDataCallback({
64+
data: "",
65+
flush: "True",
66+
close: "True"
67+
});
6368
}
6469

6570
if (this.stream) {
@@ -115,7 +120,9 @@ var MicrophoneGenerator = /*#__PURE__*/function () {
115120

116121
reader.onloadend = function () {
117122
// You can upload the base64 to server here.
118-
_this2.onDataCallback(reader.result.replace("data:audio/webm;codecs=opus;base64,", "").replace("data:audio/webm; codecs=opus; base64,", ""));
123+
_this2.onDataCallback({
124+
data: reader.result.replace("data:audio/webm;codecs=opus;base64,", "").replace("data:audio/webm; codecs=opus; base64,", "")
125+
});
119126
};
120127

121128
reader.readAsDataURL(e.data); // if (e.data.size > 0) {

assets/js/asr-client-js-main/dist/cjs/components/SocketIOClientGenerator.js renamed to assets/js/asr-client-js-refactor-VAT-385-453/dist/cjs/components/SocketIOClientGenerator.js

+24-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ var SOCKET_IO_CLIENT_NAMESPACE = _index["default"].SOCKET_IO_CLIENT_NAMESPACE,
2626
SOCKET_IO_CLIENT_BUFFER_OFFSET = _index["default"].SOCKET_IO_CLIENT_BUFFER_OFFSET,
2727
SOCKET_IO_CLIENT_AUDIO_FORMAT = _index["default"].SOCKET_IO_CLIENT_AUDIO_FORMAT,
2828
SOCKET_IO_CLIENT_SENDING_HEADERS = _index["default"].SOCKET_IO_CLIENT_SENDING_HEADERS,
29+
SOCKET_IO_CLIENT_DISABLE_DISFLUENCIES = _index["default"].SOCKET_IO_CLIENT_DISABLE_DISFLUENCIES,
30+
SOCKET_IO_CLIENT_ENABLE_PUNCTUATION_CAPITALIZATION = _index["default"].SOCKET_IO_CLIENT_ENABLE_PUNCTUATION_CAPITALIZATION,
31+
SOCKET_IO_CLIENT_ENABLE_ENTITIES_RECOGNITION = _index["default"].SOCKET_IO_CLIENT_ENABLE_ENTITIES_RECOGNITION,
32+
SOCKET_IO_CLIENT_ENABLE_NUMERALS_CONVERSION = _index["default"].SOCKET_IO_CLIENT_ENABLE_NUMERALS_CONVERSION,
2933
MICROPHONE_FRAME_LENGTH = _index["default"].MICROPHONE_FRAME_LENGTH,
3034
MICROPHONE_TIMESLICE = _index["default"].MICROPHONE_TIMESLICE;
3135

@@ -51,6 +55,7 @@ var SocketIOClientGenerator = /*#__PURE__*/function () {
5155
(0, _defineProperty2["default"])(this, "frameOverlap", void 0);
5256
(0, _defineProperty2["default"])(this, "bufferOffset", void 0);
5357
(0, _defineProperty2["default"])(this, "errorHandler", void 0);
58+
(0, _defineProperty2["default"])(this, "sendClosePacket", void 0);
5459
this.errorHandler = errorHandler;
5560
this.logger = logger;
5661
this.logger({
@@ -63,6 +68,7 @@ var SocketIOClientGenerator = /*#__PURE__*/function () {
6368
this.frameLength = frameLength;
6469
this.frameOverlap = frameOverlap;
6570
this.bufferOffset = bufferOffset;
71+
this.sendClosePacket = true;
6672
}
6773

6874
(0, _createClass2["default"])(SocketIOClientGenerator, [{
@@ -92,7 +98,11 @@ var SocketIOClientGenerator = /*#__PURE__*/function () {
9298
FrameOverlap: this.frameOverlap ? this.frameOverlap : SOCKET_IO_CLIENT_FRAME_OVERLAP,
9399
BufferOffset: this.bufferOffset ? this.bufferOffset : SOCKET_IO_CLIENT_BUFFER_OFFSET,
94100
AudioFormat: SOCKET_IO_CLIENT_AUDIO_FORMAT,
95-
SendingHeaders: SOCKET_IO_CLIENT_SENDING_HEADERS
101+
SendingHeaders: SOCKET_IO_CLIENT_SENDING_HEADERS,
102+
DisableDisfluencies: SOCKET_IO_CLIENT_DISABLE_DISFLUENCIES,
103+
EnablePunctuationCapitalization: SOCKET_IO_CLIENT_ENABLE_PUNCTUATION_CAPITALIZATION,
104+
EnableEntitiesRecognition: SOCKET_IO_CLIENT_ENABLE_ENTITIES_RECOGNITION,
105+
EnableNumeralsConversion: SOCKET_IO_CLIENT_ENABLE_NUMERALS_CONVERSION
96106
}
97107
});
98108
this.socketRef.on("connect", function () {
@@ -138,14 +148,24 @@ var SocketIOClientGenerator = /*#__PURE__*/function () {
138148
}, {
139149
key: "emitData",
140150
value: function emitData(data) {
141-
this.socketRef.emit(SOCKET_IO_CLIENT_REQUEST_PATH, {
142-
data: data
143-
});
151+
if (data.close === "True" || data.flush === "True") {
152+
this.sendClosePacket = false;
153+
}
154+
155+
this.socketRef.emit(SOCKET_IO_CLIENT_REQUEST_PATH, data);
144156
}
145157
}, {
146158
key: "destroy",
147159
value: function destroy() {
148160
this.socketRef.off("disconnect");
161+
162+
if (this.sendClosePacket) {
163+
this.socketRef.emit(SOCKET_IO_CLIENT_REQUEST_PATH, {
164+
close: "True",
165+
data: ""
166+
});
167+
}
168+
149169
this.socketRef.disconnect();
150170
}
151171
}]);

assets/js/asr-client-js-main/dist/cjs/helpers/constants/index.js renamed to assets/js/asr-client-js-refactor-VAT-385-453/dist/cjs/helpers/constants/index.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,30 @@ exports["default"] = void 0;
77
var API_URL = "https://vatis.tech/api/v1";
88
var API_URL_PATH = "/asr-client/auth?service=<service>&model=<model>&language=<language>";
99
var RESERVATION_URL = "<service_host>/asr/v1/registry/stream/reserve";
10+
var WAIT_AFTER_MESSAGES = 10;
1011
var SOCKET_IO_CLIENT_NAMESPACE = "/asr_stream";
1112
var SOCKET_IO_CLIENT_TRANSPORTS = ["websocket"];
1213
var SOCKET_IO_CLIENT_PATH = "/live/transcribe/socket.io";
1314
var SOCKET_IO_CLIENT_RESULT_PATH = "/asr_result";
1415
var SOCKET_IO_CLIENT_REQUEST_PATH = "/asr_request";
1516
var SOCKET_IO_CLIENT_RESPONSE_SPLIT_PACKET = "SplitPacket";
1617
var SOCKET_IO_CLIENT_RESPONSE_FINAL_SPLIT_PACKET = "FinalSplitPacket";
17-
var SOCKET_IO_CLIENT_FRAME_OVERLAP = 0.3;
18-
var SOCKET_IO_CLIENT_BUFFER_OFFSET = 0.3;
18+
var SOCKET_IO_CLIENT_FRAME_OVERLAP = 1.0;
19+
var SOCKET_IO_CLIENT_BUFFER_OFFSET = 0.5;
1920
var SOCKET_IO_CLIENT_AUDIO_FORMAT = "webm";
2021
var SOCKET_IO_CLIENT_SENDING_HEADERS = "True";
21-
var MICROPHONE_FRAME_LENGTH = 0.3;
22-
var MICROPHONE_BIT_RATE_SAMPLES = 8000;
23-
var MICROPHONE_TIMESLICE = 250;
22+
var SOCKET_IO_CLIENT_DISABLE_DISFLUENCIES = "True";
23+
var SOCKET_IO_CLIENT_ENABLE_PUNCTUATION_CAPITALIZATION = "True";
24+
var SOCKET_IO_CLIENT_ENABLE_ENTITIES_RECOGNITION = "True";
25+
var SOCKET_IO_CLIENT_ENABLE_NUMERALS_CONVERSION = "True";
26+
var MICROPHONE_FRAME_LENGTH = 0.6;
27+
var MICROPHONE_BIT_RATE_SAMPLES = 16000;
28+
var MICROPHONE_TIMESLICE = 500;
2429
var projectConstants = {
2530
API_URL_PATH: API_URL_PATH,
2631
API_URL: API_URL,
2732
RESERVATION_URL: RESERVATION_URL,
33+
WAIT_AFTER_MESSAGES: WAIT_AFTER_MESSAGES,
2834
SOCKET_IO_CLIENT_NAMESPACE: SOCKET_IO_CLIENT_NAMESPACE,
2935
SOCKET_IO_CLIENT_TRANSPORTS: SOCKET_IO_CLIENT_TRANSPORTS,
3036
SOCKET_IO_CLIENT_PATH: SOCKET_IO_CLIENT_PATH,
@@ -36,6 +42,10 @@ var projectConstants = {
3642
SOCKET_IO_CLIENT_BUFFER_OFFSET: SOCKET_IO_CLIENT_BUFFER_OFFSET,
3743
SOCKET_IO_CLIENT_AUDIO_FORMAT: SOCKET_IO_CLIENT_AUDIO_FORMAT,
3844
SOCKET_IO_CLIENT_SENDING_HEADERS: SOCKET_IO_CLIENT_SENDING_HEADERS,
45+
SOCKET_IO_CLIENT_DISABLE_DISFLUENCIES: SOCKET_IO_CLIENT_DISABLE_DISFLUENCIES,
46+
SOCKET_IO_CLIENT_ENABLE_PUNCTUATION_CAPITALIZATION: SOCKET_IO_CLIENT_ENABLE_PUNCTUATION_CAPITALIZATION,
47+
SOCKET_IO_CLIENT_ENABLE_ENTITIES_RECOGNITION: SOCKET_IO_CLIENT_ENABLE_ENTITIES_RECOGNITION,
48+
SOCKET_IO_CLIENT_ENABLE_NUMERALS_CONVERSION: SOCKET_IO_CLIENT_ENABLE_NUMERALS_CONVERSION,
3949
MICROPHONE_FRAME_LENGTH: MICROPHONE_FRAME_LENGTH,
4050
MICROPHONE_BIT_RATE_SAMPLES: MICROPHONE_BIT_RATE_SAMPLES,
4151
MICROPHONE_TIMESLICE: MICROPHONE_TIMESLICE

assets/js/asr-client-js-main/dist/cjs/index.js renamed to assets/js/asr-client-js-refactor-VAT-385-453/dist/cjs/index.js

+26-18
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@ var _MicrophoneGenerator = _interopRequireDefault(require("./components/Micropho
2323

2424
var _MicrophoneQueue = _interopRequireDefault(require("./components/MicrophoneQueue.js"));
2525

26-
var _index = _interopRequireDefault(require("./helpers/functions/index.js"));
26+
var _index = _interopRequireDefault(require("./helpers/constants/index.js"));
2727

28-
// import constants from "../helpers/constants/index.js";
29-
// const {
30-
//
31-
// } = constants;
32-
var generateApiUrl = _index["default"].generateApiUrl,
33-
checkIfFinalPacket = _index["default"].checkIfFinalPacket;
28+
var _index2 = _interopRequireDefault(require("./helpers/functions/index.js"));
29+
30+
var WAIT_AFTER_MESSAGES = _index["default"].WAIT_AFTER_MESSAGES;
31+
var generateApiUrl = _index2["default"].generateApiUrl,
32+
checkIfFinalPacket = _index2["default"].checkIfFinalPacket;
3433

3534
var VatisTechClient = /*#__PURE__*/function () {
3635
function VatisTechClient(_ref) {
@@ -47,7 +46,8 @@ var VatisTechClient = /*#__PURE__*/function () {
4746
frameLength = _ref.frameLength,
4847
frameOverlap = _ref.frameOverlap,
4948
bufferOffset = _ref.bufferOffset,
50-
errorHandler = _ref.errorHandler;
49+
errorHandler = _ref.errorHandler,
50+
waitingAfterMessages = _ref.waitingAfterMessages;
5151
(0, _classCallCheck2["default"])(this, VatisTechClient);
5252
(0, _defineProperty2["default"])(this, "microphoneGenerator", void 0);
5353
(0, _defineProperty2["default"])(this, "instanceReservation", void 0);
@@ -56,6 +56,7 @@ var VatisTechClient = /*#__PURE__*/function () {
5656
(0, _defineProperty2["default"])(this, "microphoneQueue", void 0);
5757
(0, _defineProperty2["default"])(this, "onData", void 0);
5858
(0, _defineProperty2["default"])(this, "waitingForFinalPacket", void 0);
59+
(0, _defineProperty2["default"])(this, "waitingAfterMessages", void 0);
5960
(0, _defineProperty2["default"])(this, "logger", void 0);
6061
(0, _defineProperty2["default"])(this, "log", void 0);
6162
(0, _defineProperty2["default"])(this, "shouldDestroy", void 0);
@@ -81,9 +82,16 @@ var VatisTechClient = /*#__PURE__*/function () {
8182
this.logger({
8283
currentState: "@vatis-tech/asr-client-js: Initilizing plugin.",
8384
description: "@vatis-tech/asr-client-js: This is the base constructor which initilizez everything for the LIVE ASR service of Vatis Tech."
84-
}); // this is a flag that says if the whole response for the previous packet was received or not
85+
});
86+
87+
if (waitingAfterMessages && waitingAfterMessages > 0) {
88+
this.waitingAfterMessages = waitingAfterMessages;
89+
} else {
90+
this.waitingAfterMessages = WAIT_AFTER_MESSAGES;
91+
} // this is a flag that says if the whole response for the previous packet was received or not
8592

86-
this.waitingForFinalPacket = false; // this is a flag that says if the user wants to destroy the VTC client
93+
94+
this.waitingForFinalPacket = 0; // this is a flag that says if the user wants to destroy the VTC client
8795
// but since there might be data to be received by the socket, or to be sent by the socket
8896
// the VTC client will wait for that to finis
8997

@@ -158,7 +166,7 @@ var VatisTechClient = /*#__PURE__*/function () {
158166
hard = _ref2.hard;
159167

160168
// check if there is still data to be received or to be sent
161-
if ((this.waitingForFinalPacket || !this.microphoneQueue.isEmpty) && hard !== true) {
169+
if ((this.waitingForFinalPacket > 0 || !this.microphoneQueue.isEmpty) && hard !== true) {
162170
// let the messaging know that we want the client to be destroyed
163171
this.shouldDestroy = true; // pause the microphone so it won't record anymore
164172

@@ -263,8 +271,8 @@ var VatisTechClient = /*#__PURE__*/function () {
263271
if (this.microphoneQueue === undefined) return;
264272
this.microphoneQueue.enqueue(data);
265273

266-
if (this.waitingForFinalPacket === false && this.microphoneQueue.peek()) {
267-
this.waitingForFinalPacket = true;
274+
if (this.waitingForFinalPacket < this.waitingAfterMessages && this.microphoneQueue.peek()) {
275+
this.waitingForFinalPacket = this.waitingForFinalPacket + 1;
268276
this.socketIOClientGenerator.emitData(this.microphoneQueue.dequeue());
269277
}
270278
} // get data from SocketIOClientGenerator from the SOCKET_IO_CLIENT_RESULT_PATH and send it to user's callback function
@@ -277,16 +285,16 @@ var VatisTechClient = /*#__PURE__*/function () {
277285
this.onData(JSON.parse(data));
278286

279287
if (checkIfFinalPacket(JSON.parse(data))) {
280-
if (this.microphoneQueue.peek()) {
281-
this.waitingForFinalPacket = true;
288+
this.waitingForFinalPacket = this.waitingForFinalPacket - 1;
289+
290+
if (this.microphoneQueue.peek() && this.waitingForFinalPacket < this.waitingAfterMessages) {
291+
this.waitingForFinalPacket = this.waitingForFinalPacket + 1;
282292
this.socketIOClientGenerator.emitData(this.microphoneQueue.dequeue());
283-
} else {
284-
this.waitingForFinalPacket = false;
285293
}
286294
} // check if the user tried to destroy the VTC client
287295

288296

289-
if (!this.waitingForFinalPacket && this.microphoneQueue.isEmpty && this.shouldDestroy) {
297+
if (this.waitingForFinalPacket === 0 && this.microphoneQueue.isEmpty && this.shouldDestroy) {
290298
this.destroy();
291299
}
292300
}

0 commit comments

Comments
 (0)