Text To Speech

🎤 Generate Speech from Text
Convert your text into speech using our Text-to-Speech API. Submit your text along with the desired language and voice settings, and our API will process your request. After audio generation, the duration of the generated audio will be rounded up and deducted from your account. For example, if the audio length is 10 minutes and 21 seconds, 11 minutes will be deducted.

⚠️ Notice: The text must not exceed 50,000 characters. For longer content, please consider sending multiple requests and merging the generated audio files afterwards.

📋 Request Parameters
The following parameters are required in the JSON body of your POST request:

text (string):
The text to be converted into speech. Maximum allowed length is 50,000 characters.
language (string):
The language code for the speech output (e.g., en-US). You can refer to this array of languages

[
    'af-ZA',    # Afrikaans (South Africa)
    'sq-AL',    # Albanian (Albania)
    'am-ET',    # Amharic (Ethiopia)
    'ar-EG',    # Arabic (Egypt)
    'ar-SA',    # Arabic (Saudi Arabia)
    'hy-AM',    # Armenian (Armenia)
    'az-AZ',    # Azerbaijani (Azerbaijan)
    'eu-ES',    # Basque (Basque)
    'bn-IN',    # Bengali (India)
    'bs-BA',    # Bosnian (Bosnia and Herzegovina)
    'bg-BG',    # Bulgarian (Bulgaria)
    'my-MM',    # Burmese (Myanmar)
    'ca-ES',    # Catalan (Spain)
    'zh-HK',    # Chinese (Cantonese, Traditional)
    'zh-CN',    # Chinese (Mandarin, Simplified)
    'zh-TW',    # Chinese (Taiwanese Mandarin)
    'hr-HR',    # Croatian (Croatia)
    'cs-CZ',    # Czech (Czech)
    'da-DK',    # Danish (Denmark)
    'nl-BE',    # Dutch (Belgium)
    'nl-NL',    # Dutch (Netherlands)
    'en-AU',    # English (Australia)
    'en-CA',    # English (Canada)
    'en-HK',    # English (Hong Kong SAR)
    'en-IN',    # English (India)
    'en-IE',    # English (Ireland)
    'en-GB',    # English (United Kingdom)
    'en-US',    # English (United States)
    'et-EE',    # Estonian (Estonia)
    'fil-PH',   # Filipino (Philippines)
    'fi-FI',    # Finnish (Finland)
    'fr-BE',    # French (Belgium)
    'fr-CA',    # French (Canada)
    'fr-FR',    # French (France)
    'fr-CH',    # French (Switzerland)
    'gl-ES',    # Galician (Galician)
    'ka-GE',    # Georgian (Georgia)
    'de-AT',    # German (Austria)
    'de-DE',    # German (Germany)
    'de-CH',    # German (Switzerland)
    'el-GR',    # Greek (Greece)
    'he-IL',    # Hebrew (Israel)
    'hi-IN',    # Hindi (India)
    'hu-HU',    # Hungarian (Hungary)
    'is-IS',    # Icelandic (Iceland)
    'id-ID',    # Indonesian (Indonesia)
    'ga-IE',    # Irish (Ireland)
    'it-IT',    # Italian (Italy)
    'ja-JP',    # Japanese (Japan)
    'jv-ID',    # Javanese (Indonesia)
    'kn-IN',    # Kannada (India)
    'kk-KZ',    # Kazakh (Kazakhstan)
    'km-KH',    # Khmer (Cambodia)
    'ko-KR',    # Korean (Korea)
    'lo-LA',    # Lao (Laos)
    'lv-LV',    # Latvian (Latvia)
    'lt-LT',    # Lithuanian (Lithuania)
    'mk-MK',    # Macedonian (North Macedonia)
    'ms-MY',    # Malay (Malaysia)
    'ml-IN',    # Malayalam (India)
    'mt-MT',    # Maltese (Malta)
    'mn-MN',    # Mongolian (Mongolia)
    'ne-NP',    # Nepali (Nepal)
    'nb-NO',    # Norwegian (Bokmål, Norway)
    'ps-AF',    # Pashto (Afghanistan)
    'fa-IR',    # Persian (Iran)
    'pl-PL',    # Polish (Poland)
    'pt-BR',    # Portuguese (Brazil)
    'pt-PT',    # Portuguese (Portugal)
    'ro-RO',    # Romanian (Romania)
    'ru-RU',    # Russian (Russia)
    'sr-RS',    # Serbian (Cyrillic, Serbia)
    'si-LK',    # Sinhala (Sri Lanka)
    'sk-SK',    # Slovak (Slovakia)
    'sl-SI',    # Slovenian (Slovenia)
    'so-SO',    # Somali (Somalia)
    'es-MX',    # Spanish (Mexico)
    'es-ES',    # Spanish (Spain)
    'su-ID',    # Sundanese (Indonesia)
    'sw-KE',    # Swahili (Kenya)
    'sv-SE',    # Swedish (Sweden)
    'ta-IN',    # Tamil (India)
    'te-IN',    # Telugu (India)
    'th-TH',    # Thai (Thailand)
    'tr-TR',    # Turkish (Türkiye)
    'uk-UA',    # Ukrainian (Ukraine)
    'ur-PK',    # Urdu (Pakistan)
    'uz-UZ',    # Uzbek (Uzbekistan)
    'vi-VN',    # Vietnamese (Vietnam)
    'cy-GB',    # Welsh (United Kingdom)
    'zu-ZA',    # Zulu (South Africa)
]

voice_name (string):
Specify the desired voice name. You can refer to the following array of speaker names or check the list of speakers at https://app.speaktor.com/ —either within your projects or on the project creation screen. Please note that speaker names may vary based on your dashboard language, as speakers have localized names for each language. You may use the names provided in the following array or the localized names shown on your web app.

["Ravi Ananda", "Laura Mitchell", "Vanessa Morgan", "Jack Wilder", "Emma Reed", "Victor Moreau", "Nathan Drake", "Sophie Lawson", "Julia Bennett", "James Lawson", "Liam Greenwood", "Mark Ellis", "Chloe Harper", "Lily Thompson"]

Additionally, include the Authorization header in your request, formatted as:
Authorization: Bearer <your_api_key>

import json
import requests

# Set your API endpoint and API key
url = "https://api.tor.app/developer/text_to_speech"
api_key = "your_api_key"  # Replace with your actual API key

# Set headers including the API key for authentication
headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {api_key}",
    "Accept": "application/json",
}

# Define your payload with text, language, and the desired voice name
payload = {
    "text": "Your text goes here",
    "language": "en-US",
    "voice_name": "Ravi Ananda"
}

# Send the POST request to the text-to-speech API endpoint
response = requests.post(url, json=payload, headers=headers)

# Print the status code and the complete JSON response
print("Status Code:", response.status_code)
response_json = response.json()
print("Response JSON:", response_json)

# Extract and print the audio URL from the response
if "audioUrl" in response_json:
    audio_url = response_json["audioUrl"]
    print("Audio URL:", audio_url)
else:
    print("Error: 'audioUrl' not found in the response.")
const axios = require('axios');

// Set your API endpoint and API key
const url = "https://api.tor.app/developer/text_to_speech";
const apiKey = "your_api_key"; // Replace with your actual API key

// Set headers including the API key for authentication
const headers = {
  "Content-Type": "application/json",
  "Authorization": `Bearer ${apiKey}`,
  "Accept": "application/json",
};

// Define your payload with text, language, and the desired voice name
const payload = {
  text: "Your text goes here",
  language: "en-US",
  voice_name: "Ravi Ananda"
};

// Send the POST request to the text-to-speech API endpoint
axios.post(url, payload, { headers })
  .then(response => {
    console.log("Status Code:", response.status);
    console.log("Response JSON:", response.data);

    // Extract and print the audio URL from the response
    if (response.data.audioUrl) {
      console.log("Audio URL:", response.data.audioUrl);
    } else {
      console.log("Error: 'audioUrl' not found in the response.");
    }
  })
  .catch(error => {
    console.error("Error making request:", error);
  });