audiobook
БесплатноБез исполняемых скриптовНе проверенCreate audiobooks from web content or text files. Handles content fetching, text processing, and TTS conversion with automatic fallback between ElevenLabs…
от benchflow-ai★ 1 941 звезда на GitHubОб этом скилле
Audiobook Creation Guide
Create audiobooks from web articles, essays, or text files. This skill covers the full pipeline: content fetching, text processing, and audio generation.
Quick Start
import os
# 1. Check which TTS API is available
def get_tts_provider():
if os.environ.get("ELEVENLABS_API_KEY"):
return "elevenlabs"
elif os.environ.get("OPENAI_API_KEY"):
return "openai"
else:
return "gtts" # Free, no API key needed
provider = get_tts_provider()
print(f"Using TTS provider: {provider}")
Step 1: Fetching Web Content
IMPORTANT: Verify fetched content is complete
WebFetch and similar tools may return summaries instead of full text. Always verify:
import subprocess
def fetch_article_content(url):
"""Fetch article content using curl for reliability."""
# Use curl to get raw HTML - more reliable than web fetch tools
result = subprocess.run(
["curl", "-s", url],
capture_output=True,
text=True
)
html = result.stdout
# Strip HTML tags (basic approach)
import re
text = re.sub(r'<script[^>]*>.*?</script>', '', html, flags=re.DOTALL)
text = re.sub(r'<style[^>]*>.*?</style>', '', html, flags=re.DOTALL)
text = re.sub(r'<[^>]+>', ' ', text)
text = re.sub(r'\s+', ' ', text).strip()
return text
Content verification checklist
Before converting to audio, verify:
- Text length is reasonable for the source (articles typically 1,000-10,000+ words)
- Content includes actual article text, not just navigation/headers
- No "summary" or "key points" headers that indicate truncation
def verify_content(text, expected_min_chars=1000):
"""Basic verification that content is complete."""
if len(text) < expected_min_chars:
print(f"WARNING: Content may be truncated ({len(text)} chars)")
return False
if "summary" in text.lower()[:500] or "key points" in text.lower()[:500]:
print("WARNING: Content appears to be a summary, not full text")
return False
return True
Step 2: Text Processing
Clean and prepare text for TTS
import re
def clean_text_for_tts(text):
"""Clean text for better TTS output."""
# Remove URLs
text = re.sub(r'http[s]?://\S+', '', text)
# Remove footnote markers like [1], [2]
text = re.sub(r'\[\d+\]', '', text)
# Normalize whitespace
text = re.sub(r'\s+', ' ', text)
# Remove special characters that confuse TTS
text = re.sub(r'[^\w\s.,!?;:\'"()-]', '', text)
return text.strip()
def chunk_text(text, max_chars=4000):
"""Split text into chunks at sentence boundaries."""
sentences = re.split(r'(?<=[.!?])\s+', text)
chunks = []
current_chunk = ""
for sentence in sentences:
if len(current_chunk) + len(sentence) < max_chars:
current_chunk += sentence + " "
else:
if current_chunk:
chunks.append(current_chunk.strip())
current_chunk = sentence + " "
if current_chunk:
chunks.append(current_chunk.strip())
return chunks
Step 3: TTS Conversion with Fallback
Automatic provider selection
import os
import subprocess
def create_audiobook(text, output_path):
"""Convert text to audiobook with automatic TTS provider selection."""
# Check available providers
has_elevenlabs = bool(os.environ.get("ELEVENLABS_API_KEY"))
has_openai = bool(os.environ.get("OPENAI_API_KEY"))
if has_elevenlabs:
print("Using ElevenLabs TTS (highest quality)")
return create_with_elevenlabs(text, output_path)
elif has_openai:
print("Using OpenAI TTS (high quality)")
return create_with_openai(text, output_path)
else:
print("Using gTTS (free, no API key required)")
return create_with_gtts(text, output_path)
ElevenLabs implementation
import requests
def create_with_elevenlabs(text, output_path):
"""Generate audiobook using ElevenLabs API."""
api_key = os.environ.get("ELEVENLABS_API_KEY")
voice_id = "21m00Tcm4TlvDq8ikWAM" # Rachel - calm female voice
chunks = chunk_text(text, max_chars=4500)
audio_files = []
for i, chunk in enumerate(chunks):
chunk_file = f"/tmp/chunk_{i:03d}.mp3"
response = requests.post(
f"https://api.elevenlabs.io/v1/text-to-speech/{voice_id}",
headers={
"xi-api-key": api_key,
"Content-Type": "application/json"
},
json={
"text": chunk,
"model_id": "eleven_turbo_v2_5",
"voice_settings": {"stability": 0.5, "similarity_boost": 0.75}
}
)
if response.status_code == 200:
with open(chunk_file, "wb") as f:
f.write(response.content)
audio_files.append(chunk_file)
else:
print(f"Error:
Установить audiobook в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл audiobook?
Create audiobooks from web content or text files. Handles content fetching, text processing, and TTS conversion with automatic fallback between ElevenLabs, OpenAI TTS, and gTTS.
Как установить скилл audiobook?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл audiobook запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic