@fonoster/autopilot 0.7.54 → 0.7.55

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.
@@ -24,16 +24,18 @@ exports.chunkToFloat32Array = chunkToFloat32Array;
24
24
  //
25
25
  // Q. Would it be the same if we just created a new Uint8Array from the chunk?
26
26
  function chunkToFloat32Array(chunk) {
27
- // Check if byteOffset is not aligned
28
- const alignedByteOffset = chunk.byteOffset % Int16Array.BYTES_PER_ELEMENT === 0;
29
27
  let int16Array;
28
+ const alignedByteOffset = chunk.byteOffset % Int16Array.BYTES_PER_ELEMENT === 0;
30
29
  if (alignedByteOffset) {
31
30
  int16Array = new Int16Array(chunk.buffer, chunk.byteOffset, chunk.byteLength / Int16Array.BYTES_PER_ELEMENT);
32
31
  }
33
32
  else {
34
- // Create a new aligned Uint8Array and then an Int16Array from it
35
33
  const alignedChunk = new Uint8Array(chunk);
36
34
  int16Array = new Int16Array(alignedChunk.buffer, alignedChunk.byteOffset, alignedChunk.byteLength / Int16Array.BYTES_PER_ELEMENT);
37
35
  }
38
- return new Float32Array(Array.from(int16Array, (sample) => sample / 32768.0));
36
+ const floatArray = new Float32Array(int16Array.length);
37
+ for (let i = 0; i < int16Array.length; i++) {
38
+ floatArray[i] = int16Array[i] / 32768.0;
39
+ }
40
+ return floatArray;
39
41
  }
@@ -34,11 +34,28 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.makeVad = makeVad;
37
- const logger_1 = require("@fonoster/logger");
37
+ /* eslint-disable no-loops/no-loops */
38
+ /*
39
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
40
+ * http://github.com/fonoster/fonoster
41
+ *
42
+ * This file is part of Fonoster
43
+ *
44
+ * Licensed under the MIT License (the "License");
45
+ * you may not use this file except in compliance with
46
+ * the License. You may obtain a copy of the License at
47
+ *
48
+ * https://opensource.org/licenses/MIT
49
+ *
50
+ * Unless required by applicable law or agreed to in writing, software
51
+ * distributed under the License is distributed on an "AS IS" BASIS,
52
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
53
+ * See the License for the specific language governing permissions and
54
+ * limitations under the License.
55
+ */
38
56
  const ort = __importStar(require("onnxruntime-node"));
39
57
  const chunkToFloat32Array_1 = require("./chunkToFloat32Array");
40
58
  const SileroVadModel_1 = require("./SileroVadModel");
41
- const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
42
59
  const BUFFER_SIZE = 512;
43
60
  async function makeVad(params) {
44
61
  const { pathToModel, activationThreshold, deactivationThreshold, debounceFrames } = params;
@@ -56,7 +73,6 @@ async function makeVad(params) {
56
73
  const audioFrame = buffer.slice(0, BUFFER_SIZE);
57
74
  const remainingBuffer = buffer.slice(BUFFER_SIZE);
58
75
  const result = await silero.process(new Float32Array(audioFrame));
59
- logger.silly("last vad result", { ...result });
60
76
  if (result.isSpeech > activationThreshold) {
61
77
  consecutiveNonSpeechFrames = 0; // Reset non-speech counter
62
78
  consecutiveSpeechFrames++;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/autopilot",
3
- "version": "0.7.54",
3
+ "version": "0.7.55",
4
4
  "description": "Voice AI for the Fonoster platform",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/fonoster#readme",
@@ -36,10 +36,10 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@aws-sdk/client-s3": "^3.712.0",
39
- "@fonoster/common": "^0.7.54",
40
- "@fonoster/logger": "^0.7.54",
41
- "@fonoster/types": "^0.7.54",
42
- "@fonoster/voice": "^0.7.54",
39
+ "@fonoster/common": "^0.7.55",
40
+ "@fonoster/logger": "^0.7.55",
41
+ "@fonoster/types": "^0.7.55",
42
+ "@fonoster/voice": "^0.7.55",
43
43
  "@langchain/community": "^0.3.19",
44
44
  "@langchain/core": "^0.3.23",
45
45
  "@langchain/groq": "^0.1.2",
@@ -57,5 +57,5 @@
57
57
  "devDependencies": {
58
58
  "typescript": "^5.5.4"
59
59
  },
60
- "gitHead": "f762eb57b3e07b679bbb2194d48abaeaf75e88ef"
60
+ "gitHead": "9e6953d9c5fdd753d3742ef3da84b44d56c4c4ed"
61
61
  }