@omote/core 0.2.1 → 0.2.3

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.
package/dist/index.d.mts CHANGED
@@ -1367,6 +1367,7 @@ declare class SileroVADInference {
1367
1367
  private inferenceQueue;
1368
1368
  private preSpeechBuffer;
1369
1369
  private wasSpeaking;
1370
+ private srTensor;
1370
1371
  constructor(config: SileroVADConfig);
1371
1372
  get backend(): RuntimeBackend | null;
1372
1373
  get isLoaded(): boolean;
package/dist/index.d.ts CHANGED
@@ -1367,6 +1367,7 @@ declare class SileroVADInference {
1367
1367
  private inferenceQueue;
1368
1368
  private preSpeechBuffer;
1369
1369
  private wasSpeaking;
1370
+ private srTensor;
1370
1371
  constructor(config: SileroVADConfig);
1371
1372
  get backend(): RuntimeBackend | null;
1372
1373
  get isLoaded(): boolean;
package/dist/index.js CHANGED
@@ -29016,6 +29016,25 @@ async function isWebGPUAvailable() {
29016
29016
  return false;
29017
29017
  }
29018
29018
  }
29019
+ var iosWasmPatched = false;
29020
+ function applyIOSWasmMemoryPatch() {
29021
+ if (iosWasmPatched || !isIOS()) return;
29022
+ iosWasmPatched = true;
29023
+ const OrigMemory = WebAssembly.Memory;
29024
+ const MAX_IOS_PAGES = 16384;
29025
+ logger.info("Applying iOS WASM memory patch (shared\u2192false, max\u21921GB)");
29026
+ WebAssembly.Memory = function IOSPatchedMemory(descriptor) {
29027
+ const patched = { ...descriptor };
29028
+ if (patched.shared) {
29029
+ patched.shared = false;
29030
+ }
29031
+ if (patched.maximum !== void 0 && patched.maximum > MAX_IOS_PAGES) {
29032
+ patched.maximum = MAX_IOS_PAGES;
29033
+ }
29034
+ return new OrigMemory(patched);
29035
+ };
29036
+ WebAssembly.Memory.prototype = OrigMemory.prototype;
29037
+ }
29019
29038
  function configureWasm(ort) {
29020
29039
  ort.env.wasm.wasmPaths = WASM_CDN_PATH;
29021
29040
  const numThreads = getOptimalWasmThreads();
@@ -29041,6 +29060,7 @@ async function getOnnxRuntime(backend) {
29041
29060
  return ortInstance;
29042
29061
  }
29043
29062
  logger.info(`Loading ONNX Runtime with ${backend} backend...`);
29063
+ applyIOSWasmMemoryPatch();
29044
29064
  try {
29045
29065
  if (backend === "wasm") {
29046
29066
  const module2 = await import("onnxruntime-web");
@@ -30216,6 +30236,8 @@ var SileroVADInference = class {
30216
30236
  // Pre-speech buffer for capturing beginning of speech
30217
30237
  this.preSpeechBuffer = [];
30218
30238
  this.wasSpeaking = false;
30239
+ // Cached sample rate tensor (int64 scalar, never changes per instance)
30240
+ this.srTensor = null;
30219
30241
  const sampleRate = config.sampleRate ?? 16e3;
30220
30242
  if (sampleRate !== 8e3 && sampleRate !== 16e3) {
30221
30243
  throw new Error("Silero VAD only supports 8000 or 16000 Hz sample rates");
@@ -30346,6 +30368,24 @@ var SileroVADInference = class {
30346
30368
  this.context = new Float32Array(this.contextSize);
30347
30369
  this.preSpeechBuffer = [];
30348
30370
  this.wasSpeaking = false;
30371
+ if (!this.srTensor) {
30372
+ try {
30373
+ this.srTensor = new this.ort.Tensor(
30374
+ "int64",
30375
+ new BigInt64Array([BigInt(this.config.sampleRate)]),
30376
+ []
30377
+ );
30378
+ } catch (e) {
30379
+ logger7.warn("BigInt64Array not available, using bigint array fallback", {
30380
+ error: e instanceof Error ? e.message : String(e)
30381
+ });
30382
+ this.srTensor = new this.ort.Tensor(
30383
+ "int64",
30384
+ [BigInt(this.config.sampleRate)],
30385
+ []
30386
+ );
30387
+ }
30388
+ }
30349
30389
  }
30350
30390
  /**
30351
30391
  * Process a single audio chunk
@@ -30477,7 +30517,7 @@ var SileroVADInference = class {
30477
30517
  inputBuffer.set(audioChunkCopy, this.contextSize);
30478
30518
  const inputBufferCopy = new Float32Array(inputBuffer);
30479
30519
  const inputTensor = new this.ort.Tensor("float32", inputBufferCopy, [1, inputSize]);
30480
- const srTensor = new this.ort.Tensor("int64", BigInt64Array.from([BigInt(this.config.sampleRate)]), []);
30520
+ const srTensor = this.srTensor;
30481
30521
  const stateCopy = new Float32Array(this.state.data);
30482
30522
  const stateTensor = new this.ort.Tensor("float32", stateCopy, this.state.dims);
30483
30523
  const feeds = {
@@ -30566,6 +30606,7 @@ var SileroVADInference = class {
30566
30606
  this.session = null;
30567
30607
  }
30568
30608
  this.state = null;
30609
+ this.srTensor = null;
30569
30610
  }
30570
30611
  };
30571
30612
  /**
@@ -30670,7 +30711,14 @@ async function runInference(audio, state, context) {
30670
30711
  // Create tensors
30671
30712
  const inputTensor = new ort.Tensor('float32', new Float32Array(inputBuffer), [1, inputSize]);
30672
30713
  const stateTensor = new ort.Tensor('float32', new Float32Array(state), [2, 1, 128]);
30673
- const srTensor = new ort.Tensor('int64', BigInt64Array.from([BigInt(sampleRate)]), []);
30714
+ // Use BigInt64Array constructor (not .from()) for broader compatibility
30715
+ let srTensor;
30716
+ try {
30717
+ srTensor = new ort.Tensor('int64', new BigInt64Array([BigInt(sampleRate)]), []);
30718
+ } catch (e) {
30719
+ // Fallback for environments without BigInt64Array support
30720
+ srTensor = new ort.Tensor('int64', [BigInt(sampleRate)], []);
30721
+ }
30674
30722
 
30675
30723
  const feeds = {
30676
30724
  'input': inputTensor,