lobe-tts

lobehubMIT活跃维护

高质量、可靠的 TTS/STT 库,在服务端和浏览器里都能用,统一封装 Edge、微软、OpenAI 等语音接口,省去逐个对接的麻烦。

🎤 Lobe TTS - A high-quality & reliable TTS/STT library for Server and Browser

v6.0.1发布于 2026-10-21 12:13 UTC810star104fork同步于 2026-11-10 23:53 UTC

怎么上手

由 README 提炼,执行前请确认
pnpm i @lobehub/tts
硬件要求按 README 说明

README 未说明显存或 GPU 要求;服务端在 Node.js / Bun 运行,浏览器端使用浏览器内置语音能力。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

一个同时支持服务端与浏览器的 TTS/STT 库,几行 TypeScript 就能给应用加上语音

高质量、可靠的 TTS/STT 库,在服务端和浏览器里都能用,统一封装 Edge、微软、OpenAI 等语音接口,省去逐个对接的麻烦。

核心能力

  • 同一套 API 切换 Edge、OpenAI 或浏览器内置语音
  • 在 Node.js/Bun 生成音频,或在浏览器直接朗读
  • 提供 React hooks 与带进度、暂停、下载的音频播放器
  • 长文本边生成边播放,无需等整段音频就绪
  • 附带 skills.md 与 llms.txt 供编码 Agent 调用

容易踩的坑

该包仅提供 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']。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v6.0.1
  1. v6.0.1最新正式版2026-10-21 · 2026-10-21 12:13 UTC

    6.0.1 (2026-10-21)

    🎫 Chores

    • deps: Upgrade @lobehub/lint to v2 (681a31e)
    • lint: Do not fail on warnings (9b97307)

    💄 Styles

    • Apply @lobehub/lint v2 fixes (cd0c1e4)

    📝 Documentation

    • Align library emojis with GitHub descriptions (6339993)
    • Refresh README, add AGENTS.md and agent skills, redesign docs home (dad59af)
    • Update og image (3961a82)
  2. 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
    • misc: Adopt lobe-ui 6 and drop antd [force major], closes #69 (a9781d2)

  3. 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)

  4. 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
    • misc: Drop direct antd component and type imports in favor of @lobehub/ui/base-ui, closes #68 (2dc8758)

  5. 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
    • misc: Migrate to @lobehub/ui/base-ui components, closes #67 (59ad53e)

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    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?

    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.md and llms.txt let 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 global WebSocket. It is built into Bun and Node.js 22+; on older Node.js versions, set global.WebSocket from the ws package.

    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.

    ResourceWhat it does
    Agent Skillstts.lobehub.com/skills.md — skill entry point with setup, workflow and an index of the docs
    llms.txttts.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

    EntryUse it for
    @lobehub/ttsGenerate speech or transcribe audio, on the server or browser
    @lobehub/tts/serverProxy OpenAI speech and transcription from your own API route
    @lobehub/tts/reactReact 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


    📝 License

    Copyright © 2023 LobeHub. This project is MIT licensed.