gtts
Agent skill frombenchflow-ai/skillsbench
Google Text-to-Speech (gTTS) for converting text to audio. Use when creating audiobooks, podcasts, or speech synthesis from text. Handles long text by chunking at sentence boundaries and concatenating audio segments with pydub.
How to install gtts
install gtts
# install the skillsbench pack with the skills CLI
npx skills add benchflow-ai/skillsbench# or add only this skill to Claude Code: copy the folder
tasks-extra/pg-essay-to-audiobook/environment/skills/gtts/
# into
~/.claude/skills/gtts/ (all projects)
.claude/skills/gtts/ (one project)
1# Google Text-to-Speech (gTTS)23gTTS is a Python library that converts text to speech using Google's Text-to-Speech API. It's free to use and doesn't require an API key.45## Installation67```bash8pip install gtts pydub9```1011pydub is useful for manipulating and concatenating audio files.1213## Basic Usage1415```python16from gtts import gTTS1718# Create speech19tts = gTTS(text="Hello, world!", lang='en')2021# Save to file22tts.save("output.mp3")23```2425## Language Options2627```python28# US English (default)29tts = gTTS(text="Hello", lang='en')3031# British English32tts = gTTS(text="Hello", lang='en', tld='co.uk')3334# Slow speech35tts = gTTS(text="Hello", lang='en', slow=True)36```3738## Python Example for Long Text3940```python41from gtts import gTTS42from pydub import AudioSegment43import tempfile44import os45import re4647def chunk_text(text, max_chars=4500):48 """Split text into chunks at sentence boundaries."""49 sentences = re.split(r'(?<=[.!?])\s+', text)50 chunks = []51 current_chunk = ""5253 for sentence in sentences:54 if len(current_chunk) + len(sentence) < max_chars:55 current_chunk += sentence + " "56 else:57 if current_chunk:58 chunks.append(current_chunk.strip())59 current_chunk = sentence + " "6061 if current_chunk:62 chunks.append(current_chunk.strip())6364 return chunks656667def text_to_audiobook(text, output_path):68 """Convert long text to a single audio file."""69 chunks = chunk_text(text)70 audio_segments = []71…
Excerpt shown under the repository's Apache-2.0 license.
