Metadata-Version: 2.4
Name: rapidapi-tts
Version: 1.1.0
Summary: Python wrapper for the Text-to-Speech API — convert text to speech with 400+ voices, word-level timestamps, adjustable speed and pitch.
Author-email: Text-to-Speech API <contact@tts-api.com>
License-Expression: MIT
Project-URL: Homepage, https://rapidapi.com/louismichalot/api/text-to-speech-api
Project-URL: Repository, https://github.com/DarkPancakes/rapidapi-collections
Keywords: text-to-speech,tts,speech synthesis,voice,audio,mp3,timestamps,api wrapper
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# Text-to-Speech API — Python SDK

Official Python wrapper for the [Text-to-Speech API](https://rapidapi.com/louismichalot/api/text-to-speech-api) on RapidAPI.

Convert text to natural-sounding speech with **400+ voices** in **100+ languages**, word-level timestamps, adjustable speed and pitch.

## Install

```bash
pip install text-to-speech-api
```

## Quick Start

```python
from tts_api import TTSAPI

api = TTSAPI("YOUR_RAPIDAPI_KEY")

# Generate speech
audio = api.tts("Hello, world!")
with open("hello.mp3", "wb") as f:
    f.write(audio)

# List French voices
result = api.voices("fr")
for v in result["voices"]:
    print(v["name"], v["friendly_name"])
```

## API

### `TTSAPI(api_key, base_url=None, timeout=30)`

### `api.health()` — Health Check

```python
status = api.health()
# {'status': 'ok', 'voices_count': 322, 'version': '1.0.0'}
```

### `api.voices(language=None)` — List Voices

```python
# All voices
all_voices = api.voices()

# Spanish voices only
spanish = api.voices("es")
```

### `api.tts(text, *, voice, rate, pitch, format)` — Text to Speech

Returns audio as `bytes`. Free tier.

```python
audio = api.tts(
    "Breaking news from around the world.",
    voice="en-US-GuyNeural",
    rate="+20%",
    format="mp3",
)
with open("news.mp3", "wb") as f:
    f.write(audio)
```

### `api.tts_with_timestamps(text, *, voice, rate, pitch, format)` — TTS + Timestamps

Returns audio as base64 + word-level timing. Basic tier.

```python
result = api.tts_with_timestamps("Five amazing facts about space.")
for word in result["timestamps"]:
    print(f"{word['text']} at {word['offset_ms']}ms")

# Decode audio
audio = api.decode_audio(result["audio_base64"])
with open("space.mp3", "wb") as f:
    f.write(audio)
```

## Pricing

| Tier | Price | Requests/day | Max chars |
|------|-------|-------------|-----------|
| Free | $0 | 50 | 1,000 |
| Basic | $3/mo | 500 | 5,000 |
| Pro | $9/mo | 5,000 | 10,000 |

## Requirements

- Python 3.8+
- Zero dependencies (uses only stdlib)

## License

MIT
