API Reference

Text Translate To Speech · HTTP Stream

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

Translates text and synthesizes the translation to audio — streamed as NDJSON (a ttt line, then progressive tts lines) over one chunked connection.

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 translate and synthesize

    Example:
    Without language, we cannot communicate.
  • sourceLanguagestringrequired

    Language of the input text

    Example:
    english
  • targetLanguagestringrequired

    Language to translate and synthesize into

    Example:
    tamil
  • 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 (default "wav")

    Example:
    wav
  • stylestringoptional

    Translation style ("conversational" or "formal")

    Allowed:
    conversational
    formal
    Default:
    conversational
  • wordStreambooleanoptional

    When true, each tts line carries the word its audio speaks in the word field. When false or omitted, word is present but empty.

    Default:
    false
    Example:
    true
  • projectIdstringoptional

    Optional project identifier

    Example:
    <your-project-id-here>

Responses

  • 200NDJSON stream — one JSON object per line, newline-separated.
    modeExample line
    ttt{ "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02", "mode": "ttt", "status": true, "completed": true, "chunk": 1, "translation": "வணக்கம் உலகம்" }
    tts{ "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02", "mode": "tts", "status": true, "completed": false, "chunk": 1, "audio": "<base64 PCM-16>", "word": "வணக்கம்", "sampleRate": 48000, "format": "pcm" }

    The single ttt line is completed: true. Every audio-bearing tts line is completed: false; a single terminal tts line with empty audio and completed: true marks the end of the stream.

    word holds the word that line's audio speaks, mirroring the word stream of /text-to-speech/stream. It is populated only when wordStream: true was requested; otherwise it is an empty string. Concatenating word across the tts lines reproduces the translation in playback order. On failure a single error line is sent: { "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02", "status": false, "completed": false, "message": "An unexpected error occurred. Please try again later." }

    Body: application/x-ndjson

    Example response

    "string"
  • 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."}