@livekit/agents-plugin-silero 1.0.27 → 1.0.31

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/onnx_model.ts","../../../node_modules/.pnpm/tsup@8.4.0_@microsoft+api-extractor@7.43.7_@types+node@22.15.30__postcss@8.4.38_tsx@4.20.4_typescript@5.4.5/node_modules/tsup/assets/cjs_shims.js"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { fileURLToPath } from 'node:url';\nimport { InferenceSession, Tensor } from 'onnxruntime-node';\n\nexport type SampleRate = 8000 | 16000;\n\nexport const newInferenceSession = (forceCPU: boolean) => {\n return InferenceSession.create(fileURLToPath(new URL('silero_vad.onnx', import.meta.url).href), {\n interOpNumThreads: 1,\n intraOpNumThreads: 1,\n executionMode: 'sequential',\n executionProviders: forceCPU ? [{ name: 'cpu' }] : undefined,\n });\n};\n\nexport class OnnxModel {\n #session: InferenceSession;\n #sampleRate: number;\n #windowSizeSamples: number;\n #contextSize: number;\n #sampleRateNd: BigInt64Array;\n #context: Float32Array;\n // #state: Float32Array;\n #rnnState: Float32Array;\n #inputBuffer: Float32Array;\n\n constructor(session: InferenceSession, sampleRate: SampleRate) {\n this.#session = session;\n this.#sampleRate = sampleRate;\n\n switch (sampleRate) {\n case 8000:\n this.#windowSizeSamples = 256;\n this.#contextSize = 32;\n break;\n case 16000:\n this.#windowSizeSamples = 512;\n this.#contextSize = 64;\n break;\n }\n\n this.#sampleRateNd = BigInt64Array.from([BigInt(sampleRate)]);\n this.#context = new Float32Array(this.#contextSize);\n this.#rnnState = new Float32Array(2 * 1 * 128);\n this.#inputBuffer = new Float32Array(this.#contextSize + this.#windowSizeSamples);\n }\n\n get sampleRate(): number {\n return this.#sampleRate;\n }\n\n get windowSizeSamples(): number {\n return this.#windowSizeSamples;\n }\n\n get contextSize(): number {\n return this.#contextSize;\n }\n\n async run(x: Float32Array): Promise<number> {\n this.#inputBuffer.set(this.#context, 0);\n this.#inputBuffer.set(x, this.#contextSize);\n\n return await this.#session\n .run({\n input: new Tensor('float32', this.#inputBuffer, [\n 1,\n this.#contextSize + this.#windowSizeSamples,\n ]),\n state: new Tensor('float32', this.#rnnState, [2, 1, 128]),\n sr: new Tensor('int64', this.#sampleRateNd),\n })\n .then((result) => {\n // this.#state = result.output.data as Float32Array,\n this.#context = this.#inputBuffer.subarray(0, this.#contextSize);\n return (result.output!.data as Float32Array).at(0)!;\n });\n }\n}\n","// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS,cAAc,OAClD,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;AAEpC,IAAM,gBAAgC,iCAAiB;ADR9D,sBAA8B;AAC9B,8BAAyC;AAIlC,MAAM,sBAAsB,CAAC,aAAsB;AACxD,SAAO,yCAAiB,WAAO,+BAAc,IAAI,IAAI,mBAAmB,aAAe,EAAE,IAAI,GAAG;AAAA,IAC9F,mBAAmB;AAAA,IACnB,mBAAmB;AAAA,IACnB,eAAe;AAAA,IACf,oBAAoB,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC,IAAI;AAAA,EACrD,CAAC;AACH;AAEO,MAAM,UAAU;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA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1
+ {"version":3,"sources":["../src/onnx_model.ts","../../../node_modules/.pnpm/tsup@8.4.0_@microsoft+api-extractor@7.43.7_@types+node@22.19.1__postcss@8.4.38_tsx@4.20.4_typescript@5.4.5/node_modules/tsup/assets/cjs_shims.js"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { fileURLToPath } from 'node:url';\nimport { InferenceSession, Tensor } from 'onnxruntime-node';\n\nexport type SampleRate = 8000 | 16000;\n\nexport const newInferenceSession = (forceCPU: boolean) => {\n return InferenceSession.create(fileURLToPath(new URL('silero_vad.onnx', import.meta.url).href), {\n interOpNumThreads: 1,\n intraOpNumThreads: 1,\n executionMode: 'sequential',\n executionProviders: forceCPU ? [{ name: 'cpu' }] : undefined,\n });\n};\n\nexport class OnnxModel {\n #session: InferenceSession;\n #sampleRate: number;\n #windowSizeSamples: number;\n #contextSize: number;\n #sampleRateNd: BigInt64Array;\n #context: Float32Array;\n // #state: Float32Array;\n #rnnState: Float32Array;\n #inputBuffer: Float32Array;\n\n constructor(session: InferenceSession, sampleRate: SampleRate) {\n this.#session = session;\n this.#sampleRate = sampleRate;\n\n switch (sampleRate) {\n case 8000:\n this.#windowSizeSamples = 256;\n this.#contextSize = 32;\n break;\n case 16000:\n this.#windowSizeSamples = 512;\n this.#contextSize = 64;\n break;\n }\n\n this.#sampleRateNd = BigInt64Array.from([BigInt(sampleRate)]);\n this.#context = new Float32Array(this.#contextSize);\n this.#rnnState = new Float32Array(2 * 1 * 128);\n this.#inputBuffer = new Float32Array(this.#contextSize + this.#windowSizeSamples);\n }\n\n get sampleRate(): number {\n return this.#sampleRate;\n }\n\n get windowSizeSamples(): number {\n return this.#windowSizeSamples;\n }\n\n get contextSize(): number {\n return this.#contextSize;\n }\n\n async run(x: Float32Array): Promise<number> {\n this.#inputBuffer.set(this.#context, 0);\n this.#inputBuffer.set(x, this.#contextSize);\n\n return await this.#session\n .run({\n input: new Tensor('float32', this.#inputBuffer, [\n 1,\n this.#contextSize + this.#windowSizeSamples,\n ]),\n state: new Tensor('float32', this.#rnnState, [2, 1, 128]),\n sr: new Tensor('int64', this.#sampleRateNd),\n })\n .then((result) => {\n // this.#state = result.output.data as Float32Array,\n this.#context = this.#inputBuffer.subarray(0, this.#contextSize);\n return (result.output!.data as Float32Array).at(0)!;\n });\n }\n}\n","// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS,cAAc,OAClD,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;AAEpC,IAAM,gBAAgC,iCAAiB;ADR9D,sBAA8B;AAC9B,8BAAyC;AAIlC,MAAM,sBAAsB,CAAC,aAAsB;AACxD,SAAO,yCAAiB,WAAO,+BAAc,IAAI,IAAI,mBAAmB,aAAe,EAAE,IAAI,GAAG;AAAA,IAC9F,mBAAmB;AAAA,IACnB,mBAAmB;AAAA,IACnB,eAAe;AAAA,IACf,oBAAoB,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC,IAAI;AAAA,EACrD,CAAC;AACH;AAEO,MAAM,UAAU;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EAEA,YAAY,SAA2B,YAAwB;AAC7D,SAAK,WAAW;AAChB,SAAK,cAAc;AAEnB,YAAQ,YAAY;AAAA,MAClB,KAAK;AACH,aAAK,qBAAqB;AAC1B,aAAK,eAAe;AACpB;AAAA,MACF,KAAK;AACH,aAAK,qBAAqB;AAC1B,aAAK,eAAe;AACpB;AAAA,IACJ;AAEA,SAAK,gBAAgB,cAAc,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAC5D,SAAK,WAAW,IAAI,aAAa,KAAK,YAAY;AAClD,SAAK,YAAY,IAAI,aAAa,IAAI,IAAI,GAAG;AAC7C,SAAK,eAAe,IAAI,aAAa,KAAK,eAAe,KAAK,kBAAkB;AAAA,EAClF;AAAA,EAEA,IAAI,aAAqB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,oBAA4B;AAC9B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,cAAsB;AACxB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,IAAI,GAAkC;AAC1C,SAAK,aAAa,IAAI,KAAK,UAAU,CAAC;AACtC,SAAK,aAAa,IAAI,GAAG,KAAK,YAAY;AAE1C,WAAO,MAAM,KAAK,SACf,IAAI;AAAA,MACH,OAAO,IAAI,+BAAO,WAAW,KAAK,cAAc;AAAA,QAC9C;AAAA,QACA,KAAK,eAAe,KAAK;AAAA,MAC3B,CAAC;AAAA,MACD,OAAO,IAAI,+BAAO,WAAW,KAAK,WAAW,CAAC,GAAG,GAAG,GAAG,CAAC;AAAA,MACxD,IAAI,IAAI,+BAAO,SAAS,KAAK,aAAa;AAAA,IAC5C,CAAC,EACA,KAAK,CAAC,WAAW;AAEhB,WAAK,WAAW,KAAK,aAAa,SAAS,GAAG,KAAK,YAAY;AAC/D,aAAQ,OAAO,OAAQ,KAAsB,GAAG,CAAC;AAAA,IACnD,CAAC;AAAA,EACL;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livekit/agents-plugin-silero",
3
- "version": "1.0.27",
3
+ "version": "1.0.31",
4
4
  "description": "Silero voice activity detection LiveKit Node Agents",
5
5
  "main": "dist/index.js",
6
6
  "require": "dist/index.cjs",
@@ -25,21 +25,21 @@
25
25
  "README.md"
26
26
  ],
27
27
  "devDependencies": {
28
- "@livekit/rtc-node": "^0.13.12",
28
+ "@livekit/rtc-node": "^0.13.22",
29
29
  "@microsoft/api-extractor": "^7.35.0",
30
30
  "@types/ws": "^8.5.10",
31
31
  "onnxruntime-common": "1.21.0",
32
32
  "tsup": "^8.3.5",
33
33
  "typescript": "^5.0.0",
34
- "@livekit/agents": "1.0.27"
34
+ "@livekit/agents": "1.0.31"
35
35
  },
36
36
  "dependencies": {
37
37
  "onnxruntime-node": "1.21.0",
38
38
  "ws": "^8.16.0"
39
39
  },
40
40
  "peerDependencies": {
41
- "@livekit/rtc-node": "^0.13.12",
42
- "@livekit/agents": "1.0.27"
41
+ "@livekit/rtc-node": "^0.13.22",
42
+ "@livekit/agents": "1.0.31"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "tsup --onSuccess \"pnpm build:types\" && cp src/silero_vad.onnx dist/",