API ACCESS

Generate API tokens to access TTS Raven programmatically. The same rate limits apply as the web interface.

Your Tokens

Sign in to create and manage your API tokens.

API Reference

Authentication

Pass your token in the Authorization header:

Authorization: Bearer <your_token>

List Voices

GET /api-tokens/api/v1/voices

Returns all voices available to you: preset, your own uploads, and saved community voices.

curl -H "Authorization: Bearer <token>" \
  http://ttsraven.com/api-tokens/api/v1/voices

Generate Speech

POST /api-tokens/api/v1/tts

Streams a WAV audio file. Rate limited to 5 requests/minute.

Form parameters:

Parameter Required Description
text Yes Text to synthesise (max 2500 chars)
voice No Preset voice name (e.g. alba, jean)
voice_sample_id No ID of an uploaded or saved community voice
curl -X POST \
  -H "Authorization: Bearer <token>" \
  -F "text=Hello world" \
  -F "voice=alba" \
  --output speech.wav \
  http://ttsraven.com/api-tokens/api/v1/tts

Code Examples

import requests

API_TOKEN = "<your_token>"
BASE_URL = "http://ttsraven.com/api-tokens/api/v1"
HEADERS = {"Authorization": f"Bearer {API_TOKEN}"}

# List available voices
voices = requests.get(f"{BASE_URL}/voices", headers=HEADERS).json()
print(voices)

# Generate speech and save to file
response = requests.post(
    f"{BASE_URL}/tts",
    headers=HEADERS,
    data={"text": "Hello from Python!", "voice": "alba"},
    stream=True,
)
response.raise_for_status()

with open("speech.wav", "wb") as f:
    for chunk in response.iter_content(chunk_size=8192):
        f.write(chunk)

print("Saved to speech.wav")