voicebridge-backend / docs /API_DOCUMENTATION.md
Shalzkrish's picture
chore: Setup professional GitHub repository documentation and configurations
2eca739
|
Raw History Blame Contribute Delete
2.5 kB

VoiceBridge AI API Documentation

The VoiceBridge AI platform exposes a production-ready RESTful API along with WebSocket endpoints for real-time streaming capabilities.

Base URL

When running locally: http://localhost:8000

REST Endpoints

1. Health Check

Checks if the API and its underlying services are active.

Endpoint: GET /health

Response (200 OK):

{
  "status": "online",
  "version": "1.0.0"
}

2. Metrics

Prometheus-compatible endpoint for scraping system health and performance metrics.

Endpoint: GET /metrics

Response (200 OK): Returns standard Prometheus text-based metrics format.

3. Translate Audio (Batch)

Translates an uploaded audio file from a source language to a target language.

Endpoint: POST /translate

Content-Type: multipart/form-data

Parameters:

  • file: The audio file (.wav, .mp3, etc.)
  • source_lang: Source language code (e.g., ta for Tamil, en for English)
  • target_lang: Target language code (e.g., hi for Hindi)

Response (200 OK): Returns a .wav file binary containing the translated synthesized speech.

4. Voice Cloning (Profile Generation)

Extracts voice embeddings from a reference audio file to create a voice profile for future cloning.

Endpoint: POST /voice-clone

Content-Type: multipart/form-data

Parameters:

  • file: The reference audio file of the speaker.

Response (200 OK):

{
  "profile_id": "spk_123456789",
  "message": "Voice profile successfully generated."
}

WebSocket Endpoints

Real-Time Speech Translation Stream

Handles live streaming of audio chunks from the client, performs Voice Activity Detection (VAD), and streams back translated audio chunks.

Endpoint: WS /ws/translate

Connection Parameters:

  • client_id (Query String): Unique identifier for the user session.
  • source_lang (Query String): Source language code.
  • target_lang (Query String): Target language code.

Message Protocol:

  1. Client -> Server (Binary): The client must send raw binary audio chunks (PCM 16-bit, 16kHz, mono).

  2. Server -> Client (Text/JSON): Interim results, transcription events, or metadata updates.

    {
      "event": "transcription",
      "text": "Hello, how are you?"
    }
    
  3. Server -> Client (Binary): The server streams back binary audio chunks containing the synthesized translated speech as soon as a VAD segment is processed.