Enhance DuplexPipeline and AssistantsPage for improved interruption handling. Introduce _OPENER_PRE_ROLL_MS constant for a head start on mic capture, and adjust interruption sensitivity settings from 500ms to 180ms across relevant components to optimize responsiveness during assistant interactions.

This commit is contained in:
Xin Wang
2026-02-27 11:51:15 +08:00
parent 6a9b5fcff4
commit 71cbfa2b48
2 changed files with 16 additions and 11 deletions

View File

@@ -178,7 +178,7 @@ export const AssistantsPage: React.FC = () => {
hotwords: [],
tools: [],
botCannotBeInterrupted: false,
interruptionSensitivity: 500,
interruptionSensitivity: 180,
configMode: 'platform',
};
try {
@@ -1049,7 +1049,7 @@ export const AssistantsPage: React.FC = () => {
<div className="relative">
<Input
type="number"
value={selectedAssistant.interruptionSensitivity || 500}
value={selectedAssistant.interruptionSensitivity || 180}
onChange={(e) => updateAssistant('interruptionSensitivity', parseInt(e.target.value) || 0)}
className="w-20 h-8 text-right pr-7 text-xs font-mono bg-black/40 border-white/5"
/>
@@ -1063,7 +1063,7 @@ export const AssistantsPage: React.FC = () => {
min="0"
max="2000"
step="50"
value={selectedAssistant.interruptionSensitivity || 500}
value={selectedAssistant.interruptionSensitivity || 180}
onChange={(e) => updateAssistant('interruptionSensitivity', parseInt(e.target.value))}
className="flex-1 h-1.5 bg-secondary rounded-lg appearance-none cursor-pointer accent-primary"
/>
@@ -2075,13 +2075,14 @@ export const DebugDrawer: React.FC<{
setWsError('');
setDynamicVariablesError('');
closeWs();
if (textTtsEnabled) await ensureAudioContext();
await ensureWsSession();
await startVoiceCapture();
setCallStatus('active');
} catch (e) {
console.error(e);
stopVoiceCapture();
if (textTtsEnabled) await ensureAudioContext();
// Start mic capture before session.start so barge-in works from opener start.
await startVoiceCapture();
await ensureWsSession();
setCallStatus('active');
} catch (e) {
console.error(e);
stopVoiceCapture();
setCallStatus('idle');
const err = e as Error & { __dynamicVariables?: boolean };
if (err.__dynamicVariables) {
@@ -2378,7 +2379,7 @@ export const DebugDrawer: React.FC<{
generatedOpenerEnabled: assistant.generatedOpenerEnabled === true,
bargeIn: {
enabled: assistant.botCannotBeInterrupted !== true,
minDurationMs: assistant.interruptionSensitivity || 500,
minDurationMs: Math.max(0, Number(assistant.interruptionSensitivity ?? 180)),
},
knowledgeBaseId,
knowledge,