augnitorecorder
Advanced tools
Comparing version 1.0.22 to 1.0.23
@@ -29,4 +29,4 @@ export declare class AugnitoRecorder { | ||
); | ||
togglePauseResumeAudioStream(): void; | ||
toggleStartStopAudioStream(): void; | ||
togglePauseResumeAudioStream(socketURL?: string): void; | ||
toggleStartStopAudioStream(socketURL?: string): void; | ||
startAudio(): void; | ||
@@ -33,0 +33,0 @@ pauseAudio(): void; |
@@ -388,6 +388,5 @@ function _regeneratorRuntime() { | ||
var Executor = /*#__PURE__*/function () { | ||
function Executor(wsUrl, enableLogs, eosMessage, socketTimeoutInterval, shouldSendAudioDataSequence, onFinalResult, onPartialResult, onError, onSessionEvent, onOtherResults, onSpeechResponse) { | ||
function Executor(enableLogs, eosMessage, socketTimeoutInterval, shouldSendAudioDataSequence, onFinalResult, onPartialResult, onError, onSessionEvent, onOtherResults, onSpeechResponse) { | ||
_classCallCheck(this, Executor); | ||
this.worker; | ||
this.wsUrl = wsUrl; | ||
this.onFinalResultCallback = onFinalResult; | ||
@@ -412,5 +411,5 @@ this.onErrorCallback = onError; | ||
key: "Start", | ||
value: function Start() { | ||
value: function Start(wsUrl) { | ||
var _this = this; | ||
var workerScript = "\n (() => {\n (".concat(WorkerBlob.toString(), ")(").concat(JSON.stringify(DONE_MSG), ", ").concat(JSON.stringify(this.eosMessage), ", ").concat(JSON.stringify(CLOSE_MSG), ", ").concat(JSON.stringify(CONNECT_RETRY_TIMEOUT), ", ").concat(JSON.stringify(this.socketTimeoutInterval), ", ").concat(JSON.stringify(HEALTHCHECK_INTERVAL), ", ").concat(JSON.stringify(CONSUME_INTERVAL), ", ").concat(JSON.stringify(this.wsUrl), ", ").concat(JSON.stringify(this.enableLogs), ", ").concat(JSON.stringify(this.shouldSendAudioDataSequence), ", ").concat(JSON.stringify(this.heavyOp), ");\n })();\n"); | ||
var workerScript = "\n (() => {\n (".concat(WorkerBlob.toString(), ")(").concat(JSON.stringify(DONE_MSG), ", ").concat(JSON.stringify(this.eosMessage), ", ").concat(JSON.stringify(CLOSE_MSG), ", ").concat(JSON.stringify(CONNECT_RETRY_TIMEOUT), ", ").concat(JSON.stringify(this.socketTimeoutInterval), ", ").concat(JSON.stringify(HEALTHCHECK_INTERVAL), ", ").concat(JSON.stringify(CONSUME_INTERVAL), ", ").concat(JSON.stringify(wsUrl), ", ").concat(JSON.stringify(this.enableLogs), ", ").concat(JSON.stringify(this.shouldSendAudioDataSequence), ", ").concat(JSON.stringify(this.heavyOp), ");\n })();\n"); | ||
this.worker = new Worker(URL.createObjectURL(new Blob([workerScript], { | ||
@@ -738,10 +737,7 @@ type: "application/javascript" | ||
var Streamer = /*#__PURE__*/function () { | ||
function Streamer(wsUrl, enableLogs, isDebug, bufferSizeInterval, eosMessage, socketTimeoutInterval, shouldSendAudioDataSequence, heavyOp, onFinalResult, onPartialResult, onError, onStateChanged, onSessionEvent, onOtherResults, onSpeechResponse) { | ||
function Streamer(enableLogs, isDebug, bufferSizeInterval, eosMessage, socketTimeoutInterval, shouldSendAudioDataSequence, heavyOp, onFinalResult, onPartialResult, onError, onStateChanged, onSessionEvent, onOtherResults, onSpeechResponse) { | ||
_classCallCheck(this, Streamer); | ||
this.audioContext = new AudioContext(); | ||
if (wsUrl !== "") { | ||
this.executor = new Executor(wsUrl, enableLogs, eosMessage, socketTimeoutInterval, shouldSendAudioDataSequence, onFinalResult, onPartialResult, onError, onSessionEvent, onOtherResults, onSpeechResponse); | ||
this.executor.HeavyOp = heavyOp; | ||
this.executor.Start(); | ||
} | ||
this.executor = new Executor(enableLogs, eosMessage, socketTimeoutInterval, shouldSendAudioDataSequence, onFinalResult, onPartialResult, onError, onSessionEvent, onOtherResults, onSpeechResponse); | ||
this.executor.HeavyOp = heavyOp; | ||
this.source; | ||
@@ -762,6 +758,9 @@ this.processorNode; | ||
value: function () { | ||
var _StartStream = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { | ||
var _StartStream = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(wsUrl) { | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
if (wsUrl !== "") { | ||
this.executor.Start(wsUrl); | ||
} | ||
this.log("New stream started..."); | ||
@@ -771,7 +770,7 @@ // Uncomment to stream recorded audio | ||
// Uncomment to stream microphone audio | ||
_context.next = 3; | ||
_context.next = 4; | ||
return this.createMediaStreamSourceNode(); | ||
case 3: | ||
case 4: | ||
if (this.source) { | ||
_context.next = 6; | ||
_context.next = 7; | ||
break; | ||
@@ -781,8 +780,8 @@ } | ||
return _context.abrupt("return"); | ||
case 6: | ||
_context.next = 8; | ||
case 7: | ||
_context.next = 9; | ||
return this.createProcessorNode(); | ||
case 8: | ||
case 9: | ||
if (this.processorNode) { | ||
_context.next = 11; | ||
_context.next = 12; | ||
break; | ||
@@ -792,3 +791,3 @@ } | ||
return _context.abrupt("return"); | ||
case 11: | ||
case 12: | ||
this.onStateChanged(true); | ||
@@ -798,3 +797,3 @@ this.source.connect(this.processorNode).connect(this.audioContext.destination); | ||
this.isStreaming = true; | ||
case 15: | ||
case 16: | ||
case "end": | ||
@@ -805,3 +804,3 @@ return _context.stop(); | ||
})); | ||
function StartStream() { | ||
function StartStream(_x) { | ||
return _StartStream.apply(this, arguments); | ||
@@ -1075,3 +1074,3 @@ } | ||
})); | ||
function StopStream(_x) { | ||
function StopStream(_x2) { | ||
return _StopStream.apply(this, arguments); | ||
@@ -1166,2 +1165,3 @@ } | ||
function AugnitoRecorder() { | ||
var _config$serverURL; | ||
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { | ||
@@ -1178,3 +1178,3 @@ serverURL: "", | ||
_classCallCheck(this, AugnitoRecorder); | ||
this.WebsocketURL = config.serverURL !== "" ? config.serverURL : ""; | ||
this.WebsocketURL = (_config$serverURL = config.serverURL) !== null && _config$serverURL !== void 0 ? _config$serverURL : ""; | ||
this.enableLogs = config.enableLogs; | ||
@@ -1192,3 +1192,3 @@ this.isDebug = config.isDebug; | ||
value: function initialiseStreamer() { | ||
this.streamer = new Streamer(this.WebsocketURL, this.enableLogs, this.isDebug, this.bufferInterval, this.eosMessage, this.socketTimeoutInterval, this.shouldSendAudioDataSequence, this.heavyOp, this.onFinalResultCallback.bind(this), this.onPartialResultCallback.bind(this), this.onErrorCallback.bind(this), this.onStateChangedCallback.bind(this), this.onSessionEventCallback.bind(this), this.onOtherResultCallback.bind(this), this.onSpeechResponseCallback.bind(this)); | ||
this.streamer = new Streamer(this.enableLogs, this.isDebug, this.bufferInterval, this.eosMessage, this.socketTimeoutInterval, this.shouldSendAudioDataSequence, this.heavyOp, this.onFinalResultCallback.bind(this), this.onPartialResultCallback.bind(this), this.onErrorCallback.bind(this), this.onStateChangedCallback.bind(this), this.onSessionEventCallback.bind(this), this.onOtherResultCallback.bind(this), this.onSpeechResponseCallback.bind(this)); | ||
} | ||
@@ -1198,3 +1198,7 @@ }, { | ||
value: function togglePauseResumeAudioStream() { | ||
var socketUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined; | ||
if (!this.streamer) { | ||
if (socketUrl) { | ||
this.WebsocketURL = socketUrl; | ||
} | ||
this.startAudio(); | ||
@@ -1212,3 +1216,7 @@ } else { | ||
value: function toggleStartStopAudioStream() { | ||
var socketUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined; | ||
if (!this.streamer) { | ||
if (socketUrl) { | ||
this.WebsocketURL = socketUrl; | ||
} | ||
this.startAudio(); | ||
@@ -1223,3 +1231,3 @@ } else { | ||
this.initialiseStreamer(); | ||
this.streamer.StartStream(); | ||
this.streamer.StartStream(this.WebsocketURL); | ||
this.log("Stream Started..."); | ||
@@ -1226,0 +1234,0 @@ } |
{ | ||
"name": "augnitorecorder", | ||
"version": "1.0.22", | ||
"version": "1.0.23", | ||
"description": "Audio recorder and streamer compatible with any browser", | ||
@@ -5,0 +5,0 @@ "main": "dist/augnitoRecorder.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
128145
1352