# Send openai-tts-python to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- Download the package from Yavira.
- Extract it into a folder your agent can access.
- Paste one of the prompts below and point your agent at the extracted folder.
## Suggested prompts
### New install

```text
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete.
```
### Upgrade existing

```text
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run.
```
## Machine-readable fields
```json
{
  "schemaVersion": "1.0",
  "item": {
    "slug": "openai-tts-python",
    "name": "openai-tts-python",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/merend/openai-tts-python",
    "canonicalUrl": "https://clawhub.ai/merend/openai-tts-python",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadUrl": "/downloads/openai-tts-python",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=openai-tts-python",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "README.md",
      "skill.md",
      "openai_tts.py",
      "manifest.json"
    ],
    "downloadMode": "redirect",
    "sourceHealth": {
      "source": "tencent",
      "slug": "openai-tts-python",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-05-12T09:54:01.943Z",
      "expiresAt": "2026-05-19T09:54:01.943Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=openai-tts-python",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=openai-tts-python",
        "contentDisposition": "attachment; filename=\"openai-tts-python-1.0.1.zip\"",
        "redirectLocation": null,
        "bodySnippet": null,
        "slug": "openai-tts-python"
      },
      "scope": "item",
      "summary": "Item download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this item.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/openai-tts-python"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    }
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/openai-tts-python",
    "downloadUrl": "https://openagent3.xyz/downloads/openai-tts-python",
    "agentUrl": "https://openagent3.xyz/skills/openai-tts-python/agent",
    "manifestUrl": "https://openagent3.xyz/skills/openai-tts-python/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/openai-tts-python/agent.md"
  }
}
```
## Documentation

### OpenAI TTS

Text-to-speech conversion using OpenAI's TTS API for generating high-quality, natural-sounding audio from text.

### Features

6 different voice options (male/female)
Standard and HD quality models
Automatic text chunking for long content (4096 char limit)
Multiple output formats (mp3, opus, aac, flac)

### Activation

This skill activates when the user:

Requests audio/voice output: "read this to me", "convert to audio", "generate speech", "make this an audio file"
Uses keywords: "tts", "openai tts", "text to speech", "voice", "audio", "podcast"
Needs content spoken for accessibility, multitasking, or podcast creation
Specifies voice preferences: "alloy", "echo", "fable", "onyx", "nova", "shimmer"
Asks to "narrate", "speak", or "vocalize" text

### Requirements

OPENAI_API_KEY environment variable must be set
Python 3.8+
Dependencies: openai, pydub (optional, for long text)

### Voices

VoiceTypeDescriptionalloyNeutralBalanced, versatileechoMaleWarm, conversationalfableNeutralExpressive, storytellingonyxMaleDeep, authoritativenovaFemaleFriendly, upbeatshimmerFemaleClear, professional

### Basic Usage

from openai import OpenAI
import os

client = OpenAI(api_key=os.getenv('OPENAI_API_KEY'))

response = client.audio.speech.create(
    model="tts-1",      # or "tts-1-hd" for higher quality
    voice="onyx",       # choose from: alloy, echo, fable, onyx, nova, shimmer
    input="Your text here",
    speed=1.0           # 0.25 to 4.0 (optional)
)

with open("output.mp3", "wb") as f:
    for chunk in response.iter_bytes():
        f.write(chunk)

### Command Line

# Basic
python -c "
from openai import OpenAI
client = OpenAI()
response = client.audio.speech.create(model='tts-1', voice='onyx', input='Hello world')
open('output.mp3', 'wb').write(response.content)
"

### Long Text (Auto-chunking)

from openai import OpenAI
from pydub import AudioSegment
import tempfile
import os
import re

client = OpenAI()
MAX_CHARS = 4096

def split_text(text):
    if len(text) <= MAX_CHARS:
        return [text]

    chunks = []
    sentences = re.split(r'(?<=[.!?])\\s+', text)
    current = ''

    for sentence in sentences:
        if len(current) + len(sentence) + 1 <= MAX_CHARS:
            current += (' ' if current else '') + sentence
        else:
            if current:
                chunks.append(current)
            current = sentence

    if current:
        chunks.append(current)

    return chunks

def generate_tts(text, output_path, voice='onyx', model='tts-1'):
    chunks = split_text(text)

    if len(chunks) == 1:
        response = client.audio.speech.create(model=model, voice=voice, input=text)
        with open(output_path, 'wb') as f:
            f.write(response.content)
    else:
        segments = []
        for chunk in chunks:
            response = client.audio.speech.create(model=model, voice=voice, input=chunk)
            with tempfile.NamedTemporaryFile(suffix='.mp3', delete=False) as tmp:
                tmp.write(response.content)
                segments.append(AudioSegment.from_mp3(tmp.name))
                os.unlink(tmp.name)

        combined = segments[0]
        for seg in segments[1:]:
            combined += seg
        combined.export(output_path, format='mp3')

    return output_path

# Usage
generate_tts("Your long text here...", "output.mp3", voice="nova")

### Models

ModelQualitySpeedCosttts-1StandardFast$0.015/1K charstts-1-hdHigh DefinitionSlower$0.030/1K chars

### Output Formats

Supported formats: mp3 (default), opus, aac, flac

response = client.audio.speech.create(
    model="tts-1",
    voice="onyx",
    input="Hello",
    response_format="opus"  # or mp3, aac, flac
)

### Error Handling

from openai import OpenAI, APIError, RateLimitError
import time

client = OpenAI()

def generate_with_retry(text, voice='onyx', max_retries=3):
    for attempt in range(max_retries):
        try:
            response = client.audio.speech.create(
                model="tts-1",
                voice=voice,
                input=text
            )
            return response.content
        except RateLimitError:
            if attempt < max_retries - 1:
                time.sleep(2 ** attempt)  # Exponential backoff
                continue
            raise
        except APIError as e:
            print(f"API Error: {e}")
            raise

    return None

### Convert Article to Podcast

def article_to_podcast(article_text, output_file):
    intro = "Welcome to today's article reading."
    outro = "Thank you for listening."

    full_text = f"{intro}\\n\\n{article_text}\\n\\n{outro}"

    generate_tts(full_text, output_file, voice='nova', model='tts-1-hd')
    print(f"Podcast saved to {output_file}")

### Batch Processing

def batch_tts(texts, output_dir, voice='onyx'):
    import os
    os.makedirs(output_dir, exist_ok=True)

    for i, text in enumerate(texts):
        output_path = os.path.join(output_dir, f"audio_{i+1}.mp3")
        generate_tts(text, output_path, voice=voice)
        print(f"Generated: {output_path}")

### Links

OpenAI TTS Documentation
OpenAI API Reference
Pricing
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: merend
- Version: 1.0.1
## Source health
- Status: healthy
- Item download looks usable.
- Yavira can redirect you to the upstream package for this item.
- Health scope: item
- Reason: direct_download_ok
- Checked at: 2026-05-12T09:54:01.943Z
- Expires at: 2026-05-19T09:54:01.943Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/openai-tts-python)
- [Send to Agent page](https://openagent3.xyz/skills/openai-tts-python/agent)
- [JSON manifest](https://openagent3.xyz/skills/openai-tts-python/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/openai-tts-python/agent.md)
- [Download page](https://openagent3.xyz/downloads/openai-tts-python)