@absolutejs/voice 0.0.22-beta.600 → 0.0.22-beta.602

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
@@ -3756,7 +3756,7 @@ var STREAM_CLAUSE_BOUNDARY = /[,;:]\s/g;
3756
3756
  var MAX_TTS_CHUNK_CHARS = 320;
3757
3757
  var STREAM_SENTENCE_END = /[.!?\u2026]['")\]]*$/;
3758
3758
  var STREAM_IDLE_FLUSH_MS = 350;
3759
- var SPECULATIVE_FRACTION = 0.5;
3759
+ var SPECULATIVE_DELAY_MS = 350;
3760
3760
  var nextSpeakableBoundary = (buffer) => {
3761
3761
  const match = STREAM_SENTENCE_BOUNDARY.exec(buffer);
3762
3762
  return match ? match.index + match[0].length : -1;
@@ -3942,6 +3942,8 @@ var createVoiceSession = (options) => {
3942
3942
  };
3943
3943
  let speculativeReply = null;
3944
3944
  let speculativeTimer = null;
3945
+ let speculationAttempted = false;
3946
+ console.info(`[voice][p3dbg] session ${options.id} route.speculate wired=${Boolean(options.route.speculate)}`);
3945
3947
  const sttFallback = options.sttFallback ? {
3946
3948
  adapter: options.sttFallback.adapter,
3947
3949
  completionTimeoutMs: options.sttFallback.completionTimeoutMs ?? DEFAULT_FALLBACK_COMPLETION_TIMEOUT_MS,
@@ -4480,6 +4482,7 @@ var createVoiceSession = (options) => {
4480
4482
  speculativeTimer = null;
4481
4483
  }
4482
4484
  speculativeReply = null;
4485
+ speculationAttempted = false;
4483
4486
  };
4484
4487
  const runSpeculation = async () => {
4485
4488
  if (!options.route.speculate || speculativeReply) {
@@ -4506,19 +4509,23 @@ var createVoiceSession = (options) => {
4506
4509
  session,
4507
4510
  turn: provisionalTurn
4508
4511
  }));
4512
+ console.info(`[voice][p3] speculate fired session=${session.id} -> ${result?.text ? `${result.text.length} chars` : "null"} for "${pendingText.slice(0, 30)}"`);
4509
4513
  if (result && result.text.trim() && !speculativeReply) {
4510
4514
  speculativeReply = { pendingText, text: result.text };
4511
4515
  }
4512
- } catch {}
4516
+ } catch (error) {
4517
+ console.info(`[voice][p3] speculate error: ${error instanceof Error ? error.message : String(error)}`);
4518
+ }
4513
4519
  };
4514
4520
  const scheduleSilenceCommit = (delayMs = adaptiveSilenceMs(), reset = true) => {
4515
4521
  scheduleTurnCommit(delayMs, "silence", reset);
4516
- if (options.route.speculate && reset) {
4517
- clearSpeculation();
4522
+ if (options.route.speculate && reset && !speculationAttempted) {
4523
+ speculationAttempted = true;
4524
+ console.info(`[voice][p3dbg] armed speculation delay=${SPECULATIVE_DELAY_MS} reason=silence session=${options.id}`);
4518
4525
  speculativeTimer = setTimeout(() => {
4519
4526
  speculativeTimer = null;
4520
4527
  runSpeculation();
4521
- }, Math.max(1, Math.round(delayMs * SPECULATIVE_FRACTION)));
4528
+ }, SPECULATIVE_DELAY_MS);
4522
4529
  }
4523
4530
  };
4524
4531
  const runScheduledCommit = async (reason) => {
@@ -5983,7 +5983,7 @@ var STREAM_CLAUSE_BOUNDARY = /[,;:]\s/g;
5983
5983
  var MAX_TTS_CHUNK_CHARS = 320;
5984
5984
  var STREAM_SENTENCE_END = /[.!?\u2026]['")\]]*$/;
5985
5985
  var STREAM_IDLE_FLUSH_MS = 350;
5986
- var SPECULATIVE_FRACTION = 0.5;
5986
+ var SPECULATIVE_DELAY_MS = 350;
5987
5987
  var nextSpeakableBoundary = (buffer) => {
5988
5988
  const match = STREAM_SENTENCE_BOUNDARY.exec(buffer);
5989
5989
  return match ? match.index + match[0].length : -1;
@@ -6169,6 +6169,8 @@ var createVoiceSession = (options) => {
6169
6169
  };
6170
6170
  let speculativeReply = null;
6171
6171
  let speculativeTimer = null;
6172
+ let speculationAttempted = false;
6173
+ console.info(`[voice][p3dbg] session ${options.id} route.speculate wired=${Boolean(options.route.speculate)}`);
6172
6174
  const sttFallback = options.sttFallback ? {
6173
6175
  adapter: options.sttFallback.adapter,
6174
6176
  completionTimeoutMs: options.sttFallback.completionTimeoutMs ?? DEFAULT_FALLBACK_COMPLETION_TIMEOUT_MS,
@@ -6707,6 +6709,7 @@ var createVoiceSession = (options) => {
6707
6709
  speculativeTimer = null;
6708
6710
  }
6709
6711
  speculativeReply = null;
6712
+ speculationAttempted = false;
6710
6713
  };
6711
6714
  const runSpeculation = async () => {
6712
6715
  if (!options.route.speculate || speculativeReply) {
@@ -6733,19 +6736,23 @@ var createVoiceSession = (options) => {
6733
6736
  session,
6734
6737
  turn: provisionalTurn
6735
6738
  }));
6739
+ console.info(`[voice][p3] speculate fired session=${session.id} -> ${result?.text ? `${result.text.length} chars` : "null"} for "${pendingText.slice(0, 30)}"`);
6736
6740
  if (result && result.text.trim() && !speculativeReply) {
6737
6741
  speculativeReply = { pendingText, text: result.text };
6738
6742
  }
6739
- } catch {}
6743
+ } catch (error) {
6744
+ console.info(`[voice][p3] speculate error: ${error instanceof Error ? error.message : String(error)}`);
6745
+ }
6740
6746
  };
6741
6747
  const scheduleSilenceCommit = (delayMs = adaptiveSilenceMs(), reset = true) => {
6742
6748
  scheduleTurnCommit(delayMs, "silence", reset);
6743
- if (options.route.speculate && reset) {
6744
- clearSpeculation();
6749
+ if (options.route.speculate && reset && !speculationAttempted) {
6750
+ speculationAttempted = true;
6751
+ console.info(`[voice][p3dbg] armed speculation delay=${SPECULATIVE_DELAY_MS} reason=silence session=${options.id}`);
6745
6752
  speculativeTimer = setTimeout(() => {
6746
6753
  speculativeTimer = null;
6747
6754
  runSpeculation();
6748
- }, Math.max(1, Math.round(delayMs * SPECULATIVE_FRACTION)));
6755
+ }, SPECULATIVE_DELAY_MS);
6749
6756
  }
6750
6757
  };
6751
6758
  const runScheduledCommit = async (reason) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.600",
3
+ "version": "0.0.22-beta.602",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",