Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Voice: let people hear through ElevenLabs Scribe and pick the language they speak
AdityaUmale64302dad1ef0
diff --git a/server/config.test.ts b/server/config.test.tsindex d152573ff9..d0aefdb700 100644--- a/server/config.test.ts+++ b/server/config.test.ts@@ -145,6 +145,14 @@ describe("configuration boundaries", () => {expect(() => parseConfigPatch({ tts: { fishModel: "s1" } })).toThrow("fishModel");});+ it("keeps how the person is heard and the language they speak, and refuses anything else", () => {+ expect(parseConfigPatch({ tts: { hearWith: "elevenlabs", hearLanguage: " ES " } }).tts).toEqual({ hearWith: "elevenlabs", hearLanguage: "es" });+ expect(parseConfigPatch({ tts: { hearWith: "device", hearLanguage: "" } }).tts).toEqual({ hearWith: "device", hearLanguage: "" });+ expect(parseStoredConfig({ tts: { key: "el-own" } }).tts).toEqual({ key: "el-own" });+ expect(() => parseConfigPatch({ tts: { hearWith: "fish" } })).toThrow("hearWith");+ expect(() => parseConfigPatch({ tts: { hearLanguage: "english" } })).toThrow("hearLanguage");+ });+it("defaults to what each host holds, and a saved number wins except over a plan's limit", () => {const GB = 1024 ** 3;const desktop = (gb: number) => ({ memoryGate: false, totalBytes: gb * GB, oneThreadPerBot: false });diff --git a/server/config.ts b/server/config.tsindex 3900b9dd79..357d749a67 100644--- a/server/config.ts+++ b/server/config.ts@@ -29,7 +29,7 @@ import { settledFileCache, settledFileStamp } from "./settled-file.ts";import { isRemoteMcpServer, mcpServerServes, parseStoredMcpServer } from "./mcp-registry.ts"; import { postizKeyHeaders } from "./postiz/connection.ts";import { parseJson, schemaIssue, type JsonObject, type JsonValue } from "./schema.ts";import { deciderConfigSchema, type DeciderConfig } from "./decider/config.ts";-import { fishKeyFromLiveKey, liveConfigSchema, liveConfigWithEnv, liveSettingEnv, type LiveConfig } from "./live-config.ts";+import { fishKeyFromLiveKey, liveConfigSchema, liveConfigWithEnv, liveSettingEnv, type LiveConfig } from "./live-config.ts"; import { hearingConfigShape } from "./tts/hearing-config.ts";import { browserEngineConfigSchema, isValidCdpTarget, type BrowserEngineConfig } from "./browser/config.ts";import { roomContextSettings } from "./room-context-settings.ts"; import { usageCapsSchema, type UsageCapsConfig } from "./usage-caps-config.ts";import { localVmConfigSchema } from "./local-vm-settings.ts";@@ -379,7 +379,7 @@ const appConfigSchema = z.object({.max(2048).refine((value) => !value || /^https?:\/\//i.test(value), "the Chatterbox server address must start with http:// or https://").optional(),- model: optionalText,+ model: optionalText, ...hearingConfigShape,fishModel: z.enum(FISH_TTS_MODELS).optional(), everyReply: z.boolean().optional(), // a voice note with every reply unless a bot's voiceNoteEveryReply says otherwise}).optional(),decider: deciderConfigSchema.optional(),@@ -473,7 +473,7 @@ export interface AppConfig extends HelperConfig {/** A named host from the user's SSH config. Authentication stays with SSH. */vps?: { sshAlias?: string };opencodeGo?: { apiKey?: string; providerKeys?: Record<string, string> };- tts?: { key?: string; fishKey?: string; geminiKey?: string; voice?: string; provider?: "elevenlabs" | "fish" | "system" | "chatterbox" | "xai" | "gemini" | "openai" | "deepseek"; baseUrl?: string; model?: string; fishModel?: FishTtsModel; everyReply?: boolean };+ tts?: { key?: string; fishKey?: string; geminiKey?: string; voice?: string; provider?: "elevenlabs" | "fish" | "system" | "chatterbox" | "xai" | "gemini" | "openai" | "deepseek"; baseUrl?: string; model?: string; fishModel?: FishTtsModel; everyReply?: boolean; hearWith?: "device" | "elevenlabs"; hearLanguage?: string };decider?: DeciderConfig;imageGen?: ImageGenerationConfig;live?: LiveConfig;diff --git a/server/routes/tts.test.ts b/server/routes/tts.test.tsindex 179feb316c..33edde377c 100644--- a/server/routes/tts.test.ts+++ b/server/routes/tts.test.ts@@ -112,6 +112,41 @@ describe("transcribe route", () => {expect(String((fetchMock.mock.calls[0] as unknown[])[0])).toContain("/v1/asr");});+ it("hears through Scribe in the chosen language when the person picked ElevenLabs, over Fish and DeepSeek", async () => {+ const seen: Array<{ url: string; language: unknown }> = [];+ vi.stubGlobal("fetch", vi.fn(async (url: string, init: RequestInit) => {+ seen.push({ url, language: (init.body as FormData).get("language_code") });+ return new Response(JSON.stringify({ text: "hola" }), { status: 200 });+ }));+ const cfg = {+ deepseek: { key: "ds-key" },+ tts: { provider: "deepseek", fishKey: "fish-key", key: "el-own", hearWith: "elevenlabs", hearLanguage: "es" },+ } as AppConfig;+ const { answers } = await call("POST", "/api/tts/transcribe", {}, cfg, upload(Buffer.from("RIFF")));+ expect(answers).toEqual([[200, { text: "hola" }]]);+ expect(seen).toEqual([{ url: expect.stringMatching(/\/v1\/speech-to-text$/), language: "es" }]);+ });++ it("lets Scribe detect the language when none is chosen, and sends no language when Scribe was not picked", async () => {+ const languages: unknown[] = [];+ vi.stubGlobal("fetch", vi.fn(async (_url: string, init: RequestInit) => {+ languages.push((init.body as FormData).get("language_code"));+ return new Response(JSON.stringify({ text: "hi" }), { status: 200 });+ }));+ await call("POST", "/api/tts/transcribe", {}, { tts: { key: "el-own", hearWith: "elevenlabs", hearLanguage: "" } } as AppConfig, upload(Buffer.from("RIFF")));+ await call("POST", "/api/tts/transcribe", {}, { tts: { key: "el-own", hearLanguage: "es" } } as AppConfig, upload(Buffer.from("RIFF")));+ expect(languages).toEqual([null, null]);+ });++ it("keeps Fish Audio when ElevenLabs was picked but no own ElevenLabs key is saved", async () => {+ const fetchMock = vi.fn(async () => new Response(JSON.stringify({ text: "from fish" }), { status: 200 }));+ vi.stubGlobal("fetch", fetchMock);+ const cfg = { tts: { fishKey: "fish-key", hearWith: "elevenlabs" } } as AppConfig;+ const { answers } = await call("POST", "/api/tts/transcribe", {}, cfg, upload(Buffer.from("RIFF")));+ expect(answers).toEqual([[200, { text: "from fish" }]]);+ expect(String((fetchMock.mock.calls[0] as unknown[])[0])).toContain("/v1/asr");+ });+it("names the Speech to Text permission when ElevenLabs refuses the key", async () => {vi.stubGlobal("fetch", vi.fn(async () => new Response(JSON.stringify({ detail: { message: "missing_permissions" } }), { status: 401 })));const { answers } = await call("POST", "/api/tts/transcribe", {}, { tts: { key: "el-own" } } as AppConfig, upload(Buffer.from("RIFF")));diff --git a/server/routes/tts.ts b/server/routes/tts.tsindex 6e2a5dfe80..5e5a7f3ded 100644--- a/server/routes/tts.ts+++ b/server/routes/tts.ts@@ -92,11 +92,13 @@ export function createTtsRoutes(deps: TtsRouteDeps): RouteHandler {req.resume();return json(res, 400, { error: "content-type must be audio/wav" });}- // DeepSeek voice hears with DeepSeek alone; otherwise Fish Audio first, then the person's own ElevenLabs key- // (never the plan's included voice).- const deepseekKey = tts.voiceProvider(cfg) === "deepseek" ? (cfg.deepseek?.key ?? "") : null;- const key = deepseekKey === null ? cfg.tts?.fishKey : undefined;- const own = key || deepseekKey !== null ? null : voiceCredential(cfg.tts?.key);+ // Scribe when the person chose it and their own ElevenLabs key is saved; else DeepSeek voice hears with DeepSeek+ // alone; otherwise Fish Audio first, then the person's own ElevenLabs key (never the plan's included voice).+ const ownEleven = voiceCredential(cfg.tts?.key);+ const scribeChosen = cfg.tts?.hearWith === "elevenlabs" && ownEleven !== null && !ownEleven.included;+ const deepseekKey = !scribeChosen && tts.voiceProvider(cfg) === "deepseek" ? (cfg.deepseek?.key ?? "") : null;+ const key = deepseekKey === null && !scribeChosen ? cfg.tts?.fishKey : undefined;+ const own = key || deepseekKey !== null ? null : ownEleven;const eleven = own?.included ? null : own;if (deepseekKey === "") {req.resume();@@ -130,7 +132,7 @@ export function createTtsRoutes(deps: TtsRouteDeps): RouteHandler {try {const text = deepseekKey? await deepseek.transcribe(audio, deepseekKey, controller.signal)- : key ? await fish.transcribe(audio, mime, key) : await elevenlabs.transcribe(audio, mime, eleven!.token, eleven!.api);+ : key ? await fish.transcribe(audio, mime, key) : await elevenlabs.transcribe(audio, mime, eleven!.token, eleven!.api, scribeChosen ? cfg.tts?.hearLanguage : undefined);if (controller.signal.aborted) return;return json(res, 200, { text });} catch (e) {diff --git a/server/tts/elevenlabs.ts b/server/tts/elevenlabs.tsindex a440c45793..cfe440fd58 100644--- a/server/tts/elevenlabs.ts+++ b/server/tts/elevenlabs.ts@@ -192,9 +192,10 @@ export function synthesize(text: string, voiceId: string, key: string, api: stri}/** Speech-to-text with Scribe, for listening where no Fish Audio key is saved. Only the person's own key comes here. */-export async function transcribe(audio: Uint8Array, mime: string, key: string, api: string): Promise<string> {+export async function transcribe(audio: Uint8Array, mime: string, key: string, api: string, language?: string): Promise<string> {const form = new FormData();form.append("model_id", HEARING_MODEL);+ if (language) form.append("language_code", language);form.append("tag_audio_events", "false");form.append("file", new Blob([audio as Uint8Array<ArrayBuffer>], { type: mime }), "speech.wav");let res: Response;diff --git a/server/tts/hearing-config.ts b/server/tts/hearing-config.tsnew file mode 100644index 0000000000..c22b285619--- /dev/null+++ b/server/tts/hearing-config.ts@@ -0,0 +1,8 @@+import { z } from "zod";++/** How the person is heard. hearWith "elevenlabs": dictation and Take turns go to Scribe with their own ElevenLabs+ * key on every computer. hearLanguage: the ISO 639 code they speak to Scribe; "" or absent lets Scribe detect it. */+export const hearingConfigShape = {+ hearWith: z.enum(["device", "elevenlabs"]).optional(),+ hearLanguage: z.union([z.literal(""), z.string().trim().toLowerCase().regex(/^[a-z]{2,3}$/)]).optional(),+};diff --git a/server/tts/index.ts b/server/tts/index.tsindex ee0c4dd357..dfc39b01fd 100644--- a/server/tts/index.ts+++ b/server/tts/index.ts@@ -114,6 +114,8 @@ export function describeVoice(cfg: AppConfig) {...(provider === "fish" ? { fishModel: cfg.tts?.fishModel ?? fish.DEFAULT_FISH_MODEL } : {}),...(included ? { included: true as const } : {}),...(cfg.tts?.everyReply ? { everyReply: true as const } : {}),+ ...(cfg.tts?.hearWith === "elevenlabs" ? { hearWith: "elevenlabs" as const } : {}),+ ...(cfg.tts?.hearLanguage ? { hearLanguage: cfg.tts.hearLanguage } : {}),};}diff --git a/src/components/CallView.tsx b/src/components/CallView.tsxindex 6c8825aba4..d7d8141f2b 100644--- a/src/components/CallView.tsx+++ b/src/components/CallView.tsx@@ -406,6 +406,7 @@ export function CallModeMenu({ id, mode, onChoose, onClose, placement = "header"onChoose: (mode: CallMode) => void;onClose: () => void;}) {+ const { state } = useStore();const ref = useRef<HTMLDivElement>(null);useEffect(() => {ref.current?.querySelector<HTMLButtonElement>('[aria-checked="true"]')?.focus();@@ -443,7 +444,7 @@ export function CallModeMenu({ id, mode, onChoose, onClose, placement = "header"<span className="min-w-0 flex-1"><span className={cn("block text-[14px] leading-[18px]", unavailable ? "text-ink-tertiary" : "text-ink")}>{t(entry.label)}</span><span className="mt-0.5 block text-[12px] leading-[1.4] text-ink-secondary">- {unavailable ? `${unavailable.label}. ${unavailable.reason}` : callModeHint(entry.id, { cloudHome })}+ {unavailable ? `${unavailable.label}. ${unavailable.reason}` : callModeHint(entry.id, { cloudHome, config: state.config })}</span></span>{mode === entry.id && <Check size={14} className="mt-0.5 shrink-0 text-accent" aria-hidden="true" />}diff --git a/src/components/VoiceHearingSetting.tsx b/src/components/VoiceHearingSetting.tsxnew file mode 100644index 0000000000..c2e6855e7f--- /dev/null+++ b/src/components/VoiceHearingSetting.tsx@@ -0,0 +1,81 @@+import { useContext, useState } from "react";+import { api, useStore, type ConfigStatus } from "@/state/store";+import { intlLocale, t } from "@/lib/i18n";+import { ownElevenLabsKey, scribeChosen } from "@/lib/speech";+import { Select } from "./Select";+import { SettingRow, SettingsLook, Switch } from "./SettingsPrimitives";++/** Languages offered for Scribe (ISO 639-1); Scribe hears more, and "" lets it detect the language itself. */+export const HEAR_LANGUAGES = [+ "ar", "bn", "zh", "cs", "da", "nl", "en", "fi", "fr", "de", "el", "he", "hi", "hu", "id", "it", "ja", "ko", "ms",+ "no", "fa", "pl", "pt", "ro", "ru", "es", "sv", "th", "tr", "uk", "ur", "vi",+] as const;++function languageOptions(): Array<{ code: string; name: string }> {+ let names: Intl.DisplayNames | null = null;+ try {+ names = new Intl.DisplayNames([intlLocale()], { type: "language" });+ } catch {+ // Without display names the codes themselves are shown.+ }+ return HEAR_LANGUAGES.map((code) => ({ code, name: names?.of(code) ?? code })).sort((a, b) => a.name.localeCompare(b.name, intlLocale()));+}++/** "Hear me with ElevenLabs": dictation and Take turns go to Scribe with the person's own key, in the language they pick.+ * Shown only while their own ElevenLabs key is saved; off, every computer keeps its usual way of listening. */+export function VoiceHearingSetting() {+ const { state, dispatch } = useStore();+ const [saving, setSaving] = useState(false);+ const [error, setError] = useState<string | null>(null);+ const settings = useContext(SettingsLook);+ if (!ownElevenLabsKey(state.config)) return null;+ const on = scribeChosen(state.config);+ const language = state.config?.tts?.hearLanguage ?? "";+ const save = (tts: { hearWith?: "device" | "elevenlabs"; hearLanguage?: string }) => {+ setSaving(true);+ setError(null);+ api("/api/config", { method: "PUT", body: JSON.stringify({ tts }) })+ .then((status: ConfigStatus) => dispatch({ type: "configStatus", config: status }))+ .catch((failure: Error) => setError(failure.message))+ .finally(() => setSaving(false));+ };+ const toggle = <Switch checked={on} disabled={saving} aria-label={t("voice.hearWithEleven")} onClick={() => save({ hearWith: on ? "device" : "elevenlabs" })} />;+ const picker = (+ <Select size="sm" aria-label={t("voice.hearLanguage")} value={language} disabled={saving} onChange={(event) => save({ hearLanguage: event.target.value })}>+ <option value="">{t("voice.hearLanguage.auto")}</option>+ {languageOptions().map(({ code, name }) => <option key={code} value={code}>{name}</option>)}+ </Select>+ );+ const alert = error ? <span role="alert" className="text-danger">{error}</span> : undefined;+ if (settings) {+ return (+ <div data-voice-hearing className="contents">+ <SettingRow title={t("voice.hearWithEleven")} subtitle={t("voice.hearWithEleven.help")} leading={<span aria-hidden="true" />} message={alert}>+ {toggle}+ </SettingRow>+ {on && <SettingRow title={t("voice.hearLanguage")} subtitle={t("voice.hearLanguage.help")} leading={<span aria-hidden="true" />}>{picker}</SettingRow>}+ </div>+ );+ }+ return (+ <div data-voice-hearing className="flex flex-col">+ <div className="flex items-center justify-between gap-4 px-3 py-2.5">+ <div className="min-w-0">+ <div className="text-[14px] font-medium leading-5 text-ink">{t("voice.hearWithEleven")}</div>+ <div className="mt-0.5 text-[12px] leading-4 text-ink-secondary">{t("voice.hearWithEleven.help")}</div>+ {error && <div role="alert" className="mt-1 text-[12px] text-danger">{error}</div>}+ </div>+ {toggle}+ </div>+ {on && (+ <div className="flex items-center justify-between gap-4 px-3 py-2.5">+ <div className="min-w-0">+ <div className="text-[14px] font-medium leading-5 text-ink">{t("voice.hearLanguage")}</div>+ <div className="mt-0.5 text-[12px] leading-4 text-ink-secondary">{t("voice.hearLanguage.help")}</div>+ </div>+ {picker}+ </div>+ )}+ </div>+ );+}diff --git a/src/components/bot-panel/SettingsPage.tsx b/src/components/bot-panel/SettingsPage.tsxindex db3582e983..4d45dd6819 100644--- a/src/components/bot-panel/SettingsPage.tsx+++ b/src/components/bot-panel/SettingsPage.tsx@@ -81,7 +81,7 @@ export function SettingsPage({ bot, derived, onOpen, editingInstructions = falsevalue: entry.id,label: t(entry.label),disabled: entry.id === "turns" && turnsHelp !== null,- tooltip: entry.id === "turns" && turnsHelp ? `${turnsHelp.label}. ${turnsHelp.reason}` : entry.id === "live" ? t("call.mode.liveHint") : callModeHint("turns"),+ tooltip: entry.id === "turns" && turnsHelp ? `${turnsHelp.label}. ${turnsHelp.reason}` : entry.id === "live" ? t("call.mode.liveHint") : callModeHint("turns", { config: state.config }),}));const replyOptions: SegmentOption<ReplyStyle>[] = REPLY_STYLES.map((style) => ({diff --git a/src/components/keys/KeysPage.tsx b/src/components/keys/KeysPage.tsxindex eed5f5a8fc..9f942d86b4 100644--- a/src/components/keys/KeysPage.tsx+++ b/src/components/keys/KeysPage.tsx@@ -8,6 +8,7 @@ import { t } from "@/lib/i18n";import { BoatOfferPanel } from "../BoatOffer";import { LiveProviderSettings } from "../LiveProviderSettings";import { VoiceEveryReplySetting } from "../VoiceEveryReplySetting";+import { VoiceHearingSetting } from "../VoiceHearingSetting";import { BuiltInReplyWait, LmStudioServer, OtherOpenAiCompatServers } from "../OpenAiCompatServers";import { OllamaServer } from "../OllamaServer";import { KEY_CATALOG, KEY_SECTIONS, keyHidden, keyMatches, savedState, type KeyEntry, type KeyId, type KeySectionId } from "./key-catalog";@@ -107,6 +108,7 @@ function KeySection({ id, rows, open, onToggle }: { id: KeySectionId; rows: KeyE<div id={bodyId} hidden={!open} className="flex flex-col gap-0.5 border-t border-hairline/40 px-1 py-1.5 in-data-[settings-look=simple]:border-t-[0.5px] in-data-[settings-look=simple]:border-(--settings-edge)">{rows.map((entry) => <KeyCatalogRow key={entry.id} entry={entry} visible={open} />)}{id === "voice" && <VoiceEveryReplySetting />}+ {id === "voice" && <VoiceHearingSetting />}</div></section>);@@ -180,6 +182,7 @@ export function KeysPage({ bare = false, exclude = [] }: { bare?: boolean; exclu<div data-keys-section={id} className="flex flex-col gap-0.5 py-1.5">{sectionRows.map((entry) => <KeyCatalogRow key={entry.id} entry={entry} visible={open.has(id)} />)}{id === "voice" && <VoiceEveryReplySetting />}+ {id === "voice" && <VoiceHearingSetting />}</div></SettingsFoldRow>);diff --git a/src/lib/call-mode.test.ts b/src/lib/call-mode.test.tsindex 5f275f4393..f898997241 100644--- a/src/lib/call-mode.test.ts+++ b/src/lib/call-mode.test.ts@@ -1,11 +1,14 @@import { afterEach, describe, expect, it, vi } from "vitest";import { CALL_MODE_KEY, CALL_MODES, callModeHint, effectiveCallMode, liveDisclosure, liveKeyFormKey, parseCallMode } from "./call-mode";+import { cacheDesktopCapabilities, initialDesktopCapabilities } from "./desktop";import { t } from "./i18n";import { localeChoices, locales } from "@/locales";+import type { ConfigStatus } from "@/state/store";describe("call mode", () => {afterEach(() => {+ cacheDesktopCapabilities(initialDesktopCapabilities());vi.unstubAllGlobals();vi.resetModules();});@@ -23,6 +26,16 @@ describe("call mode", () => {expect(callModeHint("turns")).toBe("You talk, then the bot answers in its own voice. Listening stays on this computer.");});+ it("says the voice leaves this computer in Take turns once the person picked ElevenLabs to hear them", () => {+ const chosen = { tts: { hearWith: "elevenlabs" }, savedKeys: { ttsKey: { configured: true } } } as unknown as ConfigStatus;+ const dictation = { available: true, engine: "apple-speech", onDevice: true } as const;+ cacheDesktopCapabilities({ ...initialDesktopCapabilities(), dictation });+ expect(callModeHint("turns", { config: chosen })).toBe("You talk, then the bot answers in its own voice. ElevenLabs turns what you say into text, so your voice goes there.");+ expect(callModeHint("turns", { config: { tts: {} } as unknown as ConfigStatus })).toBe(t("call.mode.turnsHint"));+ cacheDesktopCapabilities({ ...initialDesktopCapabilities(), dictation: { ...dictation, available: false } });+ expect(callModeHint("turns", { config: chosen })).toBe(t("call.mode.turnsHint"));+ });+it("says the OpenAI key stays on the Cloud when the chat is on the person's Cloud", () => {const live = callModeHint("live", { cloudHome: true });expect(live).toContain("A Live call sends your voice to OpenAI, along with the chat's recent messages, the bot's answers and the details of any approval it asks for. The OpenAI key stays in the Cloud.");diff --git a/src/lib/call-mode.ts b/src/lib/call-mode.tsindex b03edbcc6a..522f024136 100644--- a/src/lib/call-mode.ts+++ b/src/lib/call-mode.ts@@ -1,8 +1,10 @@import { useSyncExternalStore } from "react";import type { LocaleKey } from "@/locales";import type { LiveProvider, LiveSettings } from "../../shared/wire";+import type { ConfigStatus } from "@/state/store";import { desktopCapabilitiesNow } from "./desktop";import { t } from "./i18n";+import { scribeChosen } from "./speech";export type CallMode = "turns" | "live";export const CALL_MODE_KEY = "openmausbot.callMode.v1";@@ -48,9 +50,11 @@ export function liveKeyFormKey(live: Partial<Pick<LiveSettings, "provider" | "azreturn endpoint ? `${provider}|${endpoint}` : provider;}-export function callModeHint(mode: CallMode, where: { cloudHome?: boolean } = {}): string {+export function callModeHint(mode: CallMode, where: { cloudHome?: boolean; config?: ConfigStatus | null } = {}): string {if (mode === "live") return `${t("call.mode.liveHint")} ${liveDisclosure(where)}`;- return t(desktopCapabilitiesNow().dictation.engine === "fish-audio" ? "call.mode.turnsHintFish" : "call.mode.turnsHint");+ const { dictation } = desktopCapabilitiesNow();+ if (dictation.available && scribeChosen(where.config)) return t("call.mode.turnsHintEleven");+ return t(dictation.engine === "fish-audio" ? "call.mode.turnsHintFish" : "call.mode.turnsHint");}export function effectiveCallMode(stored: CallMode, { turnsHere, canLive }: { turnsHere: boolean; canLive: boolean }): CallMode {diff --git a/src/lib/speech.test.ts b/src/lib/speech.test.tsindex 69d3c40a62..88441ca5b7 100644--- a/src/lib/speech.test.ts+++ b/src/lib/speech.test.ts@@ -3,7 +3,7 @@ import { DEEPSEEK_RECORDING_MAX_MS } from "../../shared/deepseek-voice";import type { ConfigStatus } from "@/state/store";import { cacheDesktopCapabilities, initialDesktopCapabilities } from "./desktop";import { createEndpointer, fishSpeech } from "./fish-speech";-import { CALL_ENDPOINT_MS, fishListeningReady, listensHere, missingListenKey, recordsClips, speechBridge } from "./speech";+import { CALL_ENDPOINT_MS, fishListeningReady, listensHere, missingListenKey, recordsClips, scribeChosen, speechBridge } from "./speech";const withDictation = (dictation: DesktopCapabilities["dictation"]): DesktopCapabilities =>({ ...initialDesktopCapabilities(), dictation });@@ -100,6 +100,33 @@ describe("listening readiness", () => {});});+describe("hearing through ElevenLabs Scribe by choice", () => {+ const chosen = { tts: { hearWith: "elevenlabs" }, savedKeys: { ttsKey: { configured: true } } } as unknown as ConfigStatus;++ it("records in the page on the Mac too, over DeepSeek, once the person picks ElevenLabs with their own key", () => {+ const ogb = { speechStart: vi.fn() };+ vi.stubGlobal("window", { ogb });+ cacheDesktopCapabilities(withDictation(APPLE));+ const deepseekToo = { ...chosen, tts: { provider: "deepseek", hearWith: "elevenlabs" } } as unknown as ConfigStatus;+ expect(speechBridge(chosen)).toBe(fishSpeech);+ expect(speechBridge(deepseekToo)).toBe(fishSpeech);+ expect(scribeChosen(deepseekToo)).toBe(true);+ expect(listensHere(withDictation(APPLE), deepseekToo)).toBe(true);+ expect(missingListenKey(withDictation(APPLE), deepseekToo)).toBeNull();+ });++ it("changes nothing without the choice, or with only the plan's included voice", () => {+ const ogb = { speechStart: vi.fn() };+ vi.stubGlobal("window", { ogb });+ cacheDesktopCapabilities(withDictation(APPLE));+ const notChosen = { savedKeys: { ttsKey: { configured: true } } } as unknown as ConfigStatus;+ const included = { ...chosen, tts: { hearWith: "elevenlabs", included: true } } as unknown as ConfigStatus;+ expect(speechBridge(notChosen)).toBe(ogb);+ expect(speechBridge(included)).toBe(ogb);+ expect(scribeChosen(included)).toBe(false);+ });+});+describe("CALL_ENDPOINT_MS", () => {const FRAME = 64;const run = (endpoint: number, quietMs: number) => {diff --git a/src/lib/speech.ts b/src/lib/speech.tsindex 5cc878f292..042bbf0ddd 100644--- a/src/lib/speech.ts+++ b/src/lib/speech.ts@@ -16,14 +16,26 @@ const deepseekSpeech: SpeechBridge = {/** DeepSeek voice also hears through DeepSeek, on every computer that can listen at all. */const deepseekHears = (config: ConfigStatus | null | undefined) => config?.tts?.provider === "deepseek";+/** The person's own ElevenLabs key is saved (not the plan's included voice). */+export function ownElevenLabsKey(config: ConfigStatus | null | undefined): boolean {+ const eleven = savedState(keyEntry("elevenlabs"), config);+ return eleven.configured && !eleven.included;+}++/** The person chose to be heard through their own ElevenLabs key (Scribe), on every computer, the Mac included. */+export const scribeChosen = (config: ConfigStatus | null | undefined) =>+ config?.tts?.hearWith === "elevenlabs" && ownElevenLabsKey(config);+function serverHears(capabilities: DesktopCapabilities, config: ConfigStatus | null | undefined): boolean {- return capabilities.dictation.engine === "fish-audio" || (capabilities.dictation.available && deepseekHears(config));+ return capabilities.dictation.engine === "fish-audio"+ || (capabilities.dictation.available && (deepseekHears(config) || scribeChosen(config)));}/** The speech bridge this computer listens through: the page's own recorder (heard by the harness through DeepSeek,* Fish Audio or ElevenLabs), or the desktop app's helper. */export function speechBridge(config: ConfigStatus | null | undefined): SpeechBridge | Window["ogb"] {const capabilities = desktopCapabilitiesNow();+ if (capabilities.dictation.available && scribeChosen(config)) return fishSpeech;if (capabilities.dictation.available && deepseekHears(config)) return deepseekSpeech;return capabilities.dictation.engine === "fish-audio" ? fishSpeech : globalThis.window?.ogb;}@@ -40,10 +52,10 @@ export function stopListening(): void {/** A key the server listens with: DeepSeek while it is the voice; otherwise Fish Audio, or the person's own* ElevenLabs key (not the plan's included voice). */export function fishListeningReady(config: ConfigStatus | null | undefined): boolean {+ if (scribeChosen(config)) return true;if (deepseekHears(config)) return savedState(keyEntry("deepseek"), config).configured;if (savedState(keyEntry("fishAudio"), config).configured) return true;- const eleven = savedState(keyEntry("elevenlabs"), config);- return eleven.configured && !eleven.included;+ return ownElevenLabsKey(config);}/** The key this computer still needs before the server can hear it, if any. */diff --git a/src/locales/de.json b/src/locales/de.jsonindex f906a798c5..689408bbe4 100644--- a/src/locales/de.json+++ b/src/locales/de.json@@ -3049,6 +3049,11 @@"server.routines.card.onceContinues": "Wird einmal ausgeführt; jede Ausführung setzt die Unterhaltung der vorherigen fort.","voice.everyReply": "Sprachnachricht zu jeder Antwort","voice.everyReply.allHelp": "Jeder Bot schickt jede Antwort auch als Sprachnachricht. In den Einstellungen eines Bots kannst du das nur für ihn ein- oder ausschalten.",+ "voice.hearWithEleven": "Mit ElevenLabs zuhören",+ "voice.hearWithEleven.help": "Diktat und Anrufe im Wechsel wandeln deine Sprache mit deinem ElevenLabs-Schlüssel (Scribe) in Text um statt mit der Spracherkennung dieses Computers, deine Stimme geht also an ElevenLabs.",+ "voice.hearLanguage": "Deine Sprache",+ "voice.hearLanguage.help": "Sagt ElevenLabs, welche Sprache es erwarten soll, statt sie zu raten.",+ "voice.hearLanguage.auto": "Automatisch erkennen","voice.everyReply.followsOn": "Folgt deiner Spracheinstellung (an)","voice.everyReply.followsOff": "Folgt deiner Spracheinstellung (aus)","voice.everyReply.own": "Für diesen Bot festgelegt.",diff --git a/src/locales/en.json b/src/locales/en.jsonindex f60f33e1f9..85705f64e7 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -948,6 +948,11 @@"voice.notesHelp": "Let this agent send spoken notes; on unless switched off here.","voice.everyReply": "Voice note with every reply","voice.everyReply.allHelp": "Every bot also sends each reply as a voice note. You can turn it on or off for one bot in that bot's settings.",+ "voice.hearWithEleven": "Hear me with ElevenLabs",+ "voice.hearWithEleven.help": "Dictation and Take turns calls turn your speech into text with your ElevenLabs key (Scribe) instead of this computer's own speech recognition, so your voice goes to ElevenLabs.",+ "voice.hearLanguage": "Language you speak",+ "voice.hearLanguage.help": "Tells ElevenLabs which language to expect instead of guessing it.",+ "voice.hearLanguage.auto": "Detect automatically","voice.everyReply.followsOn": "Uses your Voice setting (on)","voice.everyReply.followsOff": "Uses your Voice setting (off)","voice.everyReply.own": "Set for this bot.",@@ -6891,6 +6896,7 @@"call.mode.turns": "Take turns","call.mode.turnsHint": "You talk, then the bot answers in its own voice. Listening stays on this computer.","call.mode.turnsHintFish": "You talk, then the bot answers in its own voice. Fish Audio (or ElevenLabs, if that's the key you saved) turns what you say into text, so your voice goes there.",+ "call.mode.turnsHintEleven": "You talk, then the bot answers in its own voice. ElevenLabs turns what you say into text, so your voice goes there.","call.mode.live": "Live","call.mode.liveHint": "Talk naturally and interrupt any time; the bot still does the work.","call.capability.turnsNeedFishKey": "Add a Fish Audio or ElevenLabs key to take turns on calls",diff --git a/src/locales/pt-br.json b/src/locales/pt-br.jsonindex 3d762b4740..b2965a3a75 100644--- a/src/locales/pt-br.json+++ b/src/locales/pt-br.json@@ -913,6 +913,11 @@"voice.notesHelp": "Permite que este agente envie mensagens de voz. Fica ligado, a menos que você desligue aqui.","voice.everyReply": "Nota de voz em toda resposta","voice.everyReply.allHelp": "Cada bot também envia cada resposta como nota de voz. Você pode ligar ou desligar isso para um bot só, nas configurações dele.",+ "voice.hearWithEleven": "Me ouvir com ElevenLabs",+ "voice.hearWithEleven.help": "O ditado e as chamadas em turnos transformam sua fala em texto com sua chave ElevenLabs (Scribe) em vez do reconhecimento de fala deste computador, então sua voz vai para a ElevenLabs.",+ "voice.hearLanguage": "Idioma que você fala",+ "voice.hearLanguage.help": "Diz à ElevenLabs qual idioma esperar em vez de adivinhar.",+ "voice.hearLanguage.auto": "Detectar automaticamente","voice.everyReply.followsOn": "Segue sua configuração de voz (ligada)","voice.everyReply.followsOff": "Segue sua configuração de voz (desligada)","voice.everyReply.own": "Definido para este bot.",@@ -6558,6 +6563,7 @@"call.mode.turns": "Um de cada vez","call.mode.turnsHint": "Você fala e depois o bot responde com a própria voz. A escuta é feita neste computador.","call.mode.turnsHintFish": "Você fala e depois o bot responde com a própria voz. O Fish Audio (ou o ElevenLabs, se essa for a chave que você salvou) transforma sua fala em texto, então sua voz é enviada para lá.",+ "call.mode.turnsHintEleven": "Você fala e depois o bot responde com a própria voz. O ElevenLabs transforma sua fala em texto, então sua voz é enviada para lá.","call.mode.live": "Ao vivo","call.mode.liveHint": "Fale naturalmente e interrompa quando quiser; o bot continua fazendo o trabalho.","call.capability.turnsNeedFishKey": "Adicionar uma chave do Fish Audio ou do ElevenLabs para chamadas com falas alternadas",diff --git a/src/locales/source-hashes.json b/src/locales/source-hashes.jsonindex f536fb9450..4a9d35c6a4 100644--- a/src/locales/source-hashes.json+++ b/src/locales/source-hashes.json@@ -4051,7 +4051,12 @@"alwaysOn.title": "2006f993f0189bf13dac31689d811ebd7581f8889987927aa6f0f11bf6b4679d","alwaysOn.add.title": "007f4d7546061eba19c8b6edd78fc70404d2f745fb1f7f3aac83a22d216a9ccc","inbox.settled.title": "7804f7a79a9eee323b6e89d3f8287c7d36076f4d76291646295f435b0dec736e",- "inbox.settled.read": "9b9a8d05a7ec353bda84f9c1bb3178c299de3001b5e970508ddc889c487f92ca"+ "inbox.settled.read": "9b9a8d05a7ec353bda84f9c1bb3178c299de3001b5e970508ddc889c487f92ca",+ "voice.hearWithEleven": "0e179499c302bb4e934abef524b14055911d4944188e205d34e7afadad716484",+ "voice.hearWithEleven.help": "fb2aab6844f1ecd9bbbb92b589062d6317fbfa2c1384b4c3ceb4e9f88f49c53a",+ "voice.hearLanguage": "e0e77e5c6f38efbd4bbb93e7b7641c5de9f88214c48133d6582fd0149cf8cbef",+ "voice.hearLanguage.help": "4047e2f61649a10025e8c030a9d3c0ba5a7f8af7704cf8ecad42ab589549c39e",+ "voice.hearLanguage.auto": "836e5a7f8e818a97ddea1777b429755700ce1fc997f931e980501fa271b17d8f"},"es": {"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",@@ -37144,7 +37149,13 @@"cliLogin.scopeAll": "ba819ccda692c3b69f5bf21fa389765482ad998a1b26e2f70bd968b0fbd6f3ad","cliLogin.scopeChat": "418ee6d363775013ad7a49e395691d26ec0134465eff893c2c8522f9970caf6f","cliLogin.allow": "e213c161d5cefa520c8dd4155c9569076d9a40406111465136a6f1b207045761",- "cliLogin.deny": "05a2d7332eb9d8bf164487c743a2e93c21b16bb2061a93e3ee2ceb508eadb753"+ "cliLogin.deny": "05a2d7332eb9d8bf164487c743a2e93c21b16bb2061a93e3ee2ceb508eadb753",+ "voice.hearWithEleven": "0e179499c302bb4e934abef524b14055911d4944188e205d34e7afadad716484",+ "voice.hearWithEleven.help": "fb2aab6844f1ecd9bbbb92b589062d6317fbfa2c1384b4c3ceb4e9f88f49c53a",+ "voice.hearLanguage": "e0e77e5c6f38efbd4bbb93e7b7641c5de9f88214c48133d6582fd0149cf8cbef",+ "voice.hearLanguage.help": "4047e2f61649a10025e8c030a9d3c0ba5a7f8af7704cf8ecad42ab589549c39e",+ "voice.hearLanguage.auto": "836e5a7f8e818a97ddea1777b429755700ce1fc997f931e980501fa271b17d8f",+ "call.mode.turnsHintEleven": "7e6acaf1930622f9d5cfe37b70dcd2c22ca99c5aacb16f624af9d71fa79bf2eb"},"zh": {"pro.fromPrice": "a48a04a457d60b08b54fc83e7a6c4584ffedb1e23621859084900c8521a3af7b",diff --git a/src/state/config-status.ts b/src/state/config-status.tsindex 745e130157..fbc2c140ef 100644--- a/src/state/config-status.ts+++ b/src/state/config-status.ts@@ -99,6 +99,10 @@ export interface ConfigStatus {model?: string;/** Voice note with every reply, for every bot without its own choice. Absent from older servers. */everyReply?: boolean;+ /** "elevenlabs": the person chose to be heard through their own ElevenLabs key (Scribe). Absent: the default. */+ hearWith?: "elevenlabs";+ /** The language the person speaks to Scribe (ISO 639 code); absent lets Scribe detect it. */+ hearLanguage?: string;/** Fish Audio speech model; present only while Fish is the provider. */fishModel?: "s2.1-pro" | "s2.1-pro-free";/** ElevenLabs voice comes with Cloud Pro; no key is saved. */