Tooluck logoTooluck
SKILL.md

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)

tasks-extra/pg-essay-to-audiobook/environment/skills/gtts/SKILL.md

Apache-2.0Full file
1# Google Text-to-Speech (gTTS)
2
3gTTS 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.
4
5## Installation
6
7```bash
8pip install gtts pydub
9```
10
11pydub is useful for manipulating and concatenating audio files.
12
13## Basic Usage
14
15```python
16from gtts import gTTS
17
18# Create speech
19tts = gTTS(text="Hello, world!", lang='en')
20
21# Save to file
22tts.save("output.mp3")
23```
24
25## Language Options
26
27```python
28# US English (default)
29tts = gTTS(text="Hello", lang='en')
30
31# British English
32tts = gTTS(text="Hello", lang='en', tld='co.uk')
33
34# Slow speech
35tts = gTTS(text="Hello", lang='en', slow=True)
36```
37
38## Python Example for Long Text
39
40```python
41from gtts import gTTS
42from pydub import AudioSegment
43import tempfile
44import os
45import re
46
47def 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 = ""
52
53 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 + " "
60
61 if current_chunk:
62 chunks.append(current_chunk.strip())
63
64 return chunks
65
66
67def 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.

More skills in skillsbench

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates