关于 elevenlabs
ElevenLabs 技能通过 ElevenLabs TTS API 将文本和文档转换为音频,支持单人旁白及双主持人播客。适合需要为文档制作朗读或对话式音频的用户。
主要功能
- 01文本转语音
- 02从 PDF、DOCX 等文档提取文本
- 03按句子分块并保持语音连贯
- 04生成双主持人播客
- 05列出可用语音
适用场景
- 01将文档制作成旁白音频
- 02把文档内容改编为双人播客
- 03试听并选择语音
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ sanjay3290/ ai-skills --skill elevenlabs安装后在 Claude Code 中输入/elevenlabs确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
config.example.jsonrequirements.txtscripts/elevenlabs.pyextract.py详细介绍
ElevenLabs - 文本转语音与播客技能
概览
此技能使用 ElevenLabs TTS API 将文本和文档转换为高品质音频。它支持两种模式:单人旁白和双主持人对话式播客生成。
何时使用此技能
当用户提到以下内容时启用:
- “创建播客”“生成播客”“根据文档制作播客”
- “为文档配旁白”“为此文件配旁白”“朗读”
- “文本转语音”“TTS”“转换为音频”
- “根据文档生成音频”“音频版本”
设置
配置文件位于 skills/elevenlabs/config.json:
{
"api_key": "your-elevenlabs-api-key",
"default_voice": "JBFqnCBsd6RMkjVDRZzb",
"default_model": "eleven_multilingual_v2",
"podcast_voice1": "JBFqnCBsd6RMkjVDRZzb",
"podcast_voice2": "EXAVITQu4vr4xnSDxMaL"
}
仅需设置 api_key。也可以设置 ELEVENLABS_API_KEY 环境变量。
依赖项:pip install PyPDF2 python-docx(仅处理 PDF/DOCX 文件时需要)。
多段旁白和播客需要 ffmpeg。
命令
列出声音
python skills/elevenlabs/scripts/elevenlabs.py voices
python skills/elevenlabs/scripts/elevenlabs.py voices --json
使用此命令为用户查找声音 ID。
单人 TTS
# From text
python skills/elevenlabs/scripts/elevenlabs.py tts --text "Hello world" --output ~/Downloads/hello.mp3
# From document
python skills/elevenlabs/scripts/elevenlabs.py tts --file /path/to/doc.pdf --output ~/Downloads/narration.mp3
# With specific voice
python skills/elevenlabs/scripts/elevenlabs.py tts --file doc.md --voice VOICE_ID --output out.mp3
脚本会自动处理文本提取、按句子边界分段(约 4000 个字符)、逐段进行 TTS 并保持声音连贯性,以及使用 ffmpeg 拼接音频。
播客生成
播客模式需要一个包含对话片段的 JSON 脚本文件:
[
{"speaker": "host1", "text": "Welcome to our podcast! Today we're diving into..."},
{"speaker": "host2", "text": "That's right! I found the section on..."},
{"speaker": "host1", "text": "Let's break that down..."}
]
python skills/elevenlabs/scripts/elevenlabs.py podcast --script /tmp/script.json --voice1 ID1 --voice2 ID2 --output ~/Downloads/podcast.mp3
播客工作流(适用于 Claude)
当用户要求根据文档制作播客时:
-
提取文档文本:
python skills/elevenlabs/scripts/extract.py /path/to/document.pdf -
根据提取的文本生成双主持人对话脚本。请遵循以下指南:
- 撰写自然、有吸引力的双主持人讨论
- 主持人 1 通常负责引出或介绍话题,主持人 2 则补充分析并作出回应
- 以简短的开场白开始,欢迎听众并说明话题
- 以总结或结束语收尾
- 每轮发言不超过 3000 个字符
- 调整每轮发言的长度,穿插简短回应和较长的解释
- 使用对话式语言,例如:“说得真好”“我觉得有意思的是……”
- 提及源文档中的具体细节
- 避免逐字朗读文档,而应对其进行讨论和解读
-
将脚本写入临时文件,保存为 JSON 数组:
# Write to /tmp/podcast_script.json [ {"speaker": "host1", "text": "Welcome to today's episode..."}, {"speaker": "host2", "text": "Thanks for having me..."}, ... ] -
生成播客:
python skills/elevenlabs/scripts/elevenlabs.py podcast --script /tmp/podcast_script.json --output ~/Downloads/podcast.mp3 -
清理临时脚本文件。
提示
- 先运行
voices,让用户挑选喜欢的声音 - 对于播客,建议选择特点互补的声音组合(例如,一个低沉,一个明亮)
- 默认将输出保存到
~/Downloads/,除非用户另有指定 - 对于大型文档,提醒用户注意其 ElevenLabs 方案的字符用量
评论
支持 Markdown