API Reference

API Reference

Complete documentation for all YourVoic API endpoints with request/response examples.

Base URL: https://yourvoic.com/api/v1
All requests require authentication via X-API-Key header.

Endpoints Overview #

Method Endpoint Description
POST /api/v1/tts/generate Generate speech from text
POST /api/v1/tts/stream Stream speech in real-time NEW
GET /api/v1/voices List available voices
GET /api/api/v1/languages List supported languages
GET /api/v1/models List available models
GET /api/v1/usage Get usage statistics
GET /health Health check

POST /api/v1/tts/generate #

Convert text to natural-sounding speech. This is the primary endpoint for generating audio.

Request Body

Parameter Type Required Description
text string ✅ Text to convert (max 5000 chars)
voice string ✅ Voice name (e.g., "Peter", "Deepika")
model string ❌ TTS model (default: "aura-prime")
language string ❌ Language code (default: "en-US")
speed number ❌ Speech speed 0.5-2.0 (default: 1.0)
pitch number ❌ Pitch adjustment -20 to +20
format string ❌ wav, mp3, ogg, flac (default: "wav")

Example Request

cURL
curl -X POST "https://yourvoic.com/api/v1/tts/generate" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello, welcome to YourVoic!",
    "voice": "Peter",
    "model": "aura-prime",
    "language": "en-US",
    "speed": 1.0
  }'

Response

Direct Audio Response: The API returns audio file bytes directly in the response body (Content-Type: audio/wav). No JSON, no URLs - just pure audio ready to save or stream.
Response Headers
HTTP/1.1 200 OK
Content-Type: audio/wav
Content-Disposition: attachment; filename=tts_1763016758696.wav
Content-Length: 48532
X-Request-ID: tts_1763016758696
X-Processing-Time-Ms: 2850
Save Audio (Python)
response = requests.post(...)
with open("output.wav", "wb") as f:
    f.write(response.content)
Save Audio (Node.js)
const fs = require('fs');
const response = await fetch(...);
const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync('output.wav', buffer);
Play Audio (Browser JavaScript)
const response = await fetch(...);
const blob = await response.blob();
const audioUrl = URL.createObjectURL(blob);
const audio = new Audio(audioUrl);
audio.play();

POST /api/v1/tts/stream NEW #

Stream audio in real-time with low latency. Audio chunks are sent as they become available, enabling instant playback without waiting for full generation.

~40ms First Byte Latency - Audio starts playing almost instantly, ideal for real-time applications like voice assistants and live chat.

Request Body

Parameter Type Required Description
text string ✅ Text to synthesize (max 50,000 chars)
voice string ✅ Voice ID (e.g., "Peter", "Zara")
language string ❌ Language code. Default: en-US
model string ❌ Model: aura-lite, aura-prime, aura-max, rapid-max. Default: aura-prime
sample_rate integer ❌ Audio sample rate in Hz. Default: 24000
Note: rapid-flash does NOT support streaming. Only aura-* models and rapid-max support streaming.

Response

Returns a chunked transfer-encoded stream of raw PCM audio data.

Header Value Description
Content-Type audio/pcm Raw PCM audio format
X-Sample-Rate 24000 Audio sample rate in Hz
X-Bits-Per-Sample 16 16-bit audio
X-Channels 1 Mono audio
X-Audio-Format pcm Raw PCM (little-endian)
Transfer-Encoding chunked Streamed response

Examples

cURL - Save to File
curl -X POST "https://yourvoic.com/api/v1/tts/stream" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello, this is streaming audio!",
    "voice": "Peter",
    "model": "aura-prime"
  }' \
  --output audio.pcm

# Convert PCM to WAV for playback
ffmpeg -f s16le -ar 24000 -ac 1 -i audio.pcm audio.wav
Python - Stream to File
import requests

response = requests.post(
    "https://yourvoic.com/api/v1/tts/stream",
    headers={
        "X-API-Key": "YOUR_API_KEY",
        "Content-Type": "application/json"
    },
    json={
        "text": "Hello, streaming world!",
        "voice": "Peter",
        "model": "aura-prime"
    },
    stream=True
)

# Save raw PCM
with open("audio.pcm", "wb") as f:
    for chunk in response.iter_content(chunk_size=1024):
        f.write(chunk)

# Or use pydub to convert and play
from pydub import AudioSegment
audio = AudioSegment.from_raw(
    "audio.pcm", 
    sample_width=2, 
    frame_rate=24000, 
    channels=1
)
audio.export("audio.wav", format="wav")
JavaScript - Real-time Playback
async function streamAndPlay(text) {
  const response = await fetch("https://yourvoic.com/api/v1/tts/stream", {
    method: "POST",
    headers: {
      "X-API-Key": "YOUR_API_KEY",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      text: text,
      voice: "Peter",
      model: "aura-prime"
    })
  });

  // Create AudioContext for real-time playback
  const audioContext = new AudioContext({ sampleRate: 24000 });
  const reader = response.body.getReader();
  
  while (true) {
    const { done, value } = await reader.read();
    if (done) break;
    
    // Convert PCM bytes to audio buffer
    const int16Array = new Int16Array(value.buffer);
    const float32Array = new Float32Array(int16Array.length);
    for (let i = 0; i < int16Array.length; i++) {
      float32Array[i] = int16Array[i] / 32768;
    }
    
    // Play the chunk
    const audioBuffer = audioContext.createBuffer(1, float32Array.length, 24000);
    audioBuffer.getChannelData(0).set(float32Array);
    const source = audioContext.createBufferSource();
    source.buffer = audioBuffer;
    source.connect(audioContext.destination);
    source.start();
  }
}
Node.js - Stream to File
const fs = require('fs');

async function streamTTS() {
  const response = await fetch("https://yourvoic.com/api/v1/tts/stream", {
    method: "POST",
    headers: {
      "X-API-Key": "YOUR_API_KEY",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      text: "Hello from Node.js streaming!",
      voice: "Peter",
      model: "rapid-max"  // Premium HD quality
    })
  });

  const fileStream = fs.createWriteStream("audio.pcm");
  const reader = response.body.getReader();
  
  while (true) {
    const { done, value } = await reader.read();
    if (done) break;
    fileStream.write(Buffer.from(value));
  }
  
  fileStream.end();
  console.log("Audio saved to audio.pcm");
}

GET /api/v1/voices #

Get all available voices, optionally filtered by language.

Query Parameters

Parameter Type Description
language string Filter by language code (e.g., "en-US", "hi-IN")

Example

cURL
curl "https://yourvoic.com/api/v1/voices?language=en-US" \
  -H "X-API-Key: YOUR_API_KEY"
Response
{
  "voices": [
    {
      "voice_id": "peter",
      "name": "Peter",
      "gender": "male",
      "language": "en-US",
      "preview_url": "https://yourvoic.com/voices/peter.mp3"
    },
    {
      "voice_id": "kylie",
      "name": "Kylie",
      "gender": "female",
      "language": "en-US",
      "preview_url": "https://yourvoic.com/voices/kylie.mp3"
    }
  ],
  "total": 2
}

GET /api/v1/languages #

Get all supported languages, optionally filtered by TTS model. Different models support different language sets.

Query Parameters

Parameter Type Description
model string Filter by TTS model. Options: aura-lite, aura-prime, aura-max, rapid-flash, rapid-max
Model Language Support:
• aura-* models: 90+ languages (full coverage)
• rapid-max: 41 languages (studio-quality)
• rapid-flash: 18 languages (ultra-fast)

Example Requests

All Languages
curl "https://yourvoic.com/api/v1/languages" \
  -H "X-API-Key: YOUR_API_KEY"
Filtered by Model (Rapid-Max)
curl "https://yourvoic.com/api/v1/languages?model=rapid-max" \
  -H "X-API-Key: YOUR_API_KEY"
Example Response
{
  "success": true,
  "languages": [
    {"code": "en-US", "name": "English (US)", "region": "Global"},
    {"code": "hi-IN", "name": "Hindi", "region": "India"},
    {"code": "es-ES", "name": "Spanish", "region": "Europe"},
    {"code": "fr-FR", "name": "French", "region": "Europe"},
    {"code": "ar-XA", "name": "Arabic", "region": "Middle East"}
  ],
  "total": 41,
  "model": "rapid-max"
}

GET /api/v1/models #

Get all available TTS models with their capabilities and supported language counts.

Response
{
  "models": [
    {
      "id": "aura-lite",
      "name": "Aura Lite",
      "description": "Fast and efficient TTS for basic use cases",
      "languages": 74,
      "plans": ["free", "basic", "pro", "enterprise"]
    },
    {
      "id": "aura-prime",
      "name": "Aura Prime",
      "description": "High-quality general purpose TTS",
      "languages": 74,
      "plans": ["free", "basic", "pro", "enterprise"]
    },
    {
      "id": "aura-max",
      "name": "Aura Max",
      "description": "Premium quality with expression tags",
      "languages": 74,
      "plans": ["pro", "enterprise"]
    },
    {
      "id": "rapid-flash",
      "name": "Rapid Flash",
      "description": "Ultra-fast voices for low latency",
      "languages": 18,
      "plans": ["basic", "pro", "enterprise"]
    },
    {
      "id": "rapid-max",
      "name": "Rapid Max",
      "description": "Studio-quality premium voices",
      "languages": 41,
      "plans": ["pro", "enterprise"]
    }
  ]
}

GET /api/v1/usage #

Get your API usage statistics including characters used, requests made, and quota remaining.

Response
{
  "plan": "basic",
  "period": {
    "start": "2025-11-01T00:00:00Z",
    "end": "2025-11-30T23:59:59Z"
  },
  "usage": {
    "characters_used": 125000,
    "characters_limit": 500000,
    "characters_remaining": 375000,
    "requests_today": 45,
    "requests_this_month": 1250
  },
  "rate_limits": {
    "requests_per_minute": 50,
    "requests_per_hour": 1000
  }
}

GET /health #

Check if the API is operational. No authentication required.

Response
{
  "status": "healthy",
  "version": "1.0.0",
  "timestamp": "2025-11-27T10:30:00Z"
}

Error Codes #

Common HTTP status codes returned by the API:

Code Description
200 Success
400 Bad request - invalid parameters
401 Unauthorized - invalid or missing API key
403 Forbidden - model not in your plan
429 Rate limit exceeded
500 Internal server error

See Error Handling for detailed error responses.