@absolutejs/voice 0.0.22-beta.600 → 0.0.22-beta.601
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 +10 -5
- package/dist/testing/index.js +10 -5
- package/package.json +1 -1
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
|
|
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,7 @@ var createVoiceSession = (options) => {
|
|
|
3942
3942
|
};
|
|
3943
3943
|
let speculativeReply = null;
|
|
3944
3944
|
let speculativeTimer = null;
|
|
3945
|
+
let speculationAttempted = false;
|
|
3945
3946
|
const sttFallback = options.sttFallback ? {
|
|
3946
3947
|
adapter: options.sttFallback.adapter,
|
|
3947
3948
|
completionTimeoutMs: options.sttFallback.completionTimeoutMs ?? DEFAULT_FALLBACK_COMPLETION_TIMEOUT_MS,
|
|
@@ -4480,6 +4481,7 @@ var createVoiceSession = (options) => {
|
|
|
4480
4481
|
speculativeTimer = null;
|
|
4481
4482
|
}
|
|
4482
4483
|
speculativeReply = null;
|
|
4484
|
+
speculationAttempted = false;
|
|
4483
4485
|
};
|
|
4484
4486
|
const runSpeculation = async () => {
|
|
4485
4487
|
if (!options.route.speculate || speculativeReply) {
|
|
@@ -4506,19 +4508,22 @@ var createVoiceSession = (options) => {
|
|
|
4506
4508
|
session,
|
|
4507
4509
|
turn: provisionalTurn
|
|
4508
4510
|
}));
|
|
4511
|
+
console.info(`[voice][p3] speculate fired session=${session.id} -> ${result?.text ? `${result.text.length} chars` : "null"} for "${pendingText.slice(0, 30)}"`);
|
|
4509
4512
|
if (result && result.text.trim() && !speculativeReply) {
|
|
4510
4513
|
speculativeReply = { pendingText, text: result.text };
|
|
4511
4514
|
}
|
|
4512
|
-
} catch {
|
|
4515
|
+
} catch (error) {
|
|
4516
|
+
console.info(`[voice][p3] speculate error: ${error instanceof Error ? error.message : String(error)}`);
|
|
4517
|
+
}
|
|
4513
4518
|
};
|
|
4514
4519
|
const scheduleSilenceCommit = (delayMs = adaptiveSilenceMs(), reset = true) => {
|
|
4515
4520
|
scheduleTurnCommit(delayMs, "silence", reset);
|
|
4516
|
-
if (options.route.speculate && reset) {
|
|
4517
|
-
|
|
4521
|
+
if (options.route.speculate && reset && !speculationAttempted) {
|
|
4522
|
+
speculationAttempted = true;
|
|
4518
4523
|
speculativeTimer = setTimeout(() => {
|
|
4519
4524
|
speculativeTimer = null;
|
|
4520
4525
|
runSpeculation();
|
|
4521
|
-
},
|
|
4526
|
+
}, SPECULATIVE_DELAY_MS);
|
|
4522
4527
|
}
|
|
4523
4528
|
};
|
|
4524
4529
|
const runScheduledCommit = async (reason) => {
|
package/dist/testing/index.js
CHANGED
|
@@ -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
|
|
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,7 @@ var createVoiceSession = (options) => {
|
|
|
6169
6169
|
};
|
|
6170
6170
|
let speculativeReply = null;
|
|
6171
6171
|
let speculativeTimer = null;
|
|
6172
|
+
let speculationAttempted = false;
|
|
6172
6173
|
const sttFallback = options.sttFallback ? {
|
|
6173
6174
|
adapter: options.sttFallback.adapter,
|
|
6174
6175
|
completionTimeoutMs: options.sttFallback.completionTimeoutMs ?? DEFAULT_FALLBACK_COMPLETION_TIMEOUT_MS,
|
|
@@ -6707,6 +6708,7 @@ var createVoiceSession = (options) => {
|
|
|
6707
6708
|
speculativeTimer = null;
|
|
6708
6709
|
}
|
|
6709
6710
|
speculativeReply = null;
|
|
6711
|
+
speculationAttempted = false;
|
|
6710
6712
|
};
|
|
6711
6713
|
const runSpeculation = async () => {
|
|
6712
6714
|
if (!options.route.speculate || speculativeReply) {
|
|
@@ -6733,19 +6735,22 @@ var createVoiceSession = (options) => {
|
|
|
6733
6735
|
session,
|
|
6734
6736
|
turn: provisionalTurn
|
|
6735
6737
|
}));
|
|
6738
|
+
console.info(`[voice][p3] speculate fired session=${session.id} -> ${result?.text ? `${result.text.length} chars` : "null"} for "${pendingText.slice(0, 30)}"`);
|
|
6736
6739
|
if (result && result.text.trim() && !speculativeReply) {
|
|
6737
6740
|
speculativeReply = { pendingText, text: result.text };
|
|
6738
6741
|
}
|
|
6739
|
-
} catch {
|
|
6742
|
+
} catch (error) {
|
|
6743
|
+
console.info(`[voice][p3] speculate error: ${error instanceof Error ? error.message : String(error)}`);
|
|
6744
|
+
}
|
|
6740
6745
|
};
|
|
6741
6746
|
const scheduleSilenceCommit = (delayMs = adaptiveSilenceMs(), reset = true) => {
|
|
6742
6747
|
scheduleTurnCommit(delayMs, "silence", reset);
|
|
6743
|
-
if (options.route.speculate && reset) {
|
|
6744
|
-
|
|
6748
|
+
if (options.route.speculate && reset && !speculationAttempted) {
|
|
6749
|
+
speculationAttempted = true;
|
|
6745
6750
|
speculativeTimer = setTimeout(() => {
|
|
6746
6751
|
speculativeTimer = null;
|
|
6747
6752
|
runSpeculation();
|
|
6748
|
-
},
|
|
6753
|
+
}, SPECULATIVE_DELAY_MS);
|
|
6749
6754
|
}
|
|
6750
6755
|
};
|
|
6751
6756
|
const runScheduledCommit = async (reason) => {
|