@animalabs/voice-kit

中文文档
0.1.0发布于 2026/10/14MITTypeScriptES Module近 30 天下载 3714

Pluggable STT/TTS provider seam for connectome voice: interfaces + provider adapters (ElevenLabs Scribe/stream-input, AssemblyAI) + audio math + voice-registry types. Surface-agnostic: no Discord, no Portal.

原始使用文档
文档目录4 节
  1. What's in it
  2. Contracts
  3. Development
  4. License

@animalabs/voice-kit

A provider seam for speech in Connectome. It defines one set of STT and TTS interfaces, adapters for the vendors we use, and the audio helpers around them. It knows nothing about Discord or any other surface: consumers such as @animalabs/discord-mcpl's voice leg open sessions and streams through these interfaces and never touch a vendor API directly.

npm install @animalabs/voice-kit

What's in it

ExportWhat it is
SttProvider, SttSession, SttTranscript, SttSessionOptionsSpeech-to-text interfaces
TtsProvider, TtsStream, TtsVoice, TtsAlignmentText-to-speech interfaces
ScribeSttProviderElevenLabs Scribe realtime STT
AssemblyAiSttProviderAssemblyAI realtime STT
ElevenLabsTtsProviderElevenLabs streaming TTS (stream-input), with character timing
EnergyVad, dbfsAn energy-based voice activity detector
downmixStereoToMono, monoTo48kStereoPCM conversion to and from Discord's 48 kHz stereo
loadRegistry, resolveVoice, VoiceRegistry, RegistryVoiceThe speaker-to-voice registry format

Each provider takes its API key in its constructor.

Contracts

  • Transcripts can be revised. A transcript event is keyed by utteranceId, and any field (text, speaker, even final) may arrive again for the same id. Treat the latest event per id as the truth. AssemblyAI revises text and speaker labels after an utterance is final; Scribe sends growing partials and then a commit.
  • Speaker labels are optional. A per-speaker source, such as Discord's receiver streams, runs one session per speaker and leaves speaker unset. On a mixed feed, a diarizing provider fills speaker with its own opaque label, which can also be revised.
  • PCM in, PCM out. Audio is PCM16LE mono. An STT session declares its input rate when it opens, and a TTS provider declares its output rate (outputRateHz). Converting to and from a surface's format is the consumer's job; audio.ts has the helpers.
  • TTS timing is optional. When a provider has character timing for a chunk, onAlignment fires before that chunk's onAudio, with times in milliseconds from the start of the stream and characters matching the text as it was sent. A provider without timing never fires it.

Development

npm install
npm run build      # tsc → dist/
npm test           # bun test

Releases publish from a v* tag through GitHub Actions with npm trusted publishing (see .github/workflows/publish.yml).

License

MIT

版本与发布记录

@animalabs/voice-kit 共发布 2 个版本,首次发布于 2026/10/14;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.1.0latest2026/10/1425 天前
0.0.0-stage2026/10/1425 天前

关于 @animalabs/voice-kit 的常见问题

@animalabs/voice-kit 是什么?

Pluggable STT/TTS provider seam for connectome voice: interfaces + provider adapters (ElevenLabs Scribe/stream-input, AssemblyAI) + audio math + voice-registry types. Surface-agnostic: no Discord, no Portal.

如何安装 @animalabs/voice-kit?

在项目目录运行 npm install @animalabs/voice-kit,或使用 pnpm add / yarn add / bun add。

@animalabs/voice-kit 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@animalabs/voice-kit 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@animalabs/voice-kit 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@animalabs/voice-kit 可以商用吗?

@animalabs/voice-kit 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@animalabs/voice-kit 的下载量有多少?

根据 npm 官方下载统计,@animalabs/voice-kit 在 2026/10/06 – 2026/11/04 这 30 天内被下载 3,714 次,日均约 124 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@animalabs/voice-kit 还在维护吗?

最新版本 0.1.0 发布于 2026/10/14(25 天前);至今共发布 2 个版本,其中过去 12 个月发布了 2 个;首次发布于 2026/10/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。