API Reference

Speech To Speech · WebSocket

WSSwss://stream.shabd.tech/v1/speech-to-speech

Connection headers

  • x-api-keystringrequired

    API key for authentication.

Message flow

WebSocket endpoint for real-time speech-to-speech conversion.

Message Flow:

  • Outgoing Message (↑): The client sends metadata including a requestId, sourceLanguage, targetLanguage, and optional settings like gender, inputSampleRate, sampleRate and speed. After sending metadata, the client sends audio data in bytes.
  • Incoming Message (↓): The server responds with processed text and audio data.

Send MetaData (↑):

{  "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02",  "sourceLanguage": "english",  "targetLanguage": "hindi",  "gender": "female",  "inputSampleRate": 16000,  "sampleRate": 8000,  "speed": "normal",  "projectId": "<your-project-id-here>"}

Send Audio Data (↑):

  Raw PCM 16-bit Audio Data (in Bytes) 

Initial messageapplication/json

  • requestIdstringrequired

    Unique identifier for the request

  • sourceLanguagestringrequired

    Source language of the speech

  • targetLanguagestringrequired

    Target language to translate to

  • genderstringoptional
    Allowed:
    male
    female
    Default:
    male
  • inputSampleRatenumber or nulloptional

    Sample rate of the input speech

    Default:
    16000
  • sampleRatenumber or nulloptional

    Audio sample rate for synthesis (e.g., 22050)

  • speedstringoptional
    Allowed:
    slow
    normal
    fast
    Default:
    normal
  • projectIdstring or nulloptional

    An optional ID representing the project.

Server messages

  • 101The server sends back synthesized audio as continuous streams of raw PCM-16 bit audio data.The response consists of 48-byte header containing metadata.Raw PCM-16 bit audio data following the header.

    Receive Message (↓):

    Streaming PCM-16 bit audio data in chunks...

    Field Breakdown

    FieldDescriptionSizeByte Offset
    requestIdUnique ID for the request360 - 35
    status0 (error) or 1 (success)136
    completed0 (in progress) or 1 (finished)137
    sampleRateSampling rate of the audio (e.g., 8, 16, 22, 48)138
    gender0 (female) or 1 (male)139
    contentLengthLength of the audio content (in bytes)440 - 43
    chunkIdID for each audio chunk144
    Audio content begins from byte 48

    Messages

    Message TypeExampleDescription
    Send (↑){ "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02", "sourceLanguage": "english", "targetLanguage": "hindi", "gender": "female", "inputSampleRate": 16000, "sampleRate": 8000, "speed": "normal", "projectId": "<your-project-id-here>" }The client sends parameters for speech synthesis.
    Send (↑)Raw PCM 16-bit Audio Data (in Bytes)The client sends audio data after sending metadata.
    Receive (↓){ "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02", "status": true, "transcript": "Welcome to Shabd", "chunk": 1, "completed": false, "mode": "stt" }The server sends transcription along with status.
    Receive (↓){ "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02", "status": true, "translation": "शब्द में आपका स्वागत है", "chunk": 1, "completed": false, "mode": "ttt" }The server sends translation along with status.
    Receive (↓)Continuous stream of raw PCM-16 bit audio data in chunks until byte header completed trueThe server sends back the synthesized audio as PCM-16 bit.
    Receive (↓){ "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02", "status": true, "transcript": "", "chunk": 2, "completed": true, "mode": "stt" }The server sends completed message for transcription.
    Receive (↓){ "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02", "status": true, "translation": "", "chunk": 2, "completed": true, "mode": "ttt" }The server sends completed message for translation.