@framers/agentos-ext-voice-synthesis

中文文档
3.1.2发布于 2026/11/02Apache-2.0TypeScriptES Module零依赖构建来源已验证近 30 天下载 2.1万

Voice synthesis and transcription tools for AgentOS via OpenAI, ElevenLabs, Deepgram, and local Ollama/Whisper-compatible runtimes

原始使用文档
文档目录8 节
  1. Installation
  2. Configuration
  3. Tool: text_to_speech
  4. Which provider runs
  5. Where the audio goes
  6. Limits and errors
  7. Tool: speech_to_text
  8. License

Voice Synthesis Extension for AgentOS

Voice input and output tools for AgentOS:

  • text_to_speech through Deepgram, OpenAI, ElevenLabs, or a server that speaks OpenAI's speech API
  • speech_to_text through OpenAI Whisper, Deepgram, or a Whisper-compatible local server

Installation

npm install @framers/agentos-ext-voice-synthesis

Configuration

Set environment variables, or pass the options to the pack.

Environment variablePack optionWhat it sets
DEEPGRAM_API_KEYdeepgramApiKey (secret deepgram.apiKey)Deepgram, for both tools
OPENAI_API_KEYopenaiApiKey (secret openai.apiKey)OpenAI, for both tools
ELEVENLABS_API_KEYelevenLabsApiKey (secret elevenlabs.apiKey)ElevenLabs speech
DEEPGRAM_BASE_URL, OPENAI_BASE_URLdeepgramBaseUrl, openaiBaseUrl, elevenLabsBaseUrlAn API base, such as a proxy. Defaults: https://api.deepgram.com/v1, https://api.openai.com/v1, https://api.elevenlabs.io/v1
compatibleBaseUrl, compatibleApiKeyThe API base of an OpenAI-compatible speech server, such as http://localhost:8880/v1, and its key if it wants one
OLLAMA_BASE_URLollamaBaseUrlThe old option for that server, a server root such as http://localhost:11434: requests go to /v1/audio/speech under it
TTS_PROVIDERdefaultProviderauto, deepgram, openai, elevenlabs or openai-compatible (ollama is its old name)
AGENTOS_AUDIO_DIRaudioDirWhere speech is saved
saveAudioThe host's own saver
maxAudioBytes, requestTimeoutMsThe limits of one speech request: 128 MiB and five minutes
WHISPER_LOCAL_BASE_URLwhisperLocalBaseUrlA local OpenAI-compatible transcription server
STT_PROVIDERdefaultSttProviderauto, openai, deepgram or whisper-local

Tool: text_to_speech

Makes an audio file of the text and returns its URL. The audio itself is never in the output: AgentOS gives a tool's output to the model as text, and base64 audio there is hundreds of kilobytes in the next request.

Input:

  • text (string, required): the text to speak. Text longer than the provider takes is refused, not cut: OpenAI 4,096 characters, Deepgram 2,000, ElevenLabs 5,000 (eleven_v3), 10,000 (eleven_multilingual_v2), 30,000 (eleven_flash_v2) or 40,000 (eleven_flash_v2_5).
  • provider (string): auto (default), deepgram, openai, elevenlabs or openai-compatible.
  • voice (string): OpenAI: alloy, ash, ballad, coral, echo, fable, onyx, nova (default), sage, shimmer, verse, marin, cedar, or a custom voice id. ElevenLabs: rachel (default), domi, bella, antoni, josh, arnold, adam, sam, or a voice id. Deepgram: an Aura model id such as aura-2-thalia-en (default), or a voice name such as thalia, which becomes aura-2-thalia-en.
  • model (string): Deepgram: an Aura model. OpenAI: gpt-4o-mini-tts (default), tts-1-hd. ElevenLabs: eleven_multilingual_v2 (default), eleven_v3, eleven_flash_v2_5, eleven_flash_v2. eleven_v4 and eleven_v4_turbo are refused: ElevenLabs serves them through its Text to Dialogue API.
  • format (string): mp3 (default), opus, aac, flac or wav. ElevenLabs makes no aac or flac.
  • speed (number): OpenAI 0.25 to 4, Deepgram 0.7 to 1.5, ElevenLabs 0.7 to 1.2.
  • stability, similarity_boost (numbers, 0 to 1): ElevenLabs only.
  • instructions (string): OpenAI's gpt-4o-mini-tts only: how to speak.

A setting the provider used does not take is not sent, and the output names it in notSent. For Deepgram the voice is the model, so a model given beside another voice is the one that speaks, and voice is named there.

Output: audioUrl, bytes, contentType, format, provider, model, voice, characters (the length of the text), durationEstimateMs (at 150 words a minute), and notSent when a setting was not sent.

Which provider runs

A provider that is named runs, or the call fails and says which key it needs: no other provider is tried in its place. With auto:

  1. a voice that belongs to one provider picks it: an OpenAI voice name, an ElevenLabs name above, a Deepgram model id (aura-...);
  2. otherwise the first with a key: Deepgram, OpenAI, ElevenLabs.

openai-compatible runs only when it is named, or set as defaultProvider. Ollama serves no speech endpoint; the option that carries its name stays for servers set up through it.

Where the audio goes

By default the audio is saved as a new file, and audioUrl is its file: URL. The directory is audioDir, else AGENTOS_AUDIO_DIR, else agentos-audio-<uid> in the temp directory (on Windows, AppData\Local\Temp\agentos-audio in the user's profile). Each caller (userContext.userId) has a subdirectory of its own. The pack deletes nothing: the host clears the directory, and the operating system clears the default one.

  • The directory, and each caller's directory in it, must belong to the service's user with no one else able to write it. Every directory above it must belong to that user or to root and be writable by no one else, unless it is sticky, as /tmp is: a user who could rename an entry in one of them could swap the tree between a check and the write, and receive another caller's speech. All of this is made and checked before the provider is called, so a directory that is refused costs no synthesis; the error names the directory, its owner and its mode.
  • In Kubernetes, a disk-backed emptyDir is 0777 without the sticky bit, and a volume under a pod fsGroup is group-writable, so an audio directory anywhere inside one is refused. Make the mount sticky (chmod 1777 in an init container, or emptyDir.mode: 01777 on a cluster with the alpha EmptyDirVolumeMode feature gate, Kubernetes 1.37 and later), give it to the service's user, or pass saveAudio.
  • On Windows, Node reads no ACLs: only the directories' kind is checked, and an audioDir you set must be private by its ACL.
  • A file: URL names a file on the machine that ran the tool. A host whose clients are elsewhere passes saveAudio: a function that gets { bytes, contentType, tool, context }, stores the audio, and returns the http(s) URL its clients load, at most 2,048 characters. With it, nothing is written to disk.

Limits and errors

One request has five minutes (requestTimeoutMs) and may answer with at most 128 MiB (maxAudioBytes); both must be positive whole numbers. An answer that does not start as the format asked for, such as an error page sent with status 200, is refused and not saved. A provider's error comes back with its status and the first 300 characters of its body, with any configured key replaced by [redacted].

The saved file is for the host to play or serve, and speech_to_text takes its file: URL as audioUrl for the caller it was saved for (below).

Tool: speech_to_text

Providers:

  • openai — hosted Whisper via OPENAI_API_KEY
  • deepgram — hosted Deepgram STT via DEEPGRAM_API_KEY
  • whisper-local — local OpenAI-compatible transcription endpoint via WHISPER_LOCAL_BASE_URL
  • auto — prefers OpenAI, then Deepgram, then explicitly configured local STT

Input:

  • audioBase64 (string) — Base64 audio payload, optionally as a data: URL
  • audioUrl (string) — The http(s) URL of audio on a public host, at most 25 MiB. It is read through AgentOS's guardedFetch (the pack needs @framers/agentos 0.13.44 or later): every address the host resolves to must be public, each redirect is checked the same way, only ports 80 and 443 are read, and the read stops at 30 seconds. Addresses on this machine or a private network are refused, with one message whether the host is refused or does not resolve. The server must answer with an audio or video type the tool lists (among them audio/mpeg, audio/mp4, audio/wav, audio/webm, audio/ogg, application/ogg, audio/flac, audio/aac, audio/x-aac, audio/aiff, video/mp4, video/mpeg, video/webm, video/quicktime) or with application/octet-stream; whether the provider reads the format is the provider's answer. With an AgentOS that has no guardedFetch an http(s) audioUrl is refused; audioBase64 still works. audioUrl may also be the file: URL of audio text_to_speech saved, for the caller it was saved for (userContext.userId), read from the same audioDir. The file must have the saver's name and sit in that caller's subdirectory, private to the service's user, under directories no other user can change. It must be a regular file with one link, at most 25 MiB, whose bytes are still the format its name says. It is opened once, without following a link. Any other file: URL is refused with one message, which does not say which files exist; other local files are never read. These are the image packs' rules for their saved images.
  • provider (string, optional) — auto, openai, deepgram, or whisper-local
  • mimeType (string, optional) — For example audio/wav
  • fileName (string, optional) — File name sent to the provider
  • format (string, optional) — Audio format hint such as wav, mp3, m4a, webm
  • language (string, optional) — ISO language hint
  • prompt (string, optional) — Context prompt to bias transcription
  • model (string, optional) — Provider model override such as whisper-1, nova-2, or base
  • temperature (number, optional) — Whisper temperature override
  • responseFormat (string, optional) — json, text, srt, verbose_json, or vtt
  • diarize (boolean, optional) — Enable speaker diarization where supported
  • utterances (boolean, optional) — Request utterance segmentation where supported
  • smartFormat (boolean, optional) — Enable provider-side formatting where supported
  • detectLanguage (boolean, optional) — Enable provider-side language detection where supported

Output: Transcribed text, provider/model metadata, language, optional confidence, duration, and optional segments.

whisper-local targets OpenAI-compatible local transcription servers. That keeps the tool contract stable even when you swap between hosted Whisper, Deepgram, and local runtimes behind the same API shape.

License

Apache-2.0 - Frame.dev

版本与发布记录

@framers/agentos-ext-voice-synthesis 共发布 10 个版本,首次发布于 2026/02/06;过去 12 个月发布了 10 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.1.2latest2026/11/0214 天前
3.1.12026/10/2125 天前
3.1.02026/10/121 个月前
3.0.12026/10/121 个月前
3.0.02026/10/121 个月前
2.1.12026/10/111 个月前

关于 @framers/agentos-ext-voice-synthesis 的常见问题

@framers/agentos-ext-voice-synthesis 是什么?

Voice synthesis and transcription tools for AgentOS via OpenAI, ElevenLabs, Deepgram, and local Ollama/Whisper-compatible runtimes

如何安装 @framers/agentos-ext-voice-synthesis?

在项目目录运行 npm install @framers/agentos-ext-voice-synthesis,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@framers/agentos(>=0.13.44)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@framers/agentos-ext-voice-synthesis 支持 TypeScript 吗?

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

@framers/agentos-ext-voice-synthesis 支持 ESM 还是 CommonJS?

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

@framers/agentos-ext-voice-synthesis 需要什么版本的 Node.js?

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

@framers/agentos-ext-voice-synthesis 可以商用吗?

@framers/agentos-ext-voice-synthesis 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@framers/agentos-ext-voice-synthesis 的下载量有多少?

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

@framers/agentos-ext-voice-synthesis 还在维护吗?

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