Skip to main content
POST
/
tts
Basic Text-to-Speech
curl --request POST \
  --url https://api.example.com/tts \
  --header 'Content-Type: application/json' \
  --data '
{
  "text": "<string>",
  "language": "<string>",
  "api_key": "<string>"
}
'

Overview

Generate high-quality speech from text using the default voice. This is the simplest way to convert text to speech.

Request Body

text
string
required
The text to convert to speech
language
string
default:"en"
Language code (e.g., “en”, “es”, “fr”). See supported languages
api_key
string
required
Your GistMag API key

Example Request

curl -X POST https://api.gistmag.co.uk/tts \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello, this is a test of the text-to-speech API.",
    "language": "en",
    "api_key": "your_api_key_here"
  }' \
  --output output.wav

Response

The response is an audio file (WAV format) with the generated speech. Content-Type: audio/wav Content-Disposition: attachment; filename=output.wav

Example Usage

Python

import requests

response = requests.post(
        "https://api.gistmag.co.uk/tts",
    json={
        "text": "Hello, this is a test.",
        "language": "en",
        "api_key": "your_api_key_here"
    }
)

with open("output.wav", "wb") as f:
    f.write(response.content)

JavaScript

const response = await fetch('https://api.gistmag.co.uk/tts', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    text: 'Hello, this is a test.',
    language: 'en',
    api_key: 'your_api_key_here'
  })
});

const audioBlob = await response.blob();
const audioUrl = URL.createObjectURL(audioBlob);
// Play the audio or download it

Text Length Limits

  • Maximum: 10,000 characters per request
  • Recommended: For longer text, use the batch endpoint
For very long text, consider using the batch endpoint which automatically splits text into manageable chunks.