@omote/core 0.4.1 → 0.4.2

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.js CHANGED
@@ -3092,12 +3092,23 @@ var Wav2Vec2Inference = class {
3092
3092
  logger2.debug("Running warmup inference to initialize GPU context");
3093
3093
  const warmupStart = performance.now();
3094
3094
  const silentAudio = new Float32Array(16e3);
3095
- await this.infer(silentAudio, 0);
3095
+ const WARMUP_TIMEOUT_MS = 15e3;
3096
+ const warmupResult = await Promise.race([
3097
+ this.infer(silentAudio, 0).then(() => "ok"),
3098
+ new Promise((r) => setTimeout(() => r("timeout"), WARMUP_TIMEOUT_MS))
3099
+ ]);
3096
3100
  const warmupTimeMs = performance.now() - warmupStart;
3097
- logger2.info("Warmup inference complete", {
3098
- warmupTimeMs: Math.round(warmupTimeMs),
3099
- backend: this._backend
3100
- });
3101
+ if (warmupResult === "timeout") {
3102
+ logger2.warn("Warmup inference timed out \u2014 GPU may be unresponsive. Continuing without warmup.", {
3103
+ timeoutMs: WARMUP_TIMEOUT_MS,
3104
+ backend: this._backend
3105
+ });
3106
+ } else {
3107
+ logger2.info("Warmup inference complete", {
3108
+ warmupTimeMs: Math.round(warmupTimeMs),
3109
+ backend: this._backend
3110
+ });
3111
+ }
3101
3112
  telemetry?.recordHistogram("omote.model.warmup_time", warmupTimeMs, {
3102
3113
  model: "wav2vec2",
3103
3114
  backend: this._backend
@@ -4153,20 +4164,21 @@ var LipSyncWithFallback = class {
4153
4164
  try {
4154
4165
  return await this.implementation.load();
4155
4166
  } catch (error) {
4156
- logger6.warn("GPU model load failed, falling back to CPU model", {
4157
- error: error instanceof Error ? error.message : String(error)
4158
- });
4159
- try {
4160
- await this.implementation.dispose();
4161
- } catch {
4162
- }
4163
- this.implementation = new Wav2ArkitCpuInference({
4164
- modelUrl: this.config.cpuModelUrl
4165
- });
4166
- this.hasFallenBack = true;
4167
- logger6.info("Fallback to Wav2ArkitCpuInference successful");
4168
- return await this.implementation.load();
4167
+ return this.fallbackToCpu(error instanceof Error ? error.message : String(error));
4168
+ }
4169
+ }
4170
+ async fallbackToCpu(reason) {
4171
+ logger6.warn("GPU model load failed, falling back to CPU model", { reason });
4172
+ try {
4173
+ await this.implementation.dispose();
4174
+ } catch {
4169
4175
  }
4176
+ this.implementation = new Wav2ArkitCpuInference({
4177
+ modelUrl: this.config.cpuModelUrl
4178
+ });
4179
+ this.hasFallenBack = true;
4180
+ logger6.info("Fallback to Wav2ArkitCpuInference successful");
4181
+ return await this.implementation.load();
4170
4182
  }
4171
4183
  async infer(audioSamples, identityIndex) {
4172
4184
  return this.implementation.infer(audioSamples, identityIndex);