Skip to main content

Python wrapper for the Text-to-Speech API — convert text to speech with 400+ voices, word-level timestamps, adjustable speed and pitch.

Project description

Text-to-Speech API — Python SDK

Official Python wrapper for the 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

pip install text-to-speech-api

Quick Start

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

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

api.voices(language=None) — List Voices

# 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.

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.

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rapidapi_tts-1.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rapidapi_tts-1.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file rapidapi_tts-1.1.0.tar.gz.

File metadata

  • Download URL: rapidapi_tts-1.1.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for rapidapi_tts-1.1.0.tar.gz
Algorithm Hash digest
SHA256 5f9645a734b5e5e6859b91395d63c38af86fe78c1dd9340d068efc7cf48511c8
MD5 1a4343ab0f9256fd3ae6e9ed0dd44442
BLAKE2b-256 64089d96dee1111d2c6397b0836d6b3d9997972f4857635b2ca30f16124a96f3

See more details on using hashes here.

File details

Details for the file rapidapi_tts-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: rapidapi_tts-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for rapidapi_tts-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d57b057165e8f302488105ecaa54418726aa4a6a827a483c6ee6fd3941c47f85
MD5 161597e1b210d95377a0b863dae79474
BLAKE2b-256 479c82c8132bc68993c1a6181eefaceef32240ebd5f1111456ef3fb058ad08cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page