Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(call): keep listening through a short pause in calls (850 ms -> 1.7 s)

AdityaUmalefe5c67a051c6
diff --git a/docs/voice-mode.md b/docs/voice-mode.md
index c14f3e8723..bbcb08c56b 100644
--- a/docs/voice-mode.md
+++ b/docs/voice-mode.md
@@ -57,8 +57,8 @@ barge-in needs AEC on the capture path — a real follow-up, not a footnote.
`SFSpeechRecognizer` does not emit `isFinal` just because the speaker becomes
quiet; it finalizes only after its audio stream ends. Call mode therefore starts
the native helper with a silence timeout. Once a non-empty transcript stops
-changing for 850ms, the helper stops capture and calls `endAudio()`, which
-produces the final transcript sent to the renderer. Composer dictation omits the
+changing for 1.7 s (`CALL_ENDPOINT_MS`), the helper stops capture and calls
+`endAudio()`, which produces the final transcript sent to the renderer. Composer dictation omits the
timeout and keeps its press-to-stop behavior. No cloud STT or bundled VAD model
is involved.
diff --git a/src/components/CallView.tsx b/src/components/CallView.tsx
index bd7a5150cf..c90f5b5fec 100644
--- a/src/components/CallView.tsx
+++ b/src/components/CallView.tsx
@@ -27,13 +27,12 @@ import { callStarted } from "@/lib/product-events";
import { useDesktopCapabilities } from "./DesktopCapabilities";
import { callCapabilityHelp, type CallCapabilityHelp } from "@/lib/call-capability";
import { onCallStartRequest } from "@/lib/call-start-request";
-import { fishListeningReady, listensHere, speechBridge } from "@/lib/speech";
+import { CALL_ENDPOINT_MS, fishListeningReady, listensHere, speechBridge } from "@/lib/speech";
import { VoiceSetupDialog } from "./VoiceSetupDialog";
import { openBotSettings } from "./bot-panel/panel-link";
import { MENU_SHEET } from "./menu-recipe";
type Phase = "listening" | "sending" | "working" | "speaking";
-const CALL_ENDPOINT_MS = 850;
/** `panel`: the small round button beside the bot in its panel, with no chevron. It leaves the composer's + menu to the
* composer's own button: two buttons answering it would start two calls. */
diff --git a/src/components/GroupCallView.tsx b/src/components/GroupCallView.tsx
index 3f8436b484..ad13d163ec 100644
--- a/src/components/GroupCallView.tsx
+++ b/src/components/GroupCallView.tsx
@@ -16,14 +16,13 @@ import { cn } from "@/lib/cn";
import { BotAvatar } from "./Avatar";
import { CallTargetButton, type CallButtonPlacement } from "./CallView";
import { useAdvancedMode } from "@/lib/interface-mode";
-import { speechBridge } from "@/lib/speech";
+import { CALL_ENDPOINT_MS, speechBridge } from "@/lib/speech";
import { useDesktopCapabilities } from "./DesktopCapabilities";
import { isRoutineApproval, isSkillApproval, pendingApprovals, spokenApprovalPrompt } from "./PendingApproval";
import { titledCard } from "./ApprovalCard";
const YES = /^(yes|yeah|yep|yup|sure|ok|okay|go ahead|do it|allow|approve|approved|fine|please do)\b/i;
const NO = /^(no|nope|don'?t|do not|stop|deny|denied|cancel|never|skip it)\b/i;
-const CALL_ENDPOINT_MS = 850;
type Phase = "listening" | "sending" | "working" | "speaking";
diff --git a/src/lib/speech.test.ts b/src/lib/speech.test.ts
index 3794332e3c..f3e22a0302 100644
--- a/src/lib/speech.test.ts
+++ b/src/lib/speech.test.ts
@@ -1,8 +1,8 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import type { ConfigStatus } from "@/state/store";
import { cacheDesktopCapabilities, initialDesktopCapabilities } from "./desktop";
-import { fishSpeech } from "./fish-speech";
-import { fishListeningReady, listensHere, speechBridge } from "./speech";
+import { createEndpointer, fishSpeech } from "./fish-speech";
+import { CALL_ENDPOINT_MS, fishListeningReady, listensHere, speechBridge } from "./speech";
const withDictation = (dictation: DesktopCapabilities["dictation"]): DesktopCapabilities =>
({ ...initialDesktopCapabilities(), dictation });
@@ -48,3 +48,24 @@ describe("listening readiness", () => {
expect(listensHere(withDictation({ available: false, engine: "none", onDevice: false }), savedFish)).toBe(false);
});
});
+
+describe("CALL_ENDPOINT_MS", () => {
+ const FRAME = 64;
+ const run = (endpoint: number, quietMs: number) => {
+ const heard = createEndpointer(endpoint, FRAME);
+ for (let i = 0; i < 10; i += 1) heard(0.1);
+ let last = heard(0);
+ for (let quiet = FRAME; quiet < quietMs; quiet += FRAME) last = heard(0);
+ return last;
+ };
+
+ it("keeps listening through a short thinking pause in a call", () => {
+ expect(CALL_ENDPOINT_MS).toBeGreaterThanOrEqual(1_500);
+ expect(run(CALL_ENDPOINT_MS, 1_200)).toBe("speaking");
+ });
+
+ it("still ends the turn once the person has stopped speaking", () => {
+ expect(CALL_ENDPOINT_MS).toBeLessThanOrEqual(2_500);
+ expect(run(CALL_ENDPOINT_MS, CALL_ENDPOINT_MS + FRAME)).toBe("done");
+ });
+});
diff --git a/src/lib/speech.ts b/src/lib/speech.ts
index 9850b427dd..e08ae63159 100644
--- a/src/lib/speech.ts
+++ b/src/lib/speech.ts
@@ -3,6 +3,10 @@ import type { ConfigStatus } from "@/state/store";
import { desktopCapabilitiesNow } from "./desktop";
import { fishSpeech, type SpeechBridge } from "./fish-speech";
+/** Quiet after speech that ends the person's turn in a call, through the Mac's helper or Fish Audio alike: long enough
+ * for a short thinking pause mid-sentence. */
+export const CALL_ENDPOINT_MS = 1_700;
+
/** The speech bridge this computer listens through: the page's own Fish Audio listener, or the desktop app's helper. */
export function speechBridge(): SpeechBridge | Window["ogb"] {
return desktopCapabilitiesNow().dictation.engine === "fish-audio" ? fishSpeech : globalThis.window?.ogb;