add-read-aloud
它能做什么
让智能体为现有应用添加 Grok 文字转语音功能。适合希望应用能够朗读回复或旁白文字的开发者。
适用场景
- ✓当你希望有一个喇叭按钮,朗读智能体回复的时候。
- ✓当你希望应用为某个页面或提示词做旁白的时候。
- ✓当你需要从文字生成一个语音音频文件的时候。
技能链接
https://github.com/cursor/plugins/blob/main/grok-voice/skills/add-read-aloud/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请在我们应用中每条智能体回复下方加一个朗读按钮,让用户可以听到回复内容。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会配置一个服务器端请求,发送文字并返回音频文件。如果音频需要在完整文字准备好之前就开始播放,它可以通过你的后端使用流式连接。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Add Read Aloud
Add Grok Text to Speech to an existing app: a speaker button on assistant replies, auto-speak, or narration of any text. Run on /add-read-aloud, typed Read aloud, or clear “speak this” / “TTS” intent. Cursor has no speaker; wire the app, not the IDE.
Docs
- https://docs.x.ai/developers/model-capabilities/audio/text-to-speech
- API reference: https://docs.x.ai/developers/rest-api-reference/inference/voice
- Custom voices: https://docs.x.ai/developers/model-capabilities/audio/custom-voices
- Pricing (cite docs only): https://docs.x.ai/developers/pricing
Pick the path
| Need | Path |
|---|---|
| Tap speaker, hear the finished reply. Narrate a page. Generate a file. | Batch POST https://api.x.ai/v1/tts (default) |
| Audio starts while the LLM is still streaming; barge-in; texts over 15,000 chars | Streaming wss://api.x.ai/v1/tts through a backend relay |
Batch is the default for a read-aloud button: one request, one MP3, cacheable, the key never leaves the server. Go streaming only when the UX needs audio before the text is complete. POST /v1/tts has no documented streaming flag; do not invent one.
Auth
- Bearer
XAI_API_KEY, server side only. The TTS docs document no ephemeral-token flow, and browsers cannot set WebSocket headers, so browser streaming goes through your backend relay. - Never put the key in a client bundle. Do not paste keys in chat.
Steps
Map the app
- Where assistant messages render, where per-message actions live (copy, regenerate), how the reply stream ends, server framework, package manager.
- The speaker icon belongs to read aloud. Waveform is voice mode (
/add-voice), microphone is dictation (/add-dictation). Put a ghost speaker button in the message action row; loading shows a spinner, playing shows a stop square. One utterance at a time: starting a new one stops the current one. - Align the action row to the reply’s text edge, not the button’s box: an icon button centres its glyph, so if the assistant bubble has no padding pull the row left by that inset (e.g.
-ml-[5px]for a 12–14 px icon in a 24 px button). Measure in the browser;getBoundingClientRecton the<p>and the<svg>should share a left edge. - Render the button only once the reply has finished streaming; on a live message it would speak a partial reply.
- With many messages on screen, keep player state (active message id,
loading | playing, last error) in one shared store (useSyncExternalStore, a signal, whatever the app uses) so every button reflects it and errors can surface in the app's existing status area. A per-buttonlet currentis not enough. - Auto-speak: opt-in toggle, off by default, and only after a user gesture on the page (autoplay policy). Never auto-speak on load.
- If
/add-voiceis installed, itsAudioContextand PCM player can play streaming TTS; do not add a second audio graph.
Prepare the text
- Speak prose, not markup. Strip markdown: headings → text,
**bold**→ text, links → link text, inline code → the code, fenced blocks →[pause] Code block omitted., tables → one sentence per row or omit. Keep punctuation; it drives pacing. - Neutralise speech tags that arrive inside the reply (
[laugh],<whisper>…) so the model’s text cannot steer delivery. Strip only the documented tag names (list in step 5), not every bracket:[1]citations and[note]must survive. - Batch limit is 15,000 characters per request. Split longer text on paragraph, then sentence, then word boundaries and play the parts in order; fetch part N+1 while N plays or there is a silent gap at every boundary. Or use streaming.
- Cache by
hash(text + voice_id + language + speed); the same reply is often replayed.
- Speak prose, not markup. Strip markdown: headings → text,
Batch path (default)
- Server: your route takes
{ text, voice_id?, language? }, validates the shape of each (voice_id^[a-z0-9-]{1,64}$,languageBCP-47 orauto), forwards JSON, streams the body back with the upstreamContent-TypeandCache-Control: no-store. Map upstream 404 to “unknown voice” so the client gets a readable error. Default output is MP3 at 24 kHz / 128 kbps, playable everywhere in the browser. language: default to"auto"for a chat app, where replies follow the user’s language; pin"en"etc. only for fixed-language products.
- Server: your route takes
// server (any runtime with fetch)
export async function speak(text: string, voice_id = "eve", l
常见问题
API 密钥会发送到浏览器吗?
不会。密钥保存在服务器上,浏览器从不持有它。
默认采用什么方式?
对于朗读按钮,默认使用批处理请求,它会返回一个完整的音频文件。
该技能是否涵盖自定义声音?
它会指引你查阅关于自定义声音的文档,因此自定义声音是该技能会为你提及的一个选项。
详情
作者的原始描述
Use when the user runs /add-read-aloud or wants the app to speak text with Grok text-to-speech: read-aloud button on assistant replies, auto-speak, TTS, voice output, narration, IVR prompts, speech tags, voice_id. For a two-way voice agent use /add-voice. For speech-to-text use /add-dictation.
repo: cursor/plugins
热度
- GitHub 星标
- 15k
- 排名
- #10951
- 许可证
- —
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
advisor
15k如果你开启该功能,让你的智能体在关键节点咨询一个更强的第二模型,例如在重大决定之前,或在错误上卡住时。
check-agent-compatibility
15k全面检查 AI 编程智能体能否启动、验证和记录某个代码仓库,并返回一个兼容性评分以及主要问题。
cli-for-agents
15k教你的智能体设计或审查命令行工具,使 AI 智能体无需提示即可运行,并提供清晰的帮助文字和示例。
continual-learning
15k通过把回顾过往对话的工作交给专门的记忆更新程序,使你的 AGENTS.md 笔记保持最新。