Basic Text-to-Speech
curl --request POST \
--url https://api.example.com/tts \
--header 'Content-Type: application/json' \
--data '
{
"text": "<string>",
"language": "<string>",
"voice_name": "<string>",
"speed": 123,
"pitch": 123,
"volume_gain_db": 123,
"api_key": "<string>"
}
'import requests
url = "https://api.example.com/tts"
payload = {
"text": "<string>",
"language": "<string>",
"voice_name": "<string>",
"speed": 123,
"pitch": 123,
"volume_gain_db": 123,
"api_key": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
text: '<string>',
language: '<string>',
voice_name: '<string>',
speed: 123,
pitch: 123,
volume_gain_db: 123,
api_key: '<string>'
})
};
fetch('https://api.example.com/tts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/tts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => '<string>',
'language' => '<string>',
'voice_name' => '<string>',
'speed' => 123,
'pitch' => 123,
'volume_gain_db' => 123,
'api_key' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/tts"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"language\": \"<string>\",\n \"voice_name\": \"<string>\",\n \"speed\": 123,\n \"pitch\": 123,\n \"volume_gain_db\": 123,\n \"api_key\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/tts")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"language\": \"<string>\",\n \"voice_name\": \"<string>\",\n \"speed\": 123,\n \"pitch\": 123,\n \"volume_gain_db\": 123,\n \"api_key\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/tts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"language\": \"<string>\",\n \"voice_name\": \"<string>\",\n \"speed\": 123,\n \"pitch\": 123,\n \"volume_gain_db\": 123,\n \"api_key\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyText-to-Speech
Basic Text-to-Speech
Convert text to speech
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>",
"voice_name": "<string>",
"speed": 123,
"pitch": 123,
"volume_gain_db": 123,
"api_key": "<string>"
}
'import requests
url = "https://api.example.com/tts"
payload = {
"text": "<string>",
"language": "<string>",
"voice_name": "<string>",
"speed": 123,
"pitch": 123,
"volume_gain_db": 123,
"api_key": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
text: '<string>',
language: '<string>',
voice_name: '<string>',
speed: 123,
pitch: 123,
volume_gain_db: 123,
api_key: '<string>'
})
};
fetch('https://api.example.com/tts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/tts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => '<string>',
'language' => '<string>',
'voice_name' => '<string>',
'speed' => 123,
'pitch' => 123,
'volume_gain_db' => 123,
'api_key' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/tts"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"language\": \"<string>\",\n \"voice_name\": \"<string>\",\n \"speed\": 123,\n \"pitch\": 123,\n \"volume_gain_db\": 123,\n \"api_key\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/tts")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"language\": \"<string>\",\n \"voice_name\": \"<string>\",\n \"speed\": 123,\n \"pitch\": 123,\n \"volume_gain_db\": 123,\n \"api_key\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/tts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"language\": \"<string>\",\n \"voice_name\": \"<string>\",\n \"speed\": 123,\n \"pitch\": 123,\n \"volume_gain_db\": 123,\n \"api_key\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyOverview
Generate high-quality speech from text using the default voice. This is the simplest way to convert text to speech.Request Body
string
required
The text to convert to speech
string
default:"en"
Language code (e.g., “en”, “es”, “fr”). See supported languages
string
Optional voice name — either a KittenTTS voice (
Bella, Jasper, Luna, Bruno, Rosie, Hugo, Kiki, Leo) or a Google Cloud voice (e.g. en-US-Wavenet-D). The name selects the engine. Use GET /tts/voices to discover available voices.number
default:"1.0"
Speaking rate. Values < 1.0 slow down the voice, values > 1.0 make it faster.
number
default:"0.0"
Pitch adjustment in semitones. Positive values raise the pitch, negative values lower it.
number
default:"0.0"
Volume gain in decibels. Range is typically between -96.0 and +16.0.
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",
"voice_name": "en-US-Wavenet-D",
"speed": 1.0,
"pitch": 0.0,
"volume_gain_db": 0.0,
"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
Credit Cost
1 credit per 1,000 characters, with a minimum of 1 credit for any request.Examples:
- 10 characters = 1 credit (minimum charge)
- 500 characters = 1 credit (minimum charge)
- 999 characters = 1 credit (minimum charge)
- 1,000 characters = 1 credit
- 1,001 characters = 2 credits (rounded up)
- 2,500 characters = 3 credits (rounded up)
- 5,000 characters = 5 credits
Example Usage
Python
import requests
response = requests.post(
"https://api.gistmag.co.uk/tts",
json={
"text": "Hello, this is a test.",
"language": "en",
"voice_name": "en-US-Wavenet-D",
"speed": 1.0,
"pitch": 0.0,
"volume_gain_db": 0.0,
"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',
voice_name: 'en-US-Wavenet-D',
speed: 1.0,
pitch: 0.0,
volume_gain_db: 0.0,
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.