Skip to content

Commit 14a97ab

Browse files
committed
1.5.0
1 parent 5ca2095 commit 14a97ab

File tree

4 files changed

+226
-216
lines changed

4 files changed

+226
-216
lines changed

dist/README.md

Lines changed: 1 addition & 1 deletion
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.3.1-blue.svg)
3+
![version](https://img.shields.io/badge/version-1.5.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)

dist/cjs/components/MicrophoneGenerator.js

Lines changed: 74 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -81,84 +81,82 @@ var MicrophoneGenerator = /*#__PURE__*/function () {
8181
var _init = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
8282
var _this = this;
8383
return _regenerator["default"].wrap(function _callee$(_context) {
84-
while (1) {
85-
switch (_context.prev = _context.next) {
86-
case 0:
87-
this.logger({
88-
currentState: "@vatis-tech/asr-client-js: Initializing the \"MicrophoneGenerator\" plugin.",
89-
description: "@vatis-tech/asr-client-js: The MicrophoneGenerator will request for the user's microphone."
90-
});
91-
_context.next = 3;
92-
return navigator.mediaDevices.getUserMedia({
93-
video: false,
94-
audio: true
95-
}).then(function (stream) {
96-
_this.stream = stream;
97-
var options = {
98-
mimeType: "audio/webm",
99-
bitsPerSecond: 128000,
100-
audioBitrateMode: "constant"
84+
while (1) switch (_context.prev = _context.next) {
85+
case 0:
86+
this.logger({
87+
currentState: "@vatis-tech/asr-client-js: Initializing the \"MicrophoneGenerator\" plugin.",
88+
description: "@vatis-tech/asr-client-js: The MicrophoneGenerator will request for the user's microphone."
89+
});
90+
_context.next = 3;
91+
return navigator.mediaDevices.getUserMedia({
92+
video: false,
93+
audio: true
94+
}).then(function (stream) {
95+
_this.stream = stream;
96+
var options = {
97+
mimeType: "audio/webm",
98+
bitsPerSecond: 128000,
99+
audioBitrateMode: "constant"
100+
};
101+
_this.mediaRecorder = new MediaRecorder(stream, options);
102+
_this.mediaRecorder.addEventListener("dataavailable", function (e) {
103+
var _this2 = this;
104+
// Converting audio blob to base64
105+
var reader = new FileReader();
106+
reader.onloadend = function () {
107+
// You can upload the base64 to server here.
108+
_this2.onDataCallback({
109+
data: reader.result.replace("data:audio/webm;codecs=opus;base64,", "").replace("data:audio/webm; codecs=opus;base64,", "").replace("data:audio/webm; codecs=opus; base64,", "")
110+
});
101111
};
102-
_this.mediaRecorder = new MediaRecorder(stream, options);
103-
_this.mediaRecorder.addEventListener("dataavailable", function (e) {
104-
var _this2 = this;
105-
// Converting audio blob to base64
106-
var reader = new FileReader();
107-
reader.onloadend = function () {
108-
// You can upload the base64 to server here.
109-
_this2.onDataCallback({
110-
data: reader.result.replace("data:audio/webm;codecs=opus;base64,", "").replace("data:audio/webm; codecs=opus;base64,", "").replace("data:audio/webm; codecs=opus; base64,", "")
111-
});
112-
};
113-
reader.readAsDataURL(e.data);
114-
// if (e.data.size > 0) {
115-
// if (this.blobState) {
116-
// this.blobState = new Blob([this.blobState, e.data]);
117-
// } else {
118-
// this.blobState = e.data;
119-
// }
120-
// if (this.blobState.size > MICROPHONE_BIT_RATE_SAMPLES) {
121-
// this.blobState.arrayBuffer().then((buffer) => {
122-
// for (
123-
// var i = 0;
124-
// i <
125-
// Math.trunc(
126-
// this.blobState.size / MICROPHONE_BIT_RATE_SAMPLES
127-
// );
128-
// i++
129-
// ) {
130-
// let dataSamples = buffer.slice(
131-
// i * MICROPHONE_BIT_RATE_SAMPLES,
132-
// MICROPHONE_BIT_RATE_SAMPLES +
133-
// i * MICROPHONE_BIT_RATE_SAMPLES
134-
// );
135-
// // this.onDataCallback(new Int32Array(dataSamples));
136-
// this.onDataCallback(base64ArrayBuffer(dataSamples));
137-
// }
138-
// this.blobState = this.blobState.slice(
139-
// i * MICROPHONE_BIT_RATE_SAMPLES,
140-
// this.blobState.size
141-
// );
142-
// });
143-
// }
144-
// }
145-
}.bind(_this));
146-
_this.mediaRecorder.start(_this.microphoneTimeslice);
147-
_this.logger({
148-
currentState: "@vatis-tech/asr-client-js: Initialized the \"MicrophoneGenerator\" plugin.",
149-
description: "@vatis-tech/asr-client-js: The MicrophoneGenerator was successful into getting user's microphone, and will start sending data each ".concat(_this.microphoneTimeslice, " miliseconds.")
150-
});
151-
})["catch"](function (err) {
152-
_this.logger({
153-
currentState: "@vatis-tech/asr-client-js: Could not initilize the \"MicrophoneGenerator\" plugin.",
154-
description: "@vatis-tech/asr-client-js: " + err
155-
});
156-
_this.errorHandler(err);
112+
reader.readAsDataURL(e.data);
113+
// if (e.data.size > 0) {
114+
// if (this.blobState) {
115+
// this.blobState = new Blob([this.blobState, e.data]);
116+
// } else {
117+
// this.blobState = e.data;
118+
// }
119+
// if (this.blobState.size > MICROPHONE_BIT_RATE_SAMPLES) {
120+
// this.blobState.arrayBuffer().then((buffer) => {
121+
// for (
122+
// var i = 0;
123+
// i <
124+
// Math.trunc(
125+
// this.blobState.size / MICROPHONE_BIT_RATE_SAMPLES
126+
// );
127+
// i++
128+
// ) {
129+
// let dataSamples = buffer.slice(
130+
// i * MICROPHONE_BIT_RATE_SAMPLES,
131+
// MICROPHONE_BIT_RATE_SAMPLES +
132+
// i * MICROPHONE_BIT_RATE_SAMPLES
133+
// );
134+
// // this.onDataCallback(new Int32Array(dataSamples));
135+
// this.onDataCallback(base64ArrayBuffer(dataSamples));
136+
// }
137+
// this.blobState = this.blobState.slice(
138+
// i * MICROPHONE_BIT_RATE_SAMPLES,
139+
// this.blobState.size
140+
// );
141+
// });
142+
// }
143+
// }
144+
}.bind(_this));
145+
_this.mediaRecorder.start(_this.microphoneTimeslice);
146+
_this.logger({
147+
currentState: "@vatis-tech/asr-client-js: Initialized the \"MicrophoneGenerator\" plugin.",
148+
description: "@vatis-tech/asr-client-js: The MicrophoneGenerator was successful into getting user's microphone, and will start sending data each ".concat(_this.microphoneTimeslice, " miliseconds.")
149+
});
150+
})["catch"](function (err) {
151+
_this.logger({
152+
currentState: "@vatis-tech/asr-client-js: Could not initilize the \"MicrophoneGenerator\" plugin.",
153+
description: "@vatis-tech/asr-client-js: " + err
157154
});
158-
case 3:
159-
case "end":
160-
return _context.stop();
161-
}
155+
_this.errorHandler(err);
156+
});
157+
case 3:
158+
case "end":
159+
return _context.stop();
162160
}
163161
}, _callee, this);
164162
}));

dist/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vatis-tech/asr-client-js",
3-
"version": "1.4.1",
3+
"version": "1.5.0",
44
"description": "JavaScript client for Vatis Tech ASR services.",
55
"main": "cjs/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)