@omote/core 0.9.5 → 0.9.6

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.mjs CHANGED
@@ -806,18 +806,19 @@ var _A2EProcessor = class _A2EProcessor {
806
806
  */
807
807
  async flush() {
808
808
  if (this.disposed || this.writeOffset === 0) return;
809
+ const actualSamples = this.writeOffset;
809
810
  const padded = new Float32Array(this.chunkSize);
810
- padded.set(this.buffer.subarray(0, this.writeOffset), 0);
811
+ padded.set(this.buffer.subarray(0, actualSamples), 0);
811
812
  const chunkTimestamp = this.bufferStartTime > 0 ? this.bufferStartTime : void 0;
812
813
  logger4.info("flush: routing through drain pipeline", {
813
- actualSamples: this.writeOffset,
814
+ actualSamples,
814
815
  chunkTimestamp: chunkTimestamp?.toFixed(3),
815
816
  pendingChunks: this.pendingChunks.length,
816
817
  inferenceRunning: this.inferenceRunning
817
818
  });
818
819
  this.writeOffset = 0;
819
820
  this.bufferStartTime = 0;
820
- this.pendingChunks.push({ chunk: padded, timestamp: chunkTimestamp });
821
+ this.pendingChunks.push({ chunk: padded, timestamp: chunkTimestamp, actualSamples });
821
822
  this.drainPendingChunks();
822
823
  }
823
824
  /**
@@ -975,14 +976,15 @@ var _A2EProcessor = class _A2EProcessor {
975
976
  logger4.info("drainPendingChunks starting", { pendingChunks: this.pendingChunks.length });
976
977
  const processNext = async () => {
977
978
  while (this.pendingChunks.length > 0 && !this.disposed) {
978
- const { chunk, timestamp } = this.pendingChunks.shift();
979
+ const { chunk, timestamp, actualSamples } = this.pendingChunks.shift();
979
980
  try {
980
981
  const t0 = getClock().now();
981
982
  const result = await this.backend.infer(chunk, this.identityIndex);
982
983
  const inferMs = Math.round(getClock().now() - t0);
983
- const actualDuration = chunk.length / this.sampleRate;
984
+ const effectiveSamples = actualSamples ?? chunk.length;
985
+ const actualDuration = effectiveSamples / this.sampleRate;
984
986
  const actualFrameCount = Math.ceil(actualDuration * FRAME_RATE);
985
- const framesToQueue = Math.min(actualFrameCount, result.blendshapes.length);
987
+ const framesToQueue = Math.min(Math.max(1, actualFrameCount), result.blendshapes.length);
986
988
  logger4.info("Inference complete", {
987
989
  inferMs,
988
990
  modelFrames: result.blendshapes.length,