Skip to content

๐Ÿคฏ LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

[codex] Remove legacy TTS providers and add prototype skill (#16656)

Arvin Xue0e3024cb748
diff --git a/.agents/skills/design-prototype/SKILL.md b/.agents/skills/design-prototype/SKILL.md
new file mode 100644
index 00000000000..6b12a272588
--- /dev/null
+++ b/.agents/skills/design-prototype/SKILL.md
@@ -0,0 +1,127 @@
+---
+name: design-prototype
+description: Produce an interactive single-file HTML design prototype using the REAL LobeHub design system (@lobehub/ui + antd + antd-style tokens) with production-style React โ€” no build step, opens directly in a browser. Use when asked for a design prototype / interactive mockup / ไบคไบ’ๅŽŸๅž‹ / ๅ‡บไธชๅŽŸๅž‹ / ่ฎพ่ฎก็จฟ HTML for a page or flow, or to explore a redesign before committing to implementation.
+---
+
+# Design Prototype
+
+One HTML file, double-click to open, fully interactive, rendered by the **actual
+design system** (`@lobehub/ui` 5.x + antd 6 + antd-style tokens, exact versions from
+this repo's `node_modules`) โ€” while the source stays **production-style React**
+(`import { Block } from '@lobehub/ui'`, `createStyles(({ css, token }) => โ€ฆ)`, hooks,
+`memo`). Promotion to production is mostly "split into files", not "rewrite".
+
+Prototype code may be quick-and-dirty (one file, no i18n, inline data) โ€” but the
+**interaction must be complete**: states, transitions, and affordances are the point
+of a prototype, not its code style.
+
+## How it works
+
+```
+one-time (~2s, cached): scripts/build-runtime.sh โ†’ lobe-prototype-runtime.js (IIFE global)
+ + vendored babel.min.js
+per prototype (no build): single HTML = <script runtime> + babel-standalone
+ + <script type="text/babel"> with production-style React
+```
+
+- The runtime bundles `react`, `react-dom/client`, `@lobehub/ui`, `@lobehub/ui/base-ui`,
+ `antd` (curated subset), `antd-style`, `lucide-react` from the repo's own
+ `node_modules` โ€” so tokens/components/versions match production, and react/emotion/
+ theme-context are singletons by construction.
+- A 3-line `window.require` shim + babel's `transform-modules-commonjs` lets the
+ prototype keep real `import` statements.
+- `ThemeProvider themeMode="auto"` โ†’ light/dark follow the OS.
+
+> โš ๏ธ Don't re-attempt the pure-CDN route (esm.sh import maps). It was tried and
+> rejected: esm.sh's CJS named-export analysis fails serially across antd's dep chain
+> (`@ant-design/fast-color` โ†’ `@ant-design/colors` โ†’ `@rc-component/qrcode` โ†’ โ€ฆ), and
+> `?bundle` leaks an unversioned `react-is` 404. Whack-a-mole, not a foundation.
+
+## Quickstart
+
+1. **Build the runtime into the prototype's directory** (any dir works; `/tmp` is fine):
+
+ ```bash
+ bash .agents/skills/design-prototype/scripts/build-runtime.sh /tmp/my-proto
+ ```
+
+ Skip if `lobe-prototype-runtime.js` + `babel.min.js` are already there and the
+ design-system versions haven't bumped.
+
+2. **Copy [`references/template.html`](references/template.html)** into the same dir,
+ rename, and replace the sample `App` with the real surface. Keep the runtime shim
+ block untouched.
+
+3. **Open it** (`open /tmp/my-proto/xxx.html`) โ€” no server, no build.
+
+## Verify before delivering
+
+Headless-check it renders with zero console errors (the repo's e2e Playwright works):
+
+```js
+// node /tmp/check.mjs โ€” adjust paths
+import { chromium } from '<repo>/e2e/node_modules/playwright/index.mjs';
+const b = await chromium.launch();
+const p = await b.newPage();
+const errs = [];
+p.on('pageerror', (e) => errs.push(String(e)));
+await p.goto('file:///tmp/my-proto/xxx.html');
+await p.waitForSelector('#root *', { timeout: 30000 });
+await p.screenshot({ path: '/tmp/proto.png' }); // Read the screenshot yourself
+console.log('errors:', errs);
+await b.close();
+```
+
+Then **Read the screenshot** โ€” a prototype is a visual deliverable; don't ship it
+sight-unseen. Check light + dark (emulate `prefers-color-scheme`) and a narrow
+viewport if the surface has a mobile story.
+
+## What's in the runtime (extend freely)
+
+See [`assets/entry.mjs`](assets/entry.mjs) โ€” the single source of truth. Currently:
+
+- `@lobehub/ui`: ActionIcon, Alert, Avatar, Block, Button, Center, Collapse,
+ DraggablePanel, Drawer, DropdownMenu, Empty, Flexbox, Highlighter, Hotkey, Icon,
+ Image, Input, InputNumber, Markdown, Modal, NeuralNetworkLoading, Popover,
+ ScrollShadow, SearchBar, Segmented, Select, Skeleton, SortableList, Tabs, Tag,
+ Text, TextArea, ThemeProvider, Tooltip
+- `@lobehub/ui/base-ui`: full namespace (Select, Modal, DropdownMenu, Switch, Toast,
+ FloatingSheet, โ€ฆ)
+- `antd`: App, Badge, Checkbox, Divider, Dropdown, Progress, Radio, Slider, Space,
+ Steps, Table
+- `antd-style`, `lucide-react`, `react`, `react-dom/client`: full namespaces
+
+Missing a component โ†’ add to `entry.mjs`, rerun the build script (\~2s). Sizes:
+curated โ‰ˆ 16MB (fine from disk); a full `export * from '@lobehub/ui'` works too
+(โ‰ˆ 27MB) if you'd rather never curate.
+
+## Pitfalls
+
+- **`Switch` lives in `@lobehub/ui/base-ui`**, not the root package (as do the other
+ base-ui primitives). Importing it from the root fails the runtime build.
+- **Use `createStyles` (runtime), not `createStaticStyles`** โ€” static extraction
+ needs a build step. This is the one sanctioned deviation from production style;
+ note it when handing the prototype to an implementer.
+- **babel must stay the raw UMD file** (unpkg/jsdelivr). esm.sh rewrites it to ESM
+ and a classic `<script src>` chokes on `export`.
+- The require shim throws with the module name when an import isn't in the runtime โ€”
+ that's the "add to entry.mjs and rebuild" signal, not a template bug.
+- `Text type` accepts only `secondary|success|warning|danger|info`; `Tag color` has
+ no `primary` (DESIGN.md "Applying tokens in components").
+
+## Design bar (same as production surfaces)
+
+A prototype is a surface โ€” the [ux](../ux/SKILL.md) checklists apply to what it
+_demonstrates_:
+
+- Show **at least one non-happy-path state** (empty / loading / error / in-progress),
+ ideally behind a state-toggle strip like the template's. A happy-path-only
+ prototype under-specifies the design and silently blesses missing states.
+- Reuse the app's **surface contracts**: side panels are `DraggablePanel`
+ (collapse + drag-resize come free), loading is skeleton/`NeuralNetworkLoading`
+ (never antd `Spin`), modals via `createModal`-style flows.
+- Don't paint affordances you don't wire (`cursor: zoom-in` with no zoom, keycap
+ chips with no keys) โ€” in an _interactive_ prototype a dead affordance is a spec bug.
+- Walk the ux Quick review against the prototype before delivering; annotate
+ anything deliberately out of scope in an HTML comment so the implementer knows
+ it's a cut, not a decision.
diff --git a/.agents/skills/design-prototype/assets/.gitignore b/.agents/skills/design-prototype/assets/.gitignore
new file mode 100644
index 00000000000..7c54a67c5ff
--- /dev/null
+++ b/.agents/skills/design-prototype/assets/.gitignore
@@ -0,0 +1,2 @@
+lobe-prototype-runtime.js
+babel.min.js
diff --git a/.agents/skills/design-prototype/assets/entry.mjs b/.agents/skills/design-prototype/assets/entry.mjs
new file mode 100644
index 00000000000..c82c8f131f8
--- /dev/null
+++ b/.agents/skills/design-prototype/assets/entry.mjs
@@ -0,0 +1,109 @@
+/* eslint-disable no-restricted-imports */
+// Entry list for the design-prototype runtime bundle.
+// Everything a prototype can import lives here, re-exported as namespaces on a
+// single IIFE global. Bundled from THIS repo's node_modules, so versions match
+// production exactly. Missing a component? Add it below and rebuild (~2s):
+// bash .agents/skills/design-prototype/scripts/build-runtime.sh
+import {
+ ActionIcon,
+ Alert,
+ Avatar,
+ Block,
+ Button,
+ Center,
+ Collapse,
+ DraggablePanel,
+ Drawer,
+ DropdownMenu,
+ Empty,
+ Flexbox,
+ Highlighter,
+ Hotkey,
+ Icon,
+ Image,
+ Input,
+ InputNumber,
+ Markdown,
+ Modal,
+ NeuralNetworkLoading,
+ Popover,
+ ScrollShadow,
+ SearchBar,
+ Segmented,
+ Select,
+ Skeleton,
+ SortableList,
+ Tabs,
+ Tag,
+ Text,
+ TextArea,
+ ThemeProvider,
+ Tooltip,
+} from '@lobehub/ui';
+import * as baseUI from '@lobehub/ui/base-ui';
+import {
+ App,
+ Badge,
+ Checkbox,
+ Divider,
+ Dropdown,
+ Progress,
+ Radio,
+ Slider,
+ Space,
+ Steps,
+ Table,
+} from 'antd';
+import * as antdStyle from 'antd-style';
+import * as lucide from 'lucide-react';
+import * as react from 'react';
+import * as jsxRuntime from 'react/jsx-runtime';
+import * as reactDom from 'react-dom';
+import * as reactDomClient from 'react-dom/client';
+
+export default {
+ '@lobehub/ui': {
+ ActionIcon,
+ Alert,
+ Avatar,
+ Block,
+ Button,
+ Center,
+ Collapse,
+ DraggablePanel,
+ Drawer,
+ DropdownMenu,
+ Empty,
+ Flexbox,
+ Highlighter,
+ Hotkey,
+ Icon,
+ Image,
+ Input,
+ InputNumber,
+ Markdown,
+ Modal,
+ NeuralNetworkLoading,
+ Popover,
+ ScrollShadow,
+ SearchBar,
+ Segmented,
+ Select,
+ Skeleton,
+ SortableList,
+ Tabs,
+ Tag,
+ Text,
+ TextArea,
+ ThemeProvider,
+ Tooltip,
+ },
+ '@lobehub/ui/base-ui': baseUI,
+ 'antd': { App, Badge, Checkbox, Divider, Dropdown, Progress, Radio, Slider, Space, Steps, Table },
+ 'antd-style': antdStyle,
+ 'lucide-react': lucide,
+ 'react': react,
+ 'react-dom': reactDom,
+ 'react-dom/client': reactDomClient,
+ 'react/jsx-runtime': jsxRuntime,
+};
diff --git a/.agents/skills/design-prototype/references/template.html b/.agents/skills/design-prototype/references/template.html
new file mode 100644
index 00000000000..8f3a4f34663
--- /dev/null
+++ b/.agents/skills/design-prototype/references/template.html
@@ -0,0 +1,104 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <title>PROTOTYPE_TITLE</title>
+ <style>
+ body {
+ margin: 0;
+ }
+ #boot {
+ font:
+ 13px/1.6 ui-monospace,
+ monospace;
+ color: #888;
+ padding: 24px;
+ }
+ </style>
+
+ <!-- The prototype runtime: react + @lobehub/ui(+base-ui) + antd + antd-style +
+ lucide-react, bundled once from this repo's node_modules (production versions).
+ Build both files next to this HTML:
+ bash .agents/skills/design-prototype/scripts/build-runtime.sh <this-dir> -->
+ <script src="./lobe-prototype-runtime.js"></script>
+ <script>
+ // Map bare module specifiers onto the bundled namespaces, so the code below
+ // keeps production-style `import { X } from '@lobehub/ui'`.
+ window.require = (name) => {
+ const m = __PROTO_DEPS_NS__.default[name];
+ if (!m)
+ throw new Error(
+ 'prototype runtime is missing module: ' + name + ' โ€” add it to entry.mjs and rebuild',
+ );
+ return m;
+ };
+ window.exports = {};
+ window.module = { exports: window.exports };
+ </script>
+ <script src="./babel.min.js"></script>
+ </head>
+ <body>
+ <div id="boot">booting prototype runtimeโ€ฆ</div>
+ <div id="root"></div>
+
+ <script type="text/babel" data-presets="react" data-plugins="transform-modules-commonjs">
+ // Production-style React from here on. Real tokens, real components.
+ import { Button, Center, Empty, Flexbox, Text, ThemeProvider } from '@lobehub/ui';
+ import { createStyles } from 'antd-style';
+ import React, { memo, useState } from 'react';
+ import { createRoot } from 'react-dom/client';
+
+ const useStyles = createStyles(({ css, token }) => ({
+ page: css`
+ min-height: 100dvh;
+ background: ${token.colorBgLayout};
+ `,
+ }));
+
+ const App = memo(() => {
+ const { styles } = useStyles();
+ // Prototypes must demo at least one non-happy-path state (ux skill ground
+ // rule) โ€” wire a state toggle like this instead of hardcoding the happy path.
+ const [state, setState] = useState('data');
+
+ return (
+ <Flexbox className={styles.page} gap={24} padding={32}>
+ <Flexbox horizontal gap={8}>
+ {['data', 'empty', 'loading', 'error'].map((s) => (
+ <Button
+ key={s}
+ size="small"
+ type={state === s ? 'primary' : 'default'}
+ onClick={() => setState(s)}
+ >
+ {s}
+ </Button>
+ ))}
+ </Flexbox>
+ <Center flex={1}>
+ {state === 'data' && <Text>Replace me with the real surface.</Text>}
+ {state === 'empty' && <Empty description="Nothing here yet" />}
+ {state === 'loading' && (
+ <Text type="secondary">skeleton / NeuralNetworkLoading hereโ€ฆ</Text>
+ )}
+ {state === 'error' && (
+ <Flexbox align="center" gap={8}>
+ <Text type="danger">Failed to load.</Text>
+ <Button size="small">Retry</Button>
+ </Flexbox>
+ )}
+ </Center>
+ </Flexbox>
+ );
+ });
+
+ document.querySelector('#boot').remove();
+ createRoot(document.querySelector('#root')).render(
+ <ThemeProvider themeMode="auto">
+ <App />
+ </ThemeProvider>,
+ );
+ </script>
+ </body>
+</html>
diff --git a/.agents/skills/design-prototype/scripts/build-runtime.sh b/.agents/skills/design-prototype/scripts/build-runtime.sh
new file mode 100755
index 00000000000..14e2070232e
--- /dev/null
+++ b/.agents/skills/design-prototype/scripts/build-runtime.sh
@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+# Build the design-prototype runtime (real design system, bundled once) and
+# vendor babel-standalone next to it, so prototypes are single HTML files that
+# run offline over file://.
+#
+# Usage:
+# bash .agents/skills/design-prototype/scripts/build-runtime.sh [out-dir]
+# Default out-dir: <skill>/assets (gitignored artifacts)
+set -euo pipefail
+
+SKILL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+REPO_ROOT="$(cd "$SKILL_DIR/../../.." && pwd)"
+OUT_DIR="${1:-$SKILL_DIR/assets}"
+mkdir -p "$OUT_DIR"
+
+# esbuild ships as a transitive dep (vite); pick the newest copy in the pnpm store.
+ESBUILD="$(ls -d "$REPO_ROOT"/node_modules/.pnpm/esbuild@*/node_modules/esbuild/bin/esbuild | sort -V | tail -1)"
+
+cd "$REPO_ROOT"
+"$ESBUILD" "$SKILL_DIR/assets/entry.mjs" \
+ --bundle --format=iife --global-name=__PROTO_DEPS_NS__ \
+ --platform=browser --define:process.env.NODE_ENV='"production"' --minify \
+ --loader:.css=empty --loader:.woff=dataurl --loader:.woff2=dataurl \
+ --loader:.svg=dataurl --loader:.png=dataurl \
+ --outfile="$OUT_DIR/lobe-prototype-runtime.js"
+
+# Vendor babel-standalone (pinned) for offline JSX compilation.
+BABEL="$OUT_DIR/babel.min.js"
+if [ ! -s "$BABEL" ]; then
+ curl -fsSL "https://unpkg.com/@babel/[email protected]/babel.min.js" -o "$BABEL"
+fi
+
+ls -lh "$OUT_DIR/lobe-prototype-runtime.js" "$BABEL" | awk '{print $5, $NF}'
+echo "done โ†’ $OUT_DIR"
diff --git a/apps/cli/e2e/generate.e2e.test.ts b/apps/cli/e2e/generate.e2e.test.ts
index 08a206ee891..b7ea3a61526 100644
--- a/apps/cli/e2e/generate.e2e.test.ts
+++ b/apps/cli/e2e/generate.e2e.test.ts
@@ -91,14 +91,6 @@ describe('lh generate - E2E', () => {
});
});
- // โ”€โ”€ tts โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
-
- describe('tts', () => {
- it('should reject invalid backend', () => {
- expect(() => run('gen tts "hello" --backend invalid')).toThrow();
- });
- });
-
// โ”€โ”€ asr โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
describe('asr', () => {
diff --git a/apps/cli/src/commands/generate.test.ts b/apps/cli/src/commands/generate.test.ts
index edb80e96089..1782630aaea 100644
--- a/apps/cli/src/commands/generate.test.ts
+++ b/apps/cli/src/commands/generate.test.ts
@@ -331,7 +331,7 @@ describe('generate command', () => {
});
describe('tts', () => {
- it('should call TTS endpoint and save file', async () => {
+ it('should call OpenAI TTS endpoint and save file', async () => {
const audioBuffer = new ArrayBuffer(100);
vi.stubGlobal(
'fetch',
@@ -359,22 +359,6 @@ describe('generate command', () => {
expect(mockWriteFileSync).toHaveBeenCalledWith('/tmp/test.mp3', expect.any(Buffer));
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Audio saved'));
});
-
- it('should reject invalid backend', async () => {
- const program = createProgram();
- await program.parseAsync([
- 'node',
- 'test',
- 'generate',
- 'tts',
- 'Hello',
- '--backend',
- 'invalid',
- ]);
-
- expect(log.error).toHaveBeenCalledWith(expect.stringContaining('Invalid backend'));
- expect(exitSpy).toHaveBeenCalledWith(1);
- });
});
describe('asr', () => {
diff --git a/apps/cli/src/commands/generate/tts.ts b/apps/cli/src/commands/generate/tts.ts
index 72ea87043de..857ab6b29a2 100644
--- a/apps/cli/src/commands/generate/tts.ts
+++ b/apps/cli/src/commands/generate/tts.ts
@@ -14,25 +14,16 @@ export function registerTtsCommand(parent: Command) {
.option('--voice <voice>', 'Voice name', 'alloy')
.option('--speed <n>', 'Speed multiplier (0.25-4.0)', '1')
.option('--model <model>', 'TTS model', 'tts-1')
- .option('--backend <backend>', 'TTS backend: openai, microsoft, edge', 'openai')
.action(
async (
text: string,
options: {
- backend: string;
model: string;
output: string;
speed: string;
voice: string;
},
) => {
- const backends = ['openai', 'microsoft', 'edge'];
- if (!backends.includes(options.backend)) {
- log.error(`Invalid backend. Must be one of: ${backends.join(', ')}`);
- process.exit(1);
- return;
- }
-
const { serverUrl, headers } = await getAuthInfo();
const payload: Record<string, any> = {
@@ -46,7 +37,7 @@ export function registerTtsCommand(parent: Command) {
voice: options.voice,
};
- const res = await fetch(`${serverUrl}/webapi/tts/${options.backend}`, {
+ const res = await fetch(`${serverUrl}/webapi/tts/openai`, {
body: JSON.stringify(payload),
headers,
method: 'POST',
diff --git a/apps/server/src/globalConfig/parseDefaultAgent.test.ts b/apps/server/src/globalConfig/parseDefaultAgent.test.ts
index 6acdf21ef69..0a29bd601c7 100644
--- a/apps/server/src/globalConfig/parseDefaultAgent.test.ts
+++ b/apps/server/src/globalConfig/parseDefaultAgent.test.ts
@@ -71,10 +71,10 @@ describe('parseAgentConfig', () => {
expect(parseAgentConfig(envStr)).toEqual(expected);
});
- it('parses tts voice configuration correctly', () => {
- const envStr = 'tts.voice.openai=english-voice;tts.voice.microsoft=spanish-voice';
+ it('parses OpenAI TTS voice configuration correctly', () => {
+ const envStr = 'tts.voice.openai=english-voice';
const expected = {
- tts: { voice: { openai: 'english-voice', microsoft: 'spanish-voice' } },
+ tts: { voice: { openai: 'english-voice' } },
};
expect(parseAgentConfig(envStr)).toEqual(expected);
});
diff --git a/apps/server/src/services/messenger/platforms/registry.test.ts b/apps/server/src/services/messenger/platforms/registry.test.ts
index 525d16a73d1..f9378e73d20 100644
--- a/apps/server/src/services/messenger/platforms/registry.test.ts
+++ b/apps/server/src/services/messenger/platforms/registry.test.ts
@@ -1,6 +1,10 @@
// @vitest-environment node
import { describe, expect, it, vi } from 'vitest';
+// Static import keeps the heavy platform module graph (chat adapters, discord
+// REST, installationsโ€ฆ) in the collect phase instead of counting against the
+// 5s testTimeout of the singleton test below.
+import { messengerPlatformRegistry } from './index';
import { MessengerPlatformRegistry } from './registry';
const buildDefinition = (overrides: Partial<any> = {}) => ({
@@ -76,8 +80,7 @@ describe('MessengerPlatformRegistry', () => {
});
describe('messengerPlatformRegistry singleton', () => {
- it('registers slack, telegram, and discord on import', async () => {
- const { messengerPlatformRegistry } = await import('./index');
+ it('registers slack, telegram, and discord on import', () => {
const ids = messengerPlatformRegistry.listPlatforms().map((d) => d.id);
expect(ids).toEqual(expect.arrayContaining(['slack', 'telegram', 'discord']));
});
diff --git a/eslint-suppressions.json b/eslint-suppressions.json
index 1bfc792dffa..7949cc705a6 100644
--- a/eslint-suppressions.json
+++ b/eslint-suppressions.json
@@ -119,16 +119,6 @@
"count": 1
}
},
- "src/features/AgentSetting/AgentTTS/SelectWithTTSPreview.tsx": {
- "no-restricted-imports": {
- "count": 2
- }
- },
- "src/features/AgentSetting/AgentTTS/index.tsx": {
- "no-restricted-imports": {
- "count": 1
- }
- },
"src/features/AgentSkillEdit/index.tsx": {
"no-restricted-imports": {
"count": 1
diff --git a/packages/types/src/agent/tts.ts b/packages/types/src/agent/tts.ts
index 3248d0d644d..c99c0076b6c 100644
--- a/packages/types/src/agent/tts.ts
+++ b/packages/types/src/agent/tts.ts
@@ -1,12 +1,10 @@
-export type TTSServer = 'openai' | 'edge' | 'microsoft';
+export type TTSServer = 'openai';
export interface LobeAgentTTSConfig {
showAllLocaleVoice?: boolean;
sttLocale: 'auto' | string;
ttsService: TTSServer;
voice: {
- edge?: string;
- microsoft?: string;
openai: string;
};
}
diff --git a/src/app/(backend)/webapi/tts/edge/route.ts b/src/app/(backend)/webapi/tts/edge/route.ts
deleted file mode 100644
index 0a4722fa34d..00000000000
--- a/src/app/(backend)/webapi/tts/edge/route.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { type EdgeSpeechPayload } from '@lobehub/tts';
-import { EdgeSpeechTTS } from '@lobehub/tts';
-
-import { createSpeechResponse } from '@/server/utils/createSpeechResponse';
-
-export const POST = async (req: Request) => {
- const payload = (await req.json()) as EdgeSpeechPayload;
-
- return createSpeechResponse(() => EdgeSpeechTTS.createRequest({ payload }), {
- logTag: 'webapi/tts/edge',
- messages: {
- failure: 'Failed to synthesize speech',
- invalid: 'Unexpected payload from Edge speech API',
- },
- });
-};
diff --git a/src/app/(backend)/webapi/tts/microsoft/route.ts b/src/app/(backend)/webapi/tts/microsoft/route.ts
deleted file mode 100644
index beeffab945e..00000000000
--- a/src/app/(backend)/webapi/tts/microsoft/route.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { type MicrosoftSpeechPayload } from '@lobehub/tts';
-import { MicrosoftSpeechTTS } from '@lobehub/tts';
-
-import { createSpeechResponse } from '@/server/utils/createSpeechResponse';
-
-export const POST = async (req: Request) => {
- const payload = (await req.json()) as MicrosoftSpeechPayload;
-
- return createSpeechResponse(() => MicrosoftSpeechTTS.createRequest({ payload }), {
- logTag: 'webapi/tts/microsoft',
- messages: {
- failure: 'Failed to synthesize speech',
- invalid: 'Unexpected payload from Microsoft speech API',
- },
- });
-};
diff --git a/src/features/AgentSetting/AgentCategory/useCategory.tsx b/src/features/AgentSetting/AgentCategory/useCategory.tsx
index d0432787e6a..26236ed9c12 100644
--- a/src/features/AgentSetting/AgentCategory/useCategory.tsx
+++ b/src/features/AgentSetting/AgentCategory/useCategory.tsx
@@ -1,6 +1,6 @@
import { Icon } from '@lobehub/ui';
import { type MenuItemType } from 'antd/es/menu/interface';
-import { Activity, Bot, Handshake, LinkIcon, Mic2 } from 'lucide-react';
+import { Activity, Bot, Handshake, LinkIcon } from 'lucide-react';
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -38,11 +38,6 @@ export const useCategory = ({ mobile }: UseCategoryOptions = {}) => {
key: ChatSettingsTabs.SelfIteration,
label: t('agentTab.selfIteration'),
},
- {
- icon: <Icon icon={Mic2} size={iconSize} />,
- key: ChatSettingsTabs.TTS,
- label: t('agentTab.tts'),
- },
{
icon: <Icon icon={LinkIcon} size={iconSize} />,
key: ChatSettingsTabs.Connector,
diff --git a/src/features/AgentSetting/AgentTTS/SelectWithTTSPreview.tsx b/src/features/AgentSetting/AgentTTS/SelectWithTTSPreview.tsx
deleted file mode 100644
index 32aeffb7949..00000000000
--- a/src/features/AgentSetting/AgentTTS/SelectWithTTSPreview.tsx
+++ /dev/null
@@ -1,127 +0,0 @@
-import { getMessageError } from '@lobechat/fetch-sse';
-import { type ChatMessageError } from '@lobechat/types';
-import { AudioPlayer } from '@lobehub/tts/react';
-import { type SelectProps } from '@lobehub/ui';
-import { Alert, Button, Flexbox, Highlighter, Select } from '@lobehub/ui';
-import { type RefSelectProps } from 'antd';
-import { cssVar } from 'antd-style';
-import { useCallback, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { useTTS } from '@/hooks/useTTS';
-import { type TTSServer } from '@/types/agent';
-
-interface SelectWithTTSPreviewProps extends SelectProps {
- server: TTSServer;
-}
-
-const SelectWithTTSPreview = ({
- ref,
- value,
- options,
- server,
- onSelect,
- ...rest
-}: SelectWithTTSPreviewProps & { ref?: React.RefObject<RefSelectProps | null> }) => {
- const [error, setError] = useState<ChatMessageError>();
- const [voice, setVoice] = useState<string>(value);
- const { t } = useTranslation('welcome');
- const PREVIEW_TEXT = ['Lobe Chat', t('slogan.title'), t('slogan.desc1')].join('. ');
-
- const setDefaultError = useCallback(
- (err?: any) => {
- setError({ body: err, message: t('tts.responseError', { ns: 'error' }), type: 500 });
- },
- [t],
- );
-
- const { isGlobalLoading, audio, stop, start, response, setText } = useTTS(PREVIEW_TEXT, {
- onError: (err) => {
- stop();
- setDefaultError(err);
- },
- onErrorRetry: (err) => {
- stop();
- setDefaultError(err);
- },
- onSuccess: async () => {
- if (!response) return;
- if (response.status === 200) return;
- const message = await getMessageError(response);
- if (message) {
- setError(message);
- } else {
- setDefaultError();
- }
- stop();
- },
- server,
- voice,
- });
-
- const handleCloseError = useCallback(() => {
- setError(undefined);
- stop();
- }, [stop]);
-
- const handleRetry = useCallback(() => {
- setError(undefined);
- stop();
- start();
- }, [stop, start]);
-
- const handleSelect: SelectProps['onSelect'] = (value, option) => {
- stop();
- setVoice(value as string);
- setText([PREVIEW_TEXT, option?.label].join(' - '));
- onSelect?.(value, option);
- };
- return (
- <Flexbox gap={8}>
- <Flexbox horizontal align={'center'} gap={8} style={{ width: '100%' }}>
- <Select options={options} ref={ref} value={value} onSelect={handleSelect} {...rest} />
- <AudioPlayer
- buttonActive
- allowPause={false}
- audio={audio}
- buttonSize={{ blockSize: 36, size: 16 }}
- isLoading={isGlobalLoading}
- showDonload={false}
- showSlider={false}
- showTime={false}
- style={{ flex: 'none', padding: 0, width: 'unset' }}
- title={t('settingTTS.voice.preview', { ns: 'setting' })}
- buttonStyle={{
- background: cssVar.colorBgContainer,
- border: `1px solid ${cssVar.colorBorder}`,
- }}
- onInitPlay={start}
- onLoadingStop={stop}
- />
- </Flexbox>
- {error && (
- <Alert
- closable
- style={{ alignItems: 'center', width: '100%' }}
- title={error.message}
- type="error"
- action={
- <Button size={'small'} type={'primary'} onClick={handleRetry}>
- {t('retry', { ns: 'common' })}
- </Button>
- }
- extra={
- error.body && (
- <Highlighter actionIconSize={'small'} language={'json'} variant={'borderless'}>
- {JSON.stringify(error.body, null, 2)}
- </Highlighter>
- )
- }
- onClose={handleCloseError}
- />
- )}
- </Flexbox>
- );
-};
-
-export default SelectWithTTSPreview;
diff --git a/src/features/AgentSetting/AgentTTS/index.tsx b/src/features/AgentSetting/AgentTTS/index.tsx
deleted file mode 100644
index e3a58538cd1..00000000000
--- a/src/features/AgentSetting/AgentTTS/index.tsx
+++ /dev/null
@@ -1,105 +0,0 @@
-'use client';
-
-import { VoiceList } from '@lobehub/tts';
-import { type FormGroupItemType } from '@lobehub/ui';
-import { Form, Select } from '@lobehub/ui';
-import { Switch } from 'antd';
-import isEqual from 'fast-deep-equal';
-import { Mic } from 'lucide-react';
-import { memo, useMemo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { FORM_STYLE } from '@/const/layoutTokens';
-import { useGlobalStore } from '@/store/global';
-import { globalGeneralSelectors } from '@/store/global/selectors';
-
-import { selectors, useStore } from '../store';
-import { ttsOptions } from './options';
-import SelectWithTTSPreview from './SelectWithTTSPreview';
-
-const TTS_SETTING_KEY = 'tts';
-const { openaiVoiceOptions } = VoiceList;
-
-const AgentTTS = memo(() => {
- const { t } = useTranslation('setting');
- const [form] = Form.useForm();
- const voiceList = useGlobalStore((s) => {
- const locale = globalGeneralSelectors.currentLanguage(s);
- return (all?: boolean) => new VoiceList(all ? undefined : locale);
- });
- const config = useStore(selectors.currentTtsConfig, isEqual);
- const [disabled, updateConfig] = useStore((s) => [s.disabled, s.setAgentConfig]);
-
- const { edgeVoiceOptions, microsoftVoiceOptions } = useMemo(
- () => voiceList(config.showAllLocaleVoice),
- [config.showAllLocaleVoice],
- );
-
- const tts: FormGroupItemType = {
- children: [
- {
- children: <Select options={ttsOptions} />,
- desc: t('settingTTS.ttsService.desc'),
- label: t('settingTTS.ttsService.title'),
- name: [TTS_SETTING_KEY, 'ttsService'],
- },
- {
- children: <Switch />,
- desc: t('settingTTS.showAllLocaleVoice.desc'),
- hidden: config.ttsService === 'openai',
- label: t('settingTTS.showAllLocaleVoice.title'),
- layout: 'horizontal',
- minWidth: undefined,
- name: [TTS_SETTING_KEY, 'showAllLocaleVoice'],
- valuePropName: 'checked',
- },
- {
- children: <SelectWithTTSPreview options={openaiVoiceOptions} server={'openai'} />,
- desc: t('settingTTS.voice.desc'),
- hidden: config.ttsService !== 'openai',
- label: t('settingTTS.voice.title'),
- name: [TTS_SETTING_KEY, 'voice', 'openai'],
- },
- {
- children: <SelectWithTTSPreview options={edgeVoiceOptions} server={'edge'} />,
- desc: t('settingTTS.voice.desc'),
- divider: false,
- hidden: config.ttsService !== 'edge',
- label: t('settingTTS.voice.title'),
- name: [TTS_SETTING_KEY, 'voice', 'edge'],
- },
- {
- children: <SelectWithTTSPreview options={microsoftVoiceOptions} server={'microsoft'} />,
- desc: t('settingTTS.voice.desc'),
- divider: false,
- hidden: config.ttsService !== 'microsoft',
- label: t('settingTTS.voice.title'),
- name: [TTS_SETTING_KEY, 'voice', 'microsoft'],
- },
- ],
- icon: Mic,
- title: t('settingTTS.title'),
- };
-
- return (
- <Form
- disabled={disabled}
- footer={<Form.SubmitFooter />}
- form={form}
- items={[tts]}
- itemsType={'group'}
- variant={'borderless'}
- initialValues={{
- [TTS_SETTING_KEY]: config,
- }}
- onFinish={(values) => {
- if (disabled) return;
-
- updateConfig(values);
- }}
- {...FORM_STYLE}
- />
- );
-});
-
-export default AgentTTS;
diff --git a/src/features/AgentSetting/AgentTTS/options.tsx b/src/features/AgentSetting/AgentTTS/options.tsx
deleted file mode 100644
index 816c7d5bb89..00000000000
--- a/src/features/AgentSetting/AgentTTS/options.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import { Azure, OpenAI } from '@lobehub/icons';
-import { type SelectProps } from '@lobehub/ui';
-
-import { LabelRenderer } from '@/components/ModelSelect';
-
-export const ttsOptions: SelectProps['options'] = [
- {
- label: <LabelRenderer Icon={OpenAI.Avatar} label={'OpenAI'} />,
- value: 'openai',
- },
- {
- label: <LabelRenderer Icon={Azure.Avatar} label={'Edge Speech'} />,
- value: 'edge',
- },
- {
- label: <LabelRenderer Icon={Azure.Avatar} label={'Microsoft Speech'} />,
- value: 'microsoft',
- },
-];
diff --git a/src/features/AgentSetting/store/selectors.ts b/src/features/AgentSetting/store/selectors.ts
index 1d55264f6b4..2bef3598a39 100644
--- a/src/features/AgentSetting/store/selectors.ts
+++ b/src/features/AgentSetting/store/selectors.ts
@@ -1,9 +1,5 @@
import { DEFAULT_AGENT_META } from '@/const/meta';
-import {
- DEFAULT_AGENT_CHAT_CONFIG,
- DEFAULT_AGENT_CONFIG,
- DEFAUTT_AGENT_TTS_CONFIG,
-} from '@/const/settings';
+import { DEFAULT_AGENT_CHAT_CONFIG, DEFAULT_AGENT_CONFIG } from '@/const/settings';
import { type LobeAgentChatConfig } from '@/types/agent';
import { merge } from '@/utils/merge';
@@ -18,15 +14,12 @@ const currentChatConfig = (s: Store) => merge(DEFAULT_AGENT_CHAT_CONFIG, s.confi
const currentMetaConfig = (s: Store) => merge(DEFAULT_AGENT_META, s.meta);
-const currentTtsConfig = (s: Store) => merge(DEFAUTT_AGENT_TTS_CONFIG, s.config.tts);
-
export const DEFAULT_OPENING_QUESTIONS: string[] = [];
export const selectors = {
chatConfig,
currentAgentConfig,
currentChatConfig,
currentMetaConfig,
- currentTtsConfig,
openingMessage: (s: Store) => s.config.openingMessage,
openingQuestions: (s: Store) => s.config.openingQuestions || DEFAULT_OPENING_QUESTIONS,
};
diff --git a/src/features/Conversation/Messages/components/Extras/TTS/index.tsx b/src/features/Conversation/Messages/components/Extras/TTS/index.tsx
index 6810f87173a..69c7d9a96cb 100644
--- a/src/features/Conversation/Messages/components/Extras/TTS/index.tsx
+++ b/src/features/Conversation/Messages/components/Extras/TTS/index.tsx
@@ -4,8 +4,6 @@ import { Md5 } from 'ts-md5';
import { contextSelectors, useConversationStore } from '@/features/Conversation/store';
import { useAgentStore } from '@/store/agent';
import { agentByIdSelectors } from '@/store/agent/selectors';
-import { useGlobalStore } from '@/store/global';
-import { globalGeneralSelectors } from '@/store/global/selectors';
import FilePlayer from './FilePlayer';
import { type TTSProps } from './InitPlayer';
@@ -14,9 +12,8 @@ import InitPlayer from './InitPlayer';
const TTS = memo<TTSProps>(
(props) => {
const { file, voice, content, contentMd5 } = props;
- const lang = useGlobalStore(globalGeneralSelectors.currentLanguage);
const agentId = useConversationStore(contextSelectors.agentId);
- const currentVoice = useAgentStore(agentByIdSelectors.getAgentTTSVoiceById(agentId, lang));
+ const currentVoice = useAgentStore(agentByIdSelectors.getAgentTTSVoiceById(agentId));
const md5 = useMemo(() => Md5.hashStr(content).toString(), [content]);
diff --git a/src/hooks/useTTS.ts b/src/hooks/useTTS.ts
index 7485a94d45b..f4098e071d8 100644
--- a/src/hooks/useTTS.ts
+++ b/src/hooks/useTTS.ts
@@ -1,10 +1,5 @@
-import {
- type EdgeSpeechOptions,
- type MicrosoftSpeechOptions,
- type OpenAITTSOptions,
- type TTSOptions,
-} from '@lobehub/tts/react';
-import { useEdgeSpeech, useMicrosoftSpeech, useOpenAITTS } from '@lobehub/tts/react';
+import { type OpenAITTSOptions, type TTSOptions } from '@lobehub/tts/react';
+import { useOpenAITTS } from '@lobehub/tts/react';
import isEqual from 'fast-deep-equal';
import { useBusinessTTSProvider } from '@/business/client/hooks/useBusinessTTSProvider';
@@ -12,77 +7,38 @@ import { createHeaderWithOpenAI } from '@/services/_header';
import { API_ENDPOINTS } from '@/services/_url';
import { useAgentStore } from '@/store/agent';
import { agentSelectors } from '@/store/agent/selectors';
-import { useGlobalStore } from '@/store/global';
-import { globalGeneralSelectors } from '@/store/global/selectors';
import { serverConfigSelectors, useServerConfigStore } from '@/store/serverConfig';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/selectors';
-import { type TTSServer } from '@/types/agent';
interface TTSConfig extends TTSOptions {
onUpload?: (currentVoice: string, arraybuffers: ArrayBuffer[]) => void;
- server?: TTSServer;
voice?: string;
}
export const useTTS = (content: string, config?: TTSConfig) => {
const ttsSettings = useUserStore(settingsSelectors.currentTTS, isEqual);
- const ttsAgentSettings = useAgentStore(agentSelectors.currentAgentTTS, isEqual);
- const lang = useGlobalStore(globalGeneralSelectors.currentLanguage);
- const voice = useAgentStore(agentSelectors.currentAgentTTSVoice(lang));
+ const voice = useAgentStore(agentSelectors.currentAgentTTSVoice);
const businessTTSProvider = useBusinessTTSProvider();
const enableBusinessFeatures = useServerConfigStore(serverConfigSelectors.enableBusinessFeatures);
- let useSelectedTTS;
- let options: any = {};
- switch (config?.server || ttsAgentSettings.ttsService) {
- case 'openai': {
- useSelectedTTS = useOpenAITTS;
- options = {
- api: {
- headers: createHeaderWithOpenAI(),
- serviceUrl: API_ENDPOINTS.tts(enableBusinessFeatures ? businessTTSProvider : 'openai'),
- },
- options: {
- model: ttsSettings.openAI.ttsModel,
- voice: config?.voice || voice,
- },
- } as OpenAITTSOptions;
- break;
- }
- case 'edge': {
- useSelectedTTS = useEdgeSpeech;
- options = {
- api: {
- /**
- * @description client fetch
- * serviceUrl: TTS_URL.edge,
- */
- },
- options: {
- voice: config?.voice || voice,
- },
- } as EdgeSpeechOptions;
- break;
- }
- case 'microsoft': {
- useSelectedTTS = useMicrosoftSpeech;
- options = {
- api: {
- serviceUrl: API_ENDPOINTS.microsoft,
- },
- options: {
- voice: config?.voice || voice,
- },
- } as MicrosoftSpeechOptions;
- break;
- }
- }
+ const currentVoice = config?.voice || voice;
- return useSelectedTTS(content, {
+ const options = {
+ api: {
+ headers: createHeaderWithOpenAI(),
+ serviceUrl: API_ENDPOINTS.tts(enableBusinessFeatures ? businessTTSProvider : 'openai'),
+ },
+ options: {
+ model: ttsSettings.openAI.ttsModel,
+ voice: currentVoice,
+ },
+ } as OpenAITTSOptions;
+
+ return useOpenAITTS(content, {
...config,
...options,
onFinish: (arraybuffers) => {
- config?.onUpload?.(options.voice || 'alloy', arraybuffers);
+ config?.onUpload?.(currentVoice || 'alloy', arraybuffers);
},
});
};
diff --git a/src/routes/(mobile)/chat/settings/features/AgentInfoDescription/index.tsx b/src/routes/(mobile)/chat/settings/features/AgentInfoDescription/index.tsx
index 9ca738cc9c0..76cf100f39d 100644
--- a/src/routes/(mobile)/chat/settings/features/AgentInfoDescription/index.tsx
+++ b/src/routes/(mobile)/chat/settings/features/AgentInfoDescription/index.tsx
@@ -23,11 +23,6 @@ interface ChatConfig {
searchMode?: string;
}
-interface TTSConfig {
- ttsService?: string;
- voice?: any;
-}
-
interface AgentInfoDescriptionProps {
agentConfig?: AgentConfig;
chatConfig?: ChatConfig;
@@ -52,7 +47,6 @@ interface AgentInfoDescriptionProps {
plugins?: string[];
provider?: string;
systemRole?: string;
- ttsConfig?: TTSConfig;
}
const AgentInfoDescription = memo<AgentInfoDescriptionProps>(
@@ -67,7 +61,6 @@ const AgentInfoDescription = memo<AgentInfoDescriptionProps>(
plugins = [],
provider,
systemRole,
- ttsConfig,
}) => {
const { t } = useTranslation('setting');
// Convert remote data format
@@ -83,7 +76,6 @@ const AgentInfoDescription = memo<AgentInfoDescriptionProps>(
plugins,
provider,
systemRole,
- ttsConfig,
};
}
@@ -109,7 +101,6 @@ const AgentInfoDescription = memo<AgentInfoDescriptionProps>(
plugins: config.plugins?.map((p: any) => (typeof p === 'string' ? p : p.identifier)) || [],
provider: config.model?.provider,
systemRole: config.systemRole,
- ttsConfig: config.tts || {},
};
};
diff --git a/src/services/__tests__/_url.test.ts b/src/services/__tests__/_url.test.ts
index 1d56bd69ea8..7cf22bd62f9 100644
--- a/src/services/__tests__/_url.test.ts
+++ b/src/services/__tests__/_url.test.ts
@@ -6,8 +6,6 @@ describe('API_ENDPOINTS', () => {
it('should return correct basePath URLs', () => {
expect(API_ENDPOINTS.oauth).toBe('/api/auth');
expect(API_ENDPOINTS.trace).toBe('/webapi/trace');
- expect(API_ENDPOINTS.edge).toBe('/webapi/tts/edge');
- expect(API_ENDPOINTS.microsoft).toBe('/webapi/tts/microsoft');
});
it('should return correct dynamic URLs', () => {
diff --git a/src/services/_url.ts b/src/services/_url.ts
index d7c263bd9da..e29d29573dc 100644
--- a/src/services/_url.ts
+++ b/src/services/_url.ts
@@ -14,8 +14,6 @@ export const API_ENDPOINTS = {
// TTS
tts: (provider: string) => `/webapi/tts/${provider}`,
- edge: '/webapi/tts/edge',
- microsoft: '/webapi/tts/microsoft',
};
export const MARKET_OIDC_ENDPOINTS = {
diff --git a/src/store/agent/selectors/agentByIdSelectors.test.ts b/src/store/agent/selectors/agentByIdSelectors.test.ts
index dc5a165bfd8..2f6362d7a2f 100644
--- a/src/store/agent/selectors/agentByIdSelectors.test.ts
+++ b/src/store/agent/selectors/agentByIdSelectors.test.ts
@@ -179,13 +179,13 @@ describe('agentByIdSelectors', () => {
},
});
- expect(agentByIdSelectors.getAgentTTSVoiceById('agent-1', 'en-US')(state)).toBe('nova');
+ expect(agentByIdSelectors.getAgentTTSVoiceById('agent-1')(state)).toBe('nova');
});
it('falls back to a default voice when the agent config is missing', () => {
const state = createState({ agentMap: {} });
- expect(agentByIdSelectors.getAgentTTSVoiceById('missing', 'en-US')(state)).toBeTruthy();
+ expect(agentByIdSelectors.getAgentTTSVoiceById('missing')(state)).toBe('alloy');
});
});
});
diff --git a/src/store/agent/selectors/agentByIdSelectors.ts b/src/store/agent/selectors/agentByIdSelectors.ts
index 9a2b6234aaa..200e98911f7 100644
--- a/src/store/agent/selectors/agentByIdSelectors.ts
+++ b/src/store/agent/selectors/agentByIdSelectors.ts
@@ -7,7 +7,6 @@ import {
type LobeAgentTTSConfig,
type RuntimeEnvConfig,
} from '@lobechat/types';
-import { VoiceList } from '@lobehub/tts';
import { resolveTargetDeviceId } from '@/helpers/agentWorkingDirectory';
import { globalAgentContextManager } from '@/helpers/GlobalAgentContextManager';
@@ -46,27 +45,9 @@ const getAgentTTSById =
agentSelectors.getAgentConfigById(agentId)(s)?.tts || DEFAUTT_AGENT_TTS_CONFIG;
const getAgentTTSVoiceById =
- (agentId: string, lang: string) =>
- (s: AgentStoreState): string => {
- const { voice, ttsService } = getAgentTTSById(agentId)(s);
- const voiceList = new VoiceList(lang);
- let currentVoice;
- switch (ttsService) {
- case 'openai': {
- currentVoice = voice.openai || (VoiceList.openaiVoiceOptions?.[0].value as string);
- break;
- }
- case 'edge': {
- currentVoice = voice.edge || (voiceList.edgeVoiceOptions?.[0].value as string);
- break;
- }
- case 'microsoft': {
- currentVoice = voice.microsoft || (voiceList.microsoftVoiceOptions?.[0].value as string);
- break;
- }
- }
- return currentVoice || 'alloy';
- };
+ (agentId: string) =>
+ (s: AgentStoreState): string =>
+ getAgentTTSById(agentId)(s).voice?.openai || 'alloy';
const getAgentConfigErrorById =
(agentId: string) =>
diff --git a/src/store/agent/selectors/selectors.test.ts b/src/store/agent/selectors/selectors.test.ts
index 142485ed33b..5e0b15cdaff 100644
--- a/src/store/agent/selectors/selectors.test.ts
+++ b/src/store/agent/selectors/selectors.test.ts
@@ -8,7 +8,7 @@ import {
INBOX_SESSION_ID,
} from '@lobechat/const';
import { KnowledgeType } from '@lobechat/types';
-import { describe, expect, it, vi } from 'vitest';
+import { describe, expect, it } from 'vitest';
import { type AgentStoreState } from '@/store/agent/initialState';
import { initialAgentSliceState } from '@/store/agent/slices/agent/initialState';
@@ -16,15 +16,6 @@ import { initialBuiltinAgentSliceState } from '@/store/agent/slices/builtin';
import { agentSelectors, currentAgentConfig } from './selectors';
-// Mock VoiceList
-vi.mock('@lobehub/tts', () => ({
- VoiceList: class {
- static openaiVoiceOptions = [{ value: 'alloy' }];
- edgeVoiceOptions = [{ value: 'edge-voice' }];
- microsoftVoiceOptions = [{ value: 'microsoft-voice' }];
- },
-}));
-
const createState = (overrides: Partial<AgentStoreState> = {}): AgentStoreState => ({
...initialAgentSliceState,
...initialBuiltinAgentSliceState,
@@ -466,7 +457,7 @@ describe('agentSelectors', () => {
});
describe('currentAgentTTSVoice', () => {
- it('should return openai voice when ttsService is openai', () => {
+ it('should return openai voice', () => {
const state = createState({
activeAgentId: 'agent-1',
agentMap: {
@@ -476,33 +467,7 @@ describe('agentSelectors', () => {
},
});
- expect(agentSelectors.currentAgentTTSVoice('en-US')(state)).toBe('nova');
- });
-
- it('should return edge voice when ttsService is edge', () => {
- const state = createState({
- activeAgentId: 'agent-1',
- agentMap: {
- 'agent-1': {
- tts: { ttsService: 'edge', voice: { edge: 'edge-custom' } },
- },
- },
- });
-
- expect(agentSelectors.currentAgentTTSVoice('en-US')(state)).toBe('edge-custom');
- });
-
- it('should return microsoft voice when ttsService is microsoft', () => {
- const state = createState({
- activeAgentId: 'agent-1',
- agentMap: {
- 'agent-1': {
- tts: { ttsService: 'microsoft', voice: { microsoft: 'microsoft-custom' } },
- },
- },
- });
-
- expect(agentSelectors.currentAgentTTSVoice('en-US')(state)).toBe('microsoft-custom');
+ expect(agentSelectors.currentAgentTTSVoice(state)).toBe('nova');
});
it('should return default voice when no voice specified', () => {
@@ -515,7 +480,7 @@ describe('agentSelectors', () => {
},
});
- expect(agentSelectors.currentAgentTTSVoice('en-US')(state)).toBe('alloy');
+ expect(agentSelectors.currentAgentTTSVoice(state)).toBe('alloy');
});
});
diff --git a/src/store/agent/selectors/selectors.ts b/src/store/agent/selectors/selectors.ts
index 445ec2b8b33..4fb60a883be 100644
--- a/src/store/agent/selectors/selectors.ts
+++ b/src/store/agent/selectors/selectors.ts
@@ -17,7 +17,6 @@ import {
type RuntimeEnvConfig,
} from '@lobechat/types';
import { KnowledgeType } from '@lobechat/types';
-import { VoiceList } from '@lobehub/tts';
import { DEFAULT_OPENING_QUESTIONS } from '@/features/AgentSetting/store/selectors';
import { resolveTargetDeviceId } from '@/helpers/agentWorkingDirectory';
@@ -153,28 +152,8 @@ const currentAgentTTS = (s: AgentStoreState): LobeAgentTTSConfig => {
return config?.tts || DEFAUTT_AGENT_TTS_CONFIG;
};
-const currentAgentTTSVoice =
- (lang: string) =>
- (s: AgentStoreState): string => {
- const { voice, ttsService } = currentAgentTTS(s);
- const voiceList = new VoiceList(lang);
- let currentVoice;
- switch (ttsService) {
- case 'openai': {
- currentVoice = voice.openai || (VoiceList.openaiVoiceOptions?.[0].value as string);
- break;
- }
- case 'edge': {
- currentVoice = voice.edge || (voiceList.edgeVoiceOptions?.[0].value as string);
- break;
- }
- case 'microsoft': {
- currentVoice = voice.microsoft || (voiceList.microsoftVoiceOptions?.[0].value as string);
- break;
- }
- }
- return currentVoice || 'alloy';
- };
+const currentAgentTTSVoice = (s: AgentStoreState): string =>
+ currentAgentTTS(s).voice?.openai || 'alloy';
const currentEnabledKnowledge = (s: AgentStoreState) => {
const knowledgeBases = currentAgentKnowledgeBases(s);
diff --git a/src/store/global/initialState.ts b/src/store/global/initialState.ts
index c04d71f7104..ba4964ba52b 100644
--- a/src/store/global/initialState.ts
+++ b/src/store/global/initialState.ts
@@ -27,7 +27,6 @@ export enum ChatSettingsTabs {
Plugin = 'plugin',
Prompt = 'prompt',
SelfIteration = 'selfIteration',
- TTS = 'tts',
}
export enum GroupSettingsTabs {