@absolutejs/voice 0.0.22-beta.634 → 0.0.22-beta.635
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/core/types.d.ts +5 -1
- package/dist/index.js +7 -2
- package/dist/testing/index.js +7 -2
- package/package.json +1 -1
package/dist/core/types.d.ts
CHANGED
|
@@ -133,7 +133,7 @@ export type VoiceTurnCostEstimate = {
|
|
|
133
133
|
primaryAudioMs: number;
|
|
134
134
|
totalBillableAudioMs: number;
|
|
135
135
|
};
|
|
136
|
-
export type VoiceFallbackSelectionReason = "fallback-empty" | "primary-empty" | "word-count-margin" | "confidence-margin" | "word-count-tiebreak" | "kept-primary";
|
|
136
|
+
export type VoiceFallbackSelectionReason = "fallback-empty" | "primary-empty" | "word-count-margin" | "confidence-margin" | "word-count-tiebreak" | "policy-preference" | "kept-primary";
|
|
137
137
|
export type VoiceFallbackDiagnostics = {
|
|
138
138
|
attempted: boolean;
|
|
139
139
|
fallbackConfidence?: number;
|
|
@@ -458,6 +458,9 @@ export type VoiceSTTFallbackConfig = {
|
|
|
458
458
|
* language that should receive a second transcription pass regardless of the
|
|
459
459
|
* aggregate confidence. */
|
|
460
460
|
riskPolicy?: VoiceSTTFallbackRiskPolicy;
|
|
461
|
+
/** Prefer a non-empty independent fallback for these audited trigger reasons,
|
|
462
|
+
* including providers that do not expose comparable confidence scores. */
|
|
463
|
+
preferFallbackOn?: VoiceFallbackTriggerReason[];
|
|
461
464
|
};
|
|
462
465
|
export type VoiceResolvedSTTFallbackConfig = {
|
|
463
466
|
adapter: STTAdapter;
|
|
@@ -470,6 +473,7 @@ export type VoiceResolvedSTTFallbackConfig = {
|
|
|
470
473
|
maxAttemptsPerTurn: number;
|
|
471
474
|
wordConfidenceThreshold?: number;
|
|
472
475
|
riskPolicy?: VoiceSTTFallbackRiskPolicy;
|
|
476
|
+
preferFallbackOn?: VoiceFallbackTriggerReason[];
|
|
473
477
|
};
|
|
474
478
|
export type VoiceTurnDetectionConfig = {
|
|
475
479
|
profile?: VoiceTurnProfile;
|
package/dist/index.js
CHANGED
|
@@ -4260,7 +4260,8 @@ var createVoiceSession = (options) => {
|
|
|
4260
4260
|
settleMs: options.sttFallback.settleMs ?? DEFAULT_FALLBACK_SETTLE_MS,
|
|
4261
4261
|
trigger: options.sttFallback.trigger ?? "empty-or-low-confidence",
|
|
4262
4262
|
wordConfidenceThreshold: options.sttFallback.wordConfidenceThreshold,
|
|
4263
|
-
riskPolicy: options.sttFallback.riskPolicy
|
|
4263
|
+
riskPolicy: options.sttFallback.riskPolicy,
|
|
4264
|
+
preferFallbackOn: options.sttFallback.preferFallbackOn
|
|
4264
4265
|
} : undefined;
|
|
4265
4266
|
const appendTrace = async (input) => {
|
|
4266
4267
|
await options.trace?.append({
|
|
@@ -5524,7 +5525,11 @@ var createVoiceSession = (options) => {
|
|
|
5524
5525
|
text: primaryText,
|
|
5525
5526
|
wordCount: countWords2(normalizeText2(primaryText))
|
|
5526
5527
|
};
|
|
5527
|
-
const
|
|
5528
|
+
const policyPrefersFallback = fallbackCandidate.text.length > 0 && fallbackNeed.reason !== undefined && sttFallback.preferFallbackOn?.includes(fallbackNeed.reason);
|
|
5529
|
+
const selection = policyPrefersFallback ? {
|
|
5530
|
+
reason: "policy-preference",
|
|
5531
|
+
winner: fallbackCandidate
|
|
5532
|
+
} : selectBetterTurnText(primaryCandidate, fallbackCandidate);
|
|
5528
5533
|
const diagnostics = {
|
|
5529
5534
|
attempted: true,
|
|
5530
5535
|
fallbackConfidence: fallbackCandidate.confidence,
|
package/dist/testing/index.js
CHANGED
|
@@ -6643,7 +6643,8 @@ var createVoiceSession = (options) => {
|
|
|
6643
6643
|
settleMs: options.sttFallback.settleMs ?? DEFAULT_FALLBACK_SETTLE_MS,
|
|
6644
6644
|
trigger: options.sttFallback.trigger ?? "empty-or-low-confidence",
|
|
6645
6645
|
wordConfidenceThreshold: options.sttFallback.wordConfidenceThreshold,
|
|
6646
|
-
riskPolicy: options.sttFallback.riskPolicy
|
|
6646
|
+
riskPolicy: options.sttFallback.riskPolicy,
|
|
6647
|
+
preferFallbackOn: options.sttFallback.preferFallbackOn
|
|
6647
6648
|
} : undefined;
|
|
6648
6649
|
const appendTrace = async (input) => {
|
|
6649
6650
|
await options.trace?.append({
|
|
@@ -7907,7 +7908,11 @@ var createVoiceSession = (options) => {
|
|
|
7907
7908
|
text: primaryText,
|
|
7908
7909
|
wordCount: countWords2(normalizeText2(primaryText))
|
|
7909
7910
|
};
|
|
7910
|
-
const
|
|
7911
|
+
const policyPrefersFallback = fallbackCandidate.text.length > 0 && fallbackNeed.reason !== undefined && sttFallback.preferFallbackOn?.includes(fallbackNeed.reason);
|
|
7912
|
+
const selection = policyPrefersFallback ? {
|
|
7913
|
+
reason: "policy-preference",
|
|
7914
|
+
winner: fallbackCandidate
|
|
7915
|
+
} : selectBetterTurnText(primaryCandidate, fallbackCandidate);
|
|
7911
7916
|
const diagnostics = {
|
|
7912
7917
|
attempted: true,
|
|
7913
7918
|
fallbackConfidence: fallbackCandidate.confidence,
|