Spaces:
Sleeping
Download docs/API_DOCUMENTATION.md from Shalzkrish/voicebridge-backend: direct link, hf CLI and curl.
- Browser
- Download file 2.5 kB
-
https://huggingface.co/spaces/Shalzkrish/voicebridge-backend/resolve/main/docs/API_DOCUMENTATION.md
- Command line
-
hf download hf://spaces/Shalzkrish/voicebridge-backend/docs/API_DOCUMENTATION.md
-
curl -L -o API_DOCUMENTATION.md https://huggingface.co/spaces/Shalzkrish/voicebridge-backend/resolve/main/docs/API_DOCUMENTATION.md
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.,tafor Tamil,enfor English)target_lang: Target language code (e.g.,hifor 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:
Client -> Server (Binary): The client must send raw binary audio chunks (PCM 16-bit, 16kHz, mono).
Server -> Client (Text/JSON): Interim results, transcription events, or metadata updates.
{ "event": "transcription", "text": "Hello, how are you?" }Server -> Client (Binary): The server streams back binary audio chunks containing the synthesized translated speech as soon as a VAD segment is processed.