API Reference

Text To Speech · HTTP Stream

POSThttps://api.shabd.tech/v1/text-to-speech/stream

Synthesizes text to audio and streams back binary chunks — each a 48-byte header followed by raw PCM-16 audio (see the field breakdown under the 200 response). Note: curl cannot frame the binary packet protocol — use Python or JavaScript.

Headers

  • x-api-keystringrequired

    API Key for authentication

    Example:
    <your-api-key>
  • Content-Typestringrequired

    Content type of the request body

    Example:
    application/json
  • x-request-idstringrequired

    Unique request ID in UUID format

    Example:
    550e8400-e29b-41d4-a716-446655440000

Request bodyapplication/json

  • textstringrequired

    Text to synthesize

    Example:
    Without language, we cannot communicate.
  • languagestringrequired

    Target language code

    Example:
    english
  • genderstringrequired

    Voice gender ("male" or "female")

    Example:
    male
  • sampleRateintegeroptional

    Output audio sample rate in Hz

    Example:
    48000
  • speedstringoptional

    Speed of speech (fast, normal, or slow). Default is normal if not specified.

    Example:
    normal
  • formatstringoptional

    Output audio format (e.g. "wav")

    Example:
    wav
  • wordStreambooleanoptional

    Whether to stream word-level timing information (optional)

    Example:
    false
  • returnTextbooleanoptional

    Whether to return the input text alongside the audio (optional)

    Example:
    false
  • projectIdstringoptional

    Optional project identifier

    Example:
    <your-project-id-here>

Responses

  • 200Binary stream of audio chunks. Each chunk is a 48-byte header followed by raw PCM-16 audio; audio content begins at byte 48.
    FieldDescriptionSizeByte offset
    requestIdUnique request id360 – 35
    status0 = error, 1 = success136
    completed0 = in progress, 1 = last chunk137
    sampleRateSample-rate indicator (kHz)138
    gender0 = female, 1 = male139
    contentLengthAudio length in bytes (UInt32LE)440 – 43
    chunkIdId of the audio chunk144

    On error, the chunk with status = 0 carries a UTF-8 error message as its content.

    Body: application/octet-stream — binary

    Example response

    <binary audio — application/octet-stream>
  • 400Bad Request

    Bodyapplication/json

    • statusbooleanoptional
      Example:
      false
    • messagestringoptional
      Example:
      Invalid input parameters.

    Example response

    {  "status": false,  "message": "Invalid input parameters."}
  • 401Unauthorized Access

    Bodyapplication/json

    • statusbooleanoptional
      Example:
      false
    • messagestringoptional
      Example:
      Unauthorized access.

    Example response

    {  "status": false,  "message": "Unauthorized access."}
  • 403Usage Limit Exceeded

    Bodyapplication/json

    • statusbooleanoptional
      Example:
      false
    • messagestringoptional
      Example:
      Limit Exceeded

    Example response

    {  "status": false,  "message": "Limit Exceeded"}
  • 500Internal server error

    Bodyapplication/json

    • statusbooleanoptional
      Example:
      false
    • messagestringoptional
      Example:
      An unexpected error occurred. Please try again later.

    Example response

    {  "status": false,  "message": "An unexpected error occurred. Please try again later."}