该包仅提供 ESM,CommonJS 项目需注意;React 入口 @lobehub/tts/react 还需 peer 依赖 @lobehub/ui@^6、react@^19、react-dom@^19;Edge Speech 需要全局 WebSocket,Node.js 22 以下要自行用 ws 包设置 global.WebSocket;Next.js 需在 next.config.js 加 transpilePackages: ['@lobehub/tts']。
lobe-tts
lobehubMIT活跃维护高质量、可靠的 TTS/STT 库,在服务端和浏览器里都能用,统一封装 Edge、微软、OpenAI 等语音接口,省去逐个对接的麻烦。
🎤 Lobe TTS - A high-quality & reliable TTS/STT library for Server and Browser
pnpm i @lobehub/ttsREADME 未说明显存或 GPU 要求;服务端在 Node.js / Bun 运行,浏览器端使用浏览器内置语音能力。
一个同时支持服务端与浏览器的 TTS/STT 库,几行 TypeScript 就能给应用加上语音
高质量、可靠的 TTS/STT 库,在服务端和浏览器里都能用,统一封装 Edge、微软、OpenAI 等语音接口,省去逐个对接的麻烦。
核心能力
- 同一套 API 切换 Edge、OpenAI 或浏览器内置语音
- 在 Node.js/Bun 生成音频,或在浏览器直接朗读
- 提供 React hooks 与带进度、暂停、下载的音频播放器
- 长文本边生成边播放,无需等整段音频就绪
- 附带 skills.md 与 llms.txt 供编码 Agent 调用
容易踩的坑
- v6.0.1最新正式版2026-10-21 · 2026-10-21 12:13 UTC
- v6.0.02026-10-15 · 2026-10-15 16:21 UTC
查看更新说明
Version 6.0.0
Released on 2026-10-15
✨ Features
- misc: Adopt lobe-ui 6 and drop antd [force major].
What's improved
- v6.0.0-beta.1pre-release2026-10-10 · 2026-10-10 17:47 UTC
查看更新说明
Version 6.0.0-beta.1
Released on 2026-10-10
♻ Code Refactoring
- misc: Migrate to @lobehub/ui next major (drop antd-style).
Code refactoring
- misc: Migrate to @lobehub/ui next major (drop antd-style) (5bfad19)
- v5.2.12026-10-07 · 2026-10-07 08:59 UTC
查看更新说明
Version 5.2.1
Released on 2026-10-07
🐛 Bug Fixes
- misc: Drop direct antd component and type imports in favor of @lobehub/ui/base-ui.
What's fixed
- v5.2.02026-10-03 · 2026-10-03 06:25 UTC
查看更新说明
Version 5.2.0
Released on 2026-10-03
✨ Features
- misc: Migrate to @lobehub/ui/base-ui components.
What's improved
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Text-to-speech and speech-to-text for server and browser, with React hooks and audio components.
Documents · Changelog · Report Bug · Request Feature
TOC
- ✨ Why Lobe TTS?
- 🚀 Getting Started
- 🤖 AI-Powered Development
- 📦 Packages
- 📖 Documentation
- ⌨️ Local Development
- 🤝 Contributing
- 🩷 Sponsor
- 🔗 Links
✨ Why Lobe TTS?
Lobe TTS (@lobehub/tts) lets you add natural-sounding speech output and voice input to your app, on the server or in the browser, in a few lines of TypeScript. It powers the voice features of 🤯 LobeHub.
- Speak and listen — turn text into speech and speech into text with one library
- Pick your voice provider — Microsoft Edge, Microsoft Speech, OpenAI or the browser's built-in speech, behind the same simple API
- Server or browser — generate audio files in Node.js / Bun, or speak directly in the user's browser
- React-ready — drop-in hooks and an audio player with progress, pause and download, so you don't build playback yourself
- Smooth long-form playback — long text starts playing quickly instead of waiting for the whole audio
- AI-native —
skills.mdandllms.txtlet your coding agent use the real API instead of guessing
🚀 Getting Started
[!IMPORTANT]
This package is ESM only.
$ pnpm i @lobehub/tts
The React entry @lobehub/tts/react also needs the peer dependencies @lobehub/ui@^6, react@^19 and react-dom@^19.
Generate speech on the server
// index.js — run with `bun index.js`
import { EdgeSpeechTTS } from '@lobehub/tts';
import fs from 'node:fs';
const tts = new EdgeSpeechTTS({ locale: 'en-US' });
const response = await tts.create({
input: 'This is a speech demonstration',
options: { voice: 'en-US-GuyNeural' },
});
fs.writeFileSync('./speech.mp3', Buffer.from(await response.arrayBuffer()));
[!NOTE]
Edge Speech needs a globalWebSocket. It is built into Bun and Node.js 22+; on older Node.js versions, setglobal.WebSocketfrom thewspackage.
Play speech in React
import { AudioPlayer, useEdgeSpeech } from '@lobehub/tts/react';
import { Button, Flexbox } from '@lobehub/ui';
export default () => {
const { isGlobalLoading, start, stop, audio } = useEdgeSpeech('Hello from Lobe TTS', {
options: { voice: 'en-US-GuyNeural' },
});
return (
<Flexbox gap={8}>
<Button loading={isGlobalLoading} onClick={isGlobalLoading ? stop : start}>
Speak
</Button>
<AudioPlayer audio={audio} isLoading={isGlobalLoading} onLoadingStop={stop} />
</Flexbox>
);
};
Using Next.js? Add transpilePackages: ['@lobehub/tts'] to next.config.js. For other providers, speech-to-text and more examples, see the documentation.
🤖 AI-Powered Development
Lobe TTS publishes agent-friendly docs, so your AI assistant can write code against the documented API.
| Resource | What it does |
|---|---|
| Agent Skills | tts.lobehub.com/skills.md — skill entry point with setup, workflow and an index of the docs |
| llms.txt | tts.lobehub.com/llms.txt — an llms.txt index of every docs page |
Paste this into Cursor, Claude Code, Codex or any agent that can fetch URLs:
Read https://tts.lobehub.com/skills.md, then use @lobehub/tts to add a "read aloud" button to my React app.
Works with Cursor, Claude Code, Windsurf, GitHub Copilot and other tools that read skills.md or llms.txt.
📦 Packages
| Entry | Use it for |
|---|---|
@lobehub/tts | Generate speech or transcribe audio, on the server or browser |
@lobehub/tts/server | Proxy OpenAI speech and transcription from your own API route |
@lobehub/tts/react | React hooks and audio player components |
📖 Documentation
Visit tts.lobehub.com for guides, API reference and live demos. See the Changelog for release notes.
⌨️ Local Development
You can use Github Codespaces for online development:
Or clone it for local development:
$ git clone https://github.com/lobehub/lobe-tts.git
$ cd lobe-tts
$ bun install
$ bun run docs:dev
🤝 Contributing
Contributions of all types are more than welcome, if you are interested in contributing code, feel free to check out our GitHub Issues to get stuck in to show us what you’re made of.
🩷 Sponsor
Every bit counts and your one-time donation sparkles in our galaxy of support! You're a shooting star, making a swift and bright impact on our journey. Thank you for believing in us – your generosity guides us toward our mission, one brilliant flash at a time.
🔗 Links
- 🍭 Lobe UI - React component library for AI apps
- 🥨 Lobe Icons - AI / LLM brand logos and icons
- 📊 Lobe Charts - React chart components
- ✒️ Lobe Editor - Lexical-based rich text editor for React, with Markdown, plugins and a chat composer
- 🎤 Lobe TTS - TTS / STT speech library
- 📐 Lobe Lint - ESLint, Prettier, Stylelint, Commitlint and more lint configs
- 😀 Fluent Emoji - Fluent Emoji assets
- 📖 Docs Kit - Reusable documentation toolkit and lobedocs CLI for LobeHub component libraries
- 🌊 Streamdown - Headless streaming markdown engine for React