@omote/core 0.9.6 → 0.9.7

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
@@ -1237,7 +1237,7 @@ function applyProfile(raw, profile, out) {
1237
1237
 
1238
1238
  // src/audio/PlaybackPipeline.ts
1239
1239
  var logger5 = createLogger("PlaybackPipeline");
1240
- var PlaybackPipeline = class extends EventEmitter {
1240
+ var _PlaybackPipeline = class _PlaybackPipeline extends EventEmitter {
1241
1241
  constructor(config) {
1242
1242
  super();
1243
1243
  this.config = config;
@@ -1256,6 +1256,10 @@ var PlaybackPipeline = class extends EventEmitter {
1256
1256
  this.neutralTransitionFrame = null;
1257
1257
  this.neutralTransitionStart = 0;
1258
1258
  this.neutralAnimationId = null;
1259
+ this.rampInActive = false;
1260
+ this.rampInLastTime = 0;
1261
+ this.rampInStartTime = 0;
1262
+ this._rampInBuffer = new Float32Array(52);
1259
1263
  // Current frame refs
1260
1264
  this._currentFrame = null;
1261
1265
  this._currentRawFrame = null;
@@ -1282,6 +1286,7 @@ var PlaybackPipeline = class extends EventEmitter {
1282
1286
  modelId: config.lam.modelId,
1283
1287
  neutralTransitionEnabled: this.neutralTransitionEnabled
1284
1288
  });
1289
+ this.rampInSmoother = new BlendshapeSmoother({ halflife: _PlaybackPipeline.RAMP_IN_HALFLIFE });
1285
1290
  this.scheduler = new AudioScheduler({
1286
1291
  sampleRate: this.sampleRate,
1287
1292
  initialLookaheadSec: audioDelayMs / 1e3
@@ -1349,6 +1354,10 @@ var PlaybackPipeline = class extends EventEmitter {
1349
1354
  this.frameLoopCount = 0;
1350
1355
  this._currentFrame = null;
1351
1356
  this._currentRawFrame = null;
1357
+ this.rampInSmoother.reset();
1358
+ this.rampInActive = true;
1359
+ this.rampInLastTime = 0;
1360
+ this.rampInStartTime = 0;
1352
1361
  this.cancelNeutralTransition();
1353
1362
  this.scheduler.warmup();
1354
1363
  this.sessionStartTime = getClock().now();
@@ -1485,17 +1494,36 @@ var PlaybackPipeline = class extends EventEmitter {
1485
1494
  }
1486
1495
  }
1487
1496
  if (lamFrame) {
1488
- const scaled = applyProfile(lamFrame, this.profile, this._profileBuffer);
1497
+ let effectiveFrame = lamFrame;
1498
+ if (this.rampInActive) {
1499
+ const now = getClock().now();
1500
+ if (this.rampInLastTime === 0) {
1501
+ this.rampInStartTime = now;
1502
+ this.rampInLastTime = now;
1503
+ }
1504
+ this.rampInSmoother.setTarget(lamFrame);
1505
+ const dt = (now - this.rampInLastTime) / 1e3;
1506
+ this.rampInLastTime = now;
1507
+ if (dt > 0) {
1508
+ const smoothed = this.rampInSmoother.update(dt);
1509
+ this._rampInBuffer.set(smoothed);
1510
+ effectiveFrame = this._rampInBuffer;
1511
+ }
1512
+ if (now - this.rampInStartTime > _PlaybackPipeline.RAMP_IN_DURATION_MS) {
1513
+ this.rampInActive = false;
1514
+ }
1515
+ }
1516
+ const scaled = applyProfile(effectiveFrame, this.profile, this._profileBuffer);
1489
1517
  this._currentFrame = scaled;
1490
- this._currentRawFrame = lamFrame;
1518
+ this._currentRawFrame = effectiveFrame;
1491
1519
  const fullFrame = {
1492
1520
  blendshapes: scaled,
1493
- rawBlendshapes: lamFrame,
1521
+ rawBlendshapes: effectiveFrame,
1494
1522
  timestamp: currentTime,
1495
1523
  emotion: this._emotion ?? void 0
1496
1524
  };
1497
1525
  this.emit("frame", fullFrame);
1498
- this.emit("frame:raw", lamFrame);
1526
+ this.emit("frame:raw", effectiveFrame);
1499
1527
  }
1500
1528
  this.frameAnimationId = requestAnimationFrame(updateFrame);
1501
1529
  };
@@ -1595,6 +1623,11 @@ var PlaybackPipeline = class extends EventEmitter {
1595
1623
  this.emit("state", state);
1596
1624
  }
1597
1625
  };
1626
+ // Ramp-in smoother: smooths neutral → first inference frame at start-of-speech
1627
+ _PlaybackPipeline.RAMP_IN_HALFLIFE = 0.05;
1628
+ // 50ms — snappy but smooth
1629
+ _PlaybackPipeline.RAMP_IN_DURATION_MS = 150;
1630
+ var PlaybackPipeline = _PlaybackPipeline;
1598
1631
 
1599
1632
  // src/audio/TTSPlayback.ts
1600
1633
  var logger6 = createLogger("TTSPlayback");