Skip to navigation

Getting started with Bakbak TTS

Quick start guide for Bakbak TTS API
View as Markdown

This guide will help you get up and running with Bakbak TTS API in minutes.

Prerequisites

  • An API key (contact your administrator)
  • HTTP client (cURL, Postman, or your preferred tool)
  • Basic understanding of REST APIs

Step 1: List Available Voices

First, discover which voices are available for your use case:

curl https://hub.getraya.app/v1/voices \
-H "X-API-Key: <YOUR_API_KEY>"

Each voice is tied to a specific model (standard or m1). When you generate speech, pass the matching model value — standard voices do not work with "model": "m1", and m1 voices do not work with "model": "standard".

Response:

{
"voices": [
{
"id": "voice_001",
"name": "Hindi Female Voice",
"language": "hi",
"model": "standard"
},
{
"id": "voice_002",
"name": "Marathi Male Voice",
"language": "mr",
"model": "m1"
}
],
"count": 2
}

Step 2: Generate Speech (Non-Streaming)

Generate a complete audio file:

curl -X POST https://hub.getraya.app/v1/text-to-speech \
-H "X-API-Key: <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"text": "नमस्ते! मैं आपकी कैसे मदद कर सकता हूँ?",
"voice_id": "voice_001",
"model": "standard",
"language": "hi",
"output_format": {"container": "wav", "encoding": "pcm_s16le", "sample_rate": 24000},
"speed": 1.0
}'

The Hindi example above uses Devanagari script, which is required for language: "hi". Romanized Hindi (for example, namaste) is not supported. See Best Practices for tips on Indic named entities in English text.

The response will be a binary audio file. Save it to a file:

curl -X POST https://hub.getraya.app/v1/text-to-speech \
-H "X-API-Key: <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{"text": "Hello", "voice_id": "voice_001", "language": "hi", "output_format": {"container": "wav", "encoding": "pcm_s16le"}}' \
--output audio.wav

Step 3: Generate Speech (Streaming)

For real-time applications, use the streaming endpoint:

curl -X POST https://hub.getraya.app/v1/text-to-speech/stream \
-H "X-API-Key: <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"text": "Hello, this is a streaming example.",
"voice_id": "voice_001",
"model": "standard",
"language": "hi",
"output_format": {"container": "raw", "encoding": "pcm_s16le", "sample_rate": 24000}
}'

The response uses Server-Sent Events (SSE) format. Each chunk event carries base64-encoded audio in the encoding you asked for, here 16-bit PCM at 24 kHz. For a phone line, ask for 8 kHz μ-law instead:

"output_format": {"container": "raw", "encoding": "pcm_mulaw", "sample_rate": 8000}

See Output Formats for every option.

Next Steps