Skip to content

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

feat(live): each bot can have its own Live call voice

AdityaUmale0d57d313c9dc
diff --git a/packages/phone-protocol/src/live-call.ts b/packages/phone-protocol/src/live-call.ts
index 590653de6c..ae3024fb13 100644
--- a/packages/phone-protocol/src/live-call.ts
+++ b/packages/phone-protocol/src/live-call.ts
@@ -130,6 +130,16 @@ export function geminiLiveVoice(voice: string | undefined): string {
return GEMINI_LIVE_VOICE_OPTIONS.find((option) => option.id === voice?.trim())?.id ?? GEMINI_LIVE_DEFAULT_VOICE;
}
+/** Whether `voice` is one of the voices a bot can have of its own for Live calls: a GPT-Live or a Gemini Live voice. */
+export function isBotLiveVoice(voice: unknown): boolean {
+ return [...LIVE_VOICE_OPTIONS, ...GEMINI_LIVE_VOICE_OPTIONS].some((option) => option.id === voice);
+}
+
+/** The voice a Live call with a bot speaks in: the bot's own voice when it is one of this provider's, else the app's. */
+export function botCallVoice(botVoice: string | undefined, appVoice: string | undefined, gemini: boolean): string | undefined {
+ return (gemini ? GEMINI_LIVE_VOICE_OPTIONS : LIVE_VOICE_OPTIONS).some((option) => option.id === botVoice) ? botVoice : appVoice;
+}
+
/** A call's length as a clock: m:ss under an hour ("0:07", "1:42"),
* h:mm:ss from an hour on ("1:02:05"). Whole seconds; a value that is not a
* length reads as 0:00. */
diff --git a/packages/phone-protocol/src/wire.ts b/packages/phone-protocol/src/wire.ts
index 0a6b47f65c..9cc07c97de 100644
--- a/packages/phone-protocol/src/wire.ts
+++ b/packages/phone-protocol/src/wire.ts
@@ -325,6 +325,8 @@ export interface WireBot extends DefaultBotFields, BotAccessFields {
replyStyle?: ReplyStyle;
/** This bot's own voice id, so a room of bots doesn't sound like one person. */
voice?: string;
+ /** This bot's own Live call voice, a GPT-Live or Gemini Live voice id; absent, or not the call provider's, uses the app's. */
+ liveVoice?: string;
/** Whether this bot may send voice notes. Absent/true = allowed; false
* hides the tool and refuses the route even with a voice configured. */
voiceNotes?: boolean; /** The harness speaks each reply as a voice note; absent follows the installation's `tts.everyReply`. */ voiceNoteEveryReply?: boolean;
diff --git a/server/index.ts b/server/index.ts
index ba50e85191..81ccd899c8 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -12481,7 +12481,7 @@ const liveCalls = new LiveCallController({
return task.activity === "waiting-on-you" ? "waiting" : "working";
},
broadcast: (frame) => broadcast(frame, { adminOnly: true }),
- settings: () => liveCallSettings(cfg),
+ settings: () => liveCallSettings(cfg), botVoice: (botId) => store.bot(botId)?.liveVoice,
azureRefusal: (auth) => azureLiveCallRefusal(auth, { othersOnLoopback: adminActivityRecording() }),
...liveWiring.calls,
speakable: (text) => toUtterances(text),
diff --git a/server/live-call-controller.test.ts b/server/live-call-controller.test.ts
index 41abac4f29..dd6db45819 100644
--- a/server/live-call-controller.test.ts
+++ b/server/live-call-controller.test.ts
@@ -93,6 +93,23 @@ describe("LiveCallController lifecycle", () => {
expect(t.frames.map((f) => f?.status)).toEqual(["connecting", "live"]);
});
+ it("speaks in the called bot's own Live voice; a bot without one keeps the app's", async () => {
+ const voices: Record<string, string> = { bot1: "cedar" };
+ const own = setup({ botVoice: (botId) => voices[botId] });
+ const started = await own.controller.start({ auth: owner, ...BOT, client: "desktop", sdp: "a" });
+ expect(own.deps.createSession).toHaveBeenCalledWith(expect.objectContaining({ botId: "bot1", voice: "cedar" }));
+ expect(started.call.voice).toBe("cedar");
+ const other = setup({ botVoice: (botId) => voices[botId] });
+ await other.controller.start({ auth: owner, ...BOT, botId: "bot2", client: "desktop", sdp: "a" });
+ expect(other.deps.createSession).toHaveBeenCalledWith(expect.objectContaining({ botId: "bot2", voice: "sol" }));
+ });
+
+ it("uses the app's voice when the bot's own is not a GPT-Live voice", async () => {
+ const t = setup({ botVoice: () => "Kore" });
+ await t.controller.start({ auth: owner, ...BOT, client: "desktop", sdp: "a" });
+ expect(t.deps.createSession).toHaveBeenCalledWith(expect.objectContaining({ voice: "sol" }));
+ });
+
it("refuses a second call while one is active, before creating a session", async () => {
const t = setup();
const first = t.controller.start({ auth: owner, ...BOT, client: "desktop", sdp: "a" });
@@ -517,6 +534,18 @@ describe("LiveCallController lifecycle", () => {
expect(plain.deps.createSession).toHaveBeenCalledWith(expect.objectContaining({ voice: "Puck" }));
});
+ it("speaks in the called bot's own Gemini voice, and the app's when the bot's is GPT-Live's", async () => {
+ const voices: Record<string, string> = { bot1: "Kore", bot2: "cedar" };
+ const t = gemini({ botVoice: (botId) => voices[botId] });
+ Object.assign(t.settings, { geminiVoice: "Charon" });
+ await t.controller.start({ auth: owner, ...BOT, client: "web" });
+ expect(t.deps.createSession).toHaveBeenCalledWith(expect.objectContaining({ voice: "Kore" }));
+ const other = gemini({ botVoice: (botId) => voices[botId] });
+ Object.assign(other.settings, { geminiVoice: "Charon" });
+ await other.controller.start({ auth: owner, ...BOT, botId: "bot2", client: "web" });
+ expect(other.deps.createSession).toHaveBeenCalledWith(expect.objectContaining({ voice: "Charon" }));
+ });
+
it("refuses with the reason as a 403 before any session is taken", async () => {
const t = gemini({ geminiRefusal: () => "not you" });
await expect(t.controller.start({ auth: owner, ...BOT, client: "web" })).rejects.toMatchObject({ status: 403, message: "not you" });
diff --git a/server/live-call-controller.ts b/server/live-call-controller.ts
index 32d6c72d4a..1f5c6ff652 100644
--- a/server/live-call-controller.ts
+++ b/server/live-call-controller.ts
@@ -4,7 +4,7 @@ import { spokenConsent } from "../shared/call-consent.ts";
import {
LIVE_COPY, liveCardKind, liveStepLabel, spokenApprovalPrompt, spokenConnectorPrompt, spokenQuestionPrompt, spokenReviewPrompt, spokenSecretPrompt, spokenSignInPrompt,
} from "../shared/live-approval.ts";
-import { clampAppend, commentaryChunks, geminiLiveVoice, LiveTranscript } from "../shared/live-call.ts";
+import { botCallVoice, clampAppend, commentaryChunks, geminiLiveVoice, LiveTranscript } from "../shared/live-call.ts";
import { signInWaits } from "../shared/sign-in-request.ts";
import type { LiveCallRecord, LiveCallState, LiveClient, LiveElevenLabsTransport, LiveEndReason, LiveFishTransport, LiveGeminiTransport, LiveProvider } from "../shared/wire.ts";
import { FISH_AGENT_VOICE } from "./live-fish.ts";
@@ -69,6 +69,8 @@ export interface LiveCallDeps {
broadcast(frame: { kind: "live.call"; botId: string; threadId: string; call: LiveCallState | null }): void;
/** `endpoint` null, or a `setupProblem`, refuses the call with that message (409). */
settings(): { key: string; endpoint: LiveEndpoint | null; setupProblem?: string | null; provider?: LiveProvider; voice: string; geminiVoice?: string; readTypedReplies: boolean; idleMinutes: number };
+ /** The called bot's own Live call voice, used over the app's when it is the call provider's. */
+ botVoice?(botId: string): string | undefined;
/** Why this caller may not hold a call through Azure OpenAI; null when they may. Required, so no wiring can leave it out. */
azureRefusal(auth: RequestAuth): string | null;
/** The same for the relayed providers, where the harness hears the call only through its client's reports. Required too. */
@@ -203,7 +205,9 @@ export class LiveCallController {
const endpoint = settings.endpoint;
if (settings.setupProblem || !key || !endpoint) throw new LiveSessionError(settings.setupProblem || LIVE_NEEDS_KEY, 409);
if (relayed !== relayedProvider(endpoint.provider)) throw new LiveSessionError(settings.setupProblem || LIVE_NEEDS_KEY, 409);
- const voice = relayed === "gemini" ? geminiLiveVoice(settings.geminiVoice) : relayed ? FISH_AGENT_VOICE : liveVoice(settings.voice);
+ const botVoice = this.deps.botVoice?.(input.botId);
+ const voice = relayed === "gemini" ? geminiLiveVoice(botCallVoice(botVoice, settings.geminiVoice, true))
+ : relayed ? FISH_AGENT_VOICE : liveVoice(botCallVoice(botVoice, settings.voice, false));
const call = this.newCall(input, key, endpoint, voice);
// Taken before the first await: a second start in the same tick is refused.
this.call = call;
diff --git a/server/routes/bot-patch.test.ts b/server/routes/bot-patch.test.ts
index 9e5a99e17b..0a9b7e02a0 100644
--- a/server/routes/bot-patch.test.ts
+++ b/server/routes/bot-patch.test.ts
@@ -263,6 +263,29 @@ describe("PATCH /api/bots/:id toolsOff", () => {
});
});
+describe("PATCH /api/bots/:id liveVoice", () => {
+ it("gives one bot its own Live call voice, leaves the others on the app's, clears it, and refuses a voice that is not a Live one", async () => {
+ const { store, bot, patch } = fixture();
+ const other = store.createBot({ name: "Echo" });
+ expect((await patch(bot.id, { liveVoice: "cedar" })).status).toBe(200);
+ expect(store.bot(bot.id)?.liveVoice).toBe("cedar");
+ expect(store.bot(other.id)?.liveVoice).toBeUndefined();
+ expect((await patch(bot.id, { liveVoice: "Kore" })).status).toBe(200);
+ expect(store.bot(bot.id)?.liveVoice).toBe("Kore");
+ for (const liveVoice of ["robot", "kore", 7, "cedar ".repeat(3)]) {
+ const refused = await patch(bot.id, { liveVoice });
+ expect(refused.status, String(liveVoice)).toBe(400);
+ expect(refused.body.error).toBe("liveVoice must be a GPT-Live or Gemini Live voice, or empty");
+ }
+ expect(store.bot(bot.id)?.liveVoice).toBe("Kore");
+ expect((await patch(bot.id, { liveVoice: "" })).status).toBe(200);
+ expect(store.bot(bot.id)?.liveVoice).toBeUndefined();
+ await patch(bot.id, { liveVoice: "ash" });
+ expect((await patch(bot.id, { liveVoice: null })).status).toBe(200);
+ expect(store.bot(bot.id)?.liveVoice).toBeUndefined();
+ });
+});
+
describe("PATCH /api/bots/:id phoneApps", () => {
it("stores phoneApps and clears it with null", async () => {
const { store, bot, patch } = fixture();
diff --git a/server/routes/bot-patch.ts b/server/routes/bot-patch.ts
index 2bed4c9e65..0b8002b49b 100644
--- a/server/routes/bot-patch.ts
+++ b/server/routes/bot-patch.ts
@@ -2,6 +2,7 @@ import { z } from "zod";
import { approvalModeFor, isApprovalMode, type ApprovalMode } from "../../shared/approval-mode.ts";
import { normalizeConnectorScopes } from "../../shared/connector-scopes.ts";
+import { isBotLiveVoice } from "../../shared/live-call.ts";
import { normalizeOutboundPolicy } from "../../shared/outbound.ts";
import { normalizePhoneApps } from "../../shared/phone-apps.ts";
import { parseToolScope, toolScopeWidens } from "../../shared/tool-scope.ts";
@@ -293,6 +294,11 @@ export function createBotPatchRoutes(deps: BotPatchRouteDeps): RouteHandler {
if (body.voiceNoteEveryReply !== null && typeof body.voiceNoteEveryReply !== "boolean") return json(res, 400, { error: "voiceNoteEveryReply must be true, false or null" });
patch.voiceNoteEveryReply = body.voiceNoteEveryReply ?? undefined;
}
+ // The bot's own Live call voice; "" or null: the app's voice again.
+ if (body.liveVoice !== undefined) {
+ if (body.liveVoice !== null && body.liveVoice !== "" && !isBotLiveVoice(body.liveVoice)) return json(res, 400, { error: "liveVoice must be a GPT-Live or Gemini Live voice, or empty" });
+ patch.liveVoice = body.liveVoice || undefined;
+ }
// Spends the Cloud plan's monthly X research calls: an admin decision too.
if (body.xResearch !== undefined) {
if (typeof body.xResearch !== "boolean") return json(res, 400, { error: "xResearch must be true or false" });
diff --git a/src/components/LiveCallBar.tsx b/src/components/LiveCallBar.tsx
index 0b3c2527bf..c27b4c357d 100644
--- a/src/components/LiveCallBar.tsx
+++ b/src/components/LiveCallBar.tsx
@@ -219,6 +219,7 @@ export function LiveCallBar({ bot }: { bot: Bot }) {
{settingsOpen && (
<div className="absolute bottom-full right-0 z-40 mb-2">
<LiveCallSettings
+ bot={bot}
onClose={() => {
setSettingsOpen(false);
gearRef.current?.focus();
diff --git a/src/components/LiveCallSettings.tsx b/src/components/LiveCallSettings.tsx
index ce764ad969..245bcf9117 100644
--- a/src/components/LiveCallSettings.tsx
+++ b/src/components/LiveCallSettings.tsx
@@ -1,9 +1,9 @@
import { useCallback, useId, useState } from "react";
-import { GEMINI_LIVE_VOICE_OPTIONS, geminiLiveVoice, LIVE_VOICE_OPTIONS } from "../../shared/live-call";
+import { botCallVoice, GEMINI_LIVE_VOICE_OPTIONS, geminiLiveVoice, LIVE_VOICE_OPTIONS } from "../../shared/live-call";
import { t } from "@/lib/i18n";
import { liveDisclosure, liveKeyCopy } from "@/lib/call-mode";
-import { api, useStore, type ConfigStatus } from "@/state/store";
+import { api, useStore, type Bot, type ConfigStatus } from "@/state/store";
import type { LiveSettings } from "../../shared/wire";
import { LiveKeySetup } from "./LiveKeySetup";
import { LiveProviderSettings } from "./LiveProviderSettings";
@@ -12,7 +12,8 @@ import { Select } from "./Select";
const IDLE_CHOICES = [1, 2, 3, 5, 10, 15, 30, 60];
-export function LiveCallSettings({ onClose }: { onClose: () => void }) {
+/** With `bot`, the bot on the call: it can have a voice of its own, and the other voice is the default for every other bot. */
+export function LiveCallSettings({ bot, onClose }: { bot?: Pick<Bot, "id" | "name" | "liveVoice">; onClose: () => void }) {
const { state, dispatch } = useStore();
const live: LiveSettings = state.config?.live ?? { configured: false, voice: "", readTypedReplies: true, idleMinutes: 5 };
const [saving, setSaving] = useState(false);
@@ -35,6 +36,8 @@ export function LiveCallSettings({ onClose }: { onClose: () => void }) {
const voiceOptions = gemini ? GEMINI_LIVE_VOICE_OPTIONS : LIVE_VOICE_OPTIONS;
const voice = gemini ? geminiLiveVoice(live.geminiVoice) : live.voice || "marin";
const known = voiceOptions.some((option) => option.id === voice);
+ // A bot's own voice of the other provider's kind stays saved and shows as the default here.
+ const botVoice = bot ? botCallVoice(bot.liveVoice, "", gemini) : "";
const save = async (patch: Partial<Pick<LiveSettings, "voice" | "geminiVoice" | "readTypedReplies" | "idleMinutes">>) => {
setSaving(true);
@@ -80,8 +83,21 @@ export function LiveCallSettings({ onClose }: { onClose: () => void }) {
<LiveProviderSettings locked={keySaving} onSaving={setProviderSaving} />
{/* Fish Audio and ElevenLabs calls speak in their agent's own voice. */}
{!fish && !elevenlabs && <>
+ {bot && (
+ <label className="flex items-center justify-between gap-2">
+ <span className="text-ink-secondary">{t("call.live.botVoice", { name: bot.name })}</span>
+ <Select
+ size="sm"
+ value={botVoice}
+ onChange={(event) => dispatch({ type: "updateBot", botId: bot.id, patch: { liveVoice: event.target.value } })}
+ >
+ <option value="">{t("call.live.botVoiceDefault")}</option>
+ {voiceOptions.map((option) => <option key={option.id} value={option.id}>{option.label}</option>)}
+ </Select>
+ </label>
+ )}
<label className="flex items-center justify-between gap-2">
- <span className="text-ink-secondary">{t("call.live.voice")}</span>
+ <span className="text-ink-secondary">{t(bot ? "call.live.defaultVoice" : "call.live.voice")}</span>
<Select
size="sm"
value={voice}
diff --git a/src/locales/en.json b/src/locales/en.json
index af765bf9e1..f325f0e5fa 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -6831,6 +6831,9 @@
"call.live.close": "Close",
"call.live.voice": "Voice",
"call.live.voiceNext": "A new voice starts with the next call.",
+ "call.live.botVoice": "Voice for {name}",
+ "call.live.botVoiceDefault": "Same as the default",
+ "call.live.defaultVoice": "Default voice",
"call.live.readTyped": "Read replies to typed messages",
"call.live.readTypedHint": "When this is off, messages you type during a call and the bot's answers to them are not sent to OpenAI.",
"call.live.idle": "Hang up after this many minutes of silence",
diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json
index da216e5d0f..1b9ee52637 100644
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@ -6509,6 +6509,9 @@
"call.live.close": "Fechar",
"call.live.voice": "Voz",
"call.live.voiceNext": "A nova voz será usada na próxima chamada.",
+ "call.live.botVoice": "Voz de {name}",
+ "call.live.botVoiceDefault": "Igual à padrão",
+ "call.live.defaultVoice": "Voz padrão",
"call.live.readTyped": "Ler em voz alta as respostas a mensagens digitadas",
"call.live.readTypedHint": "Com esta opção desligada, as mensagens que você digita durante uma chamada e as respostas do bot a elas não são enviadas à OpenAI.",
"call.live.idle": "Minutos de silêncio até desligar",
diff --git a/src/locales/source-hashes.json b/src/locales/source-hashes.json
index 3230206f5d..920dc0c061 100644
--- a/src/locales/source-hashes.json
+++ b/src/locales/source-hashes.json
@@ -32122,6 +32122,9 @@
"call.live.close": "7d9eb7acb13e24625c404401d8e88b2350e32162455885f18276cf802f7701ed",
"call.live.voice": "87bf2bc08589f0bd4a078db145c34ad5e14b8fda53c3ae65b78601294913df95",
"call.live.voiceNext": "f327ac67d0d177c2c69f6625a47e459b840128ec58bce385cd466113edec022b",
+ "call.live.botVoice": "c322987a70ef66a124a8870c34db8d5f62a1cafc07a1fcad3e0c05ea1ab513ab",
+ "call.live.botVoiceDefault": "dc762426a11c0644fd3e9a5cb8dafdeebcce95e4e5772a628deec94ed0ad36a5",
+ "call.live.defaultVoice": "47813ba0bdf5a3bf09d2b412144b8d02bbb66adc2defd595b0dcfe6a02f45c20",
"call.live.readTyped": "52015a9bd8f520777f2bf5651217a05dfee815dd9276ab7a3f7ce24799ea4df9",
"call.live.readTypedHint": "cd6bff848fea06d1564c43fab7df30cc29139944c90ce57da4fad165ae4b5d44",
"call.live.idle": "687e93bc7662cf98a5c15cbd355e6f8b1712898ee1afcf48fe8cd1e595a9b790",
diff --git a/src/state/bot-patch-queue.ts b/src/state/bot-patch-queue.ts
index f9aeb71d27..0185f138d2 100644
--- a/src/state/bot-patch-queue.ts
+++ b/src/state/bot-patch-queue.ts
@@ -26,6 +26,7 @@ export type BotUpdatePatch = Partial<
| "speakReplies"
| "replyStyle"
| "voice"
+ | "liveVoice"
| "voiceNotes"
| "voiceNoteEveryReply"
| "xResearch"
diff --git a/src/state/store.tsx b/src/state/store.tsx
index 45fcf0ba13..3a59e8e6c2 100644
--- a/src/state/store.tsx
+++ b/src/state/store.tsx
@@ -308,7 +308,7 @@ export interface Bot extends DefaultBotFields, Pick<WireBot, "mascotFaceColor" |
alwaysAllow?: string[];
speakReplies?: boolean;
replyStyle?: import("../../shared/wire").WireBot["replyStyle"];
- voice?: string;
+ voice?: string; liveVoice?: string; // liveVoice: the bot's own Live call voice; "" or absent: the app's
voiceNotes?: boolean; xResearch?: boolean; toolsOff?: import("../../shared/tool-groups").ToolGroup[]; voiceNoteEveryReply?: boolean | null; // null or absent: follows the Voice setting
memoryEnabled?: boolean;
pinned?: boolean;