File size: 2,495 Bytes
2eca739
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# 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):**
```json
{
  "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):**
```json
{
  "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.
   ```json
   {
     "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.