API Reference

Speech To Text Translate · WebSocket

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

Connection headers

  • x-api-keystringrequired

    API key for authentication.

Message flow

  • Outgoing Message (↑): The client sends metadata first then sends audio data in bytes.
  • Incoming Message (↓): The server responds json with requestId, status, transcript, translation, chunk, completed, mode.

Send Metadata (↑):

{  "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02",  "sourceLanguage": "hindi",  "targetLanguage": "tamil",  "sampleRate": 16000,  "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 of the text

  • sampleRatenumber or nulloptional

    Sample Rate of the speech

    Default:
    16000
  • projectIdstring or nulloptional

    An optional ID representing the project.

Server messages

  • 101The server streams transcribed and translated text.

    Receive Transcription and Translation (↓):

    {  "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02",  "status": true,  "transcript": "नमस्ते, आपका दिन शुभ हो!",  "chunk": 1,  "completed": false,  "mode": "stt"}
    {  "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02",  "status": true,  "translation": "வணக்கம் இனிய நாள்!",  "chunk": 1,  "completed": false,  "mode": "ttt"}

    When the transcription is complete:

    {  "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02",  "status": true,  "transcript": "",  "chunk": 2,  "completed": true,  "mode": "stt"}

    When the translation is complete:

    {  "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02",  "status": true,  "translation": "",  "chunk": 2,  "completed": true,  "mode": "ttt"}

    Messages

    Message TypeExampleDescription
    Send (↑){ "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02", "sourceLanguage": "hindi", "targetLanguage": "tamil", "sampleRate": 16000, "projectId": "<your-project-id-here>" }The client sends parameters for getting transcription and translation from the Audio.
    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": "नमस्ते, आपका दिन शुभ हो!!", "chunk": 1, "completed": false, "mode": "stt" }The server sends transcription along with status and progress updates.
    Receive (↓){ "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02", "status": true, "translation": "வணக்கம் இனிய நாள்!", "chunk": 1, "completed": false, "mode": "ttt" }The server sends translation along with status and progress updates.
    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.

    Example response

    {  "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02",  "status": true,  "transcript": "नमस्ते, आपका दिन शुभ हो!",  "chunk": 1,  "completed": false,  "mode": "stt"} {  "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02",  "status": true,  "translation": "வணக்கம் இனிய நாள்!",  "chunk": 1,  "completed": false,  "mode": "ttt"} {  "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02",  "status": true,  "transcript": "",  "chunk": 2,  "completed": true,  "mode": "stt"} {  "requestId": "a216e43a-9d81-444c-a9ae-3c1e400fcb02",  "status": true,  "translation": "",  "chunk": 2,  "completed": true,  "mode": "ttt"}