API Documentation

Integrate DubVoice.ai text-to-speech capabilities into your applications with our REST API.

Quick Start

Get started with a simple API request:

curl -X POST "https://dubvoice.ai/api/v1/tts" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello, welcome to DubVoice!",
    "voice_id": "sarah",
    "language": "en"
  }'

Authentication

All API requests require authentication using an API key. You can obtain your API key from your dashboard.

Important: Keep your API key secure. Never expose it in client-side code or public repositories.

Include your API key in the request header:

Authorization: Bearer YOUR_API_KEY

API Endpoints

POST/api/v1/tts

Convert text to speech audio.

Request Body

ParameterTypeRequiredDescription
textstringYesThe text to convert to speech (max 5000 characters)
voice_idstringYesThe ID of the voice to use
languagestringNoLanguage code (e.g., "en", "es", "tr")
speednumberNoSpeech speed (0.5 - 2.0, default: 1.0)
formatstringNoOutput format: "mp3" or "wav" (default: "mp3")

Response

Returns audio file as binary stream with appropriate Content-Type header.

HTTP/1.1 200 OK
Content-Type: audio/mpeg
Content-Disposition: attachment; filename="tts_output.mp3"

[Binary audio data]
GET/api/v1/voices

Get a list of available voices.

Response

{
  "voices": [
    {
      "id": "sarah",
      "name": "Sarah",
      "language": "en",
      "gender": "female",
      "preview_url": "https://dubvoice.ai/samples/sarah.mp3"
    },
    {
      "id": "james",
      "name": "James",
      "language": "en",
      "gender": "male",
      "preview_url": "https://dubvoice.ai/samples/james.mp3"
    }
  ]
}
GET/api/v1/user

Get current user information and credit balance.

Response

{
  "user": {
    "id": "usr_123456",
    "email": "user@example.com",
    "credits": 50000,
    "plan": "pro"
  }
}

Supported Languages

en

English

es

Spanish

fr

French

de

German

it

Italian

pt

Portuguese

tr

Turkish

ru

Russian

ja

Japanese

ko

Korean

zh

Chinese

ar

Arabic

hi

Hindi

pl

Polish

nl

Dutch

sv

Swedish

And 15+ more languages available. Check the voices endpoint for full list.

Error Codes

CodeStatusDescription
400Bad RequestInvalid request parameters
401UnauthorizedInvalid or missing API key
402Payment RequiredInsufficient credits
429Too Many RequestsRate limit exceeded
500Server ErrorInternal server error

Code Examples

JavaScript / Node.js

const response = await fetch('https://dubvoice.ai/api/v1/tts', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    text: 'Hello, welcome to DubVoice!',
    voice_id: 'sarah',
    language: 'en',
  }),
});

const audioBlob = await response.blob();
const audioUrl = URL.createObjectURL(audioBlob);
const audio = new Audio(audioUrl);
audio.play();

Python

import requests

response = requests.post(
    'https://dubvoice.ai/api/v1/tts',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json',
    },
    json={
        'text': 'Hello, welcome to DubVoice!',
        'voice_id': 'sarah',
        'language': 'en',
    }
)

with open('output.mp3', 'wb') as f:
    f.write(response.content)

cURL

curl -X POST "https://dubvoice.ai/api/v1/tts" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello, welcome to DubVoice!", "voice_id": "sarah", "language": "en"}' \
  --output output.mp3

Rate Limits

PlanRequests/minConcurrent Requests
Free102
Pro605
EnterpriseUnlimitedCustom

Ready to Get Started?

Create a free account to get your API key and start building with DubVoice.ai.