augnitorecorder
Advanced tools
Comparing version 1.0.15 to 1.0.16
@@ -457,3 +457,2 @@ function _regeneratorRuntime() { | ||
// message sent to web-worker - transferrable | ||
console.log("message sent to worker"); | ||
(_this$worker2 = this.worker) === null || _this$worker2 === void 0 || _this$worker2.postMessage(data, [data]); | ||
@@ -627,3 +626,3 @@ } | ||
// worklet-thread | ||
var worklet = "class MyAudioWorkletProcessor extends AudioWorkletProcessor {\n constructor() {\n super();\n this.accumulator = [];\n this.reset();\n this.isProcessing = true;\n // message received from main-thread\n this.port.onmessage = (e) => {\n console.log(\"Worklet received event: \", e.data);\n if (this.sampleSize > 0) {\n this.accumulator.push(this.sampleVal / this.sampleSize);\n }\n if (e.data == \"PAUSE\") {\n // append silence to get last word ASR.\n const silenceSize = 16000 * 2;\n for (let i = 0; i < silenceSize; i++) {\n this.accumulator.push(0);\n }\n }\n this.send();\n if (e.data == \"STOP\") {\n // message sent to main-thread\n this.port.postMessage(\"DONE\");\n this.isProcessing = false;\n }\n };\n }\n\n static get parameterDescriptors() {\n return [\n {\n name: \"scale\",\n defaultValue: 1,\n minValue: 1,\n maxValue: 6,\n },\n {\n name: \"bufferSizeInterval\",\n defaultValue: 1,\n minValue: 1,\n maxValue: 100,\n },\n ];\n }\n\n // 128 frames\n process(inputList, outputList, params) {\n const input = inputList[0];\n if (input && input.length && input[0].length) {\n const output = outputList[0];\n const scale = params.scale[0];\n const bufferSizeInterval = params[\"bufferSizeInterval\"][0];\n console.log(\"BufferSizeInterval\", bufferSizeInterval);\n // Jackpot\n input[0].forEach((float32Element) => {\n const int16Element = Math.min(1, Math.max(-1, float32Element)) * 0x7fff;\n this.sampleVal += int16Element;\n this.sampleSize++;\n if (this.sampleSize == scale) {\n this.accumulator.push(this.sampleVal / this.sampleSize);\n this.reset();\n }\n\n // Comment this when streaming microphone audio\n // output[0][index] = float32Element;\n });\n if (this.accumulator.length >= 125 * 128 * bufferSizeInterval) {\n this.send();\n }\n }\n return this.isProcessing;\n }\n\n send() {\n if (this.accumulator.length == 0) return;\n const audioData = new Int16Array(this.accumulator);\n // message sent to main-thread - transferrable\n this.port.postMessage(audioData.buffer, [audioData.buffer]);\n this.accumulator = [];\n this.reset();\n }\n\n reset() {\n this.sampleVal = 0;\n this.sampleSize = 0;\n }\n}\n\nregisterProcessor(\"worklet-processor\", MyAudioWorkletProcessor);"; | ||
var worklet = "class MyAudioWorkletProcessor extends AudioWorkletProcessor {\n constructor() {\n super();\n this.accumulator = [];\n this.reset();\n this.isProcessing = true;\n // message received from main-thread\n this.port.onmessage = (e) => {\n console.log(\"Worklet received event: \", e.data);\n if (this.sampleSize > 0) {\n this.accumulator.push(this.sampleVal / this.sampleSize);\n }\n if (e.data == \"PAUSE\") {\n // append silence to get last word ASR.\n const silenceSize = 16000 * 2;\n for (let i = 0; i < silenceSize; i++) {\n this.accumulator.push(0);\n }\n }\n this.send();\n if (e.data == \"STOP\") {\n // message sent to main-thread\n this.port.postMessage(\"DONE\");\n this.isProcessing = false;\n }\n };\n }\n\n static get parameterDescriptors() {\n return [\n {\n name: \"scale\",\n defaultValue: 1,\n minValue: 1,\n maxValue: 6,\n },\n {\n name: \"bufferSizeInterval\",\n defaultValue: 1,\n minValue: 1,\n maxValue: 100,\n },\n ];\n }\n\n // 128 frames\n process(inputList, outputList, params) {\n const input = inputList[0];\n if (input && input.length && input[0].length) {\n const output = outputList[0];\n const scale = params.scale[0];\n const bufferSizeInterval = params[\"bufferSizeInterval\"][0];\n // console.log(\"BufferSizeInterval\", bufferSizeInterval);\n // Jackpot\n input[0].forEach((float32Element) => {\n const int16Element = Math.min(1, Math.max(-1, float32Element)) * 0x7fff;\n this.sampleVal += int16Element;\n this.sampleSize++;\n if (this.sampleSize == scale) {\n this.accumulator.push(this.sampleVal / this.sampleSize);\n this.reset();\n }\n\n // Comment this when streaming microphone audio\n // output[0][index] = float32Element;\n });\n if (this.accumulator.length >= 125 * 128 * bufferSizeInterval) {\n this.send();\n }\n }\n return this.isProcessing;\n }\n\n send() {\n if (this.accumulator.length == 0) return;\n const audioData = new Int16Array(this.accumulator);\n // message sent to main-thread - transferrable\n this.port.postMessage(audioData.buffer, [audioData.buffer]);\n this.accumulator = [];\n this.reset();\n }\n\n reset() {\n this.sampleVal = 0;\n this.sampleSize = 0;\n }\n}\n\nregisterProcessor(\"worklet-processor\", MyAudioWorkletProcessor);"; | ||
@@ -630,0 +629,0 @@ // main-thread |
{ | ||
"name": "augnitorecorder", | ||
"version": "1.0.15", | ||
"version": "1.0.16", | ||
"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
112004
1288