89 lines
2.2 KiB
Markdown
89 lines
2.2 KiB
Markdown
# Component Interfaces
|
|
|
|
*(This document will define the interfaces between different components of the system, especially between the frontend and backend.)*
|
|
|
|
## Backend API (FastAPI)
|
|
|
|
*(To be detailed. Examples below)*
|
|
|
|
### `/api/tts/generate_single` (POST)
|
|
- **Request Body:**
|
|
```json
|
|
{
|
|
"text": "string",
|
|
"speaker_id": "string",
|
|
"temperature": "float (optional)",
|
|
"length_penalty": "float (optional)"
|
|
}
|
|
```
|
|
- **Response Body (Success):**
|
|
```json
|
|
{
|
|
"audio_url": "string (URL to the generated audio file)",
|
|
"duration_ms": "integer"
|
|
}
|
|
```
|
|
- **Response Body (Error):**
|
|
```json
|
|
{
|
|
"detail": "string (error message)"
|
|
}
|
|
```
|
|
|
|
### `/api/tts/generate_dialog` (POST)
|
|
- **Request Body:**
|
|
```json
|
|
{
|
|
"dialog_lines": [
|
|
{
|
|
"type": "speech", // or "silence"
|
|
"speaker_id": "string (required if type is speech)",
|
|
"text": "string (required if type is speech)",
|
|
"duration_s": "float (required if type is silence)"
|
|
}
|
|
],
|
|
"output_base_name": "string (optional)"
|
|
}
|
|
```
|
|
- **Response Body (Success):**
|
|
```json
|
|
{
|
|
"dialog_audio_url": "string (URL to the concatenated dialog audio file)",
|
|
"individual_files_zip_url": "string (URL to zip of individual lines)",
|
|
"total_duration_ms": "integer"
|
|
}
|
|
```
|
|
|
|
### `/api/speakers` (GET)
|
|
- **Response Body (Success):**
|
|
```json
|
|
[
|
|
{
|
|
"id": "string",
|
|
"name": "string",
|
|
"sample_url": "string (optional)"
|
|
}
|
|
]
|
|
```
|
|
|
|
### `/api/speakers` (POST)
|
|
- **Request Body:** (Multipart form-data)
|
|
- `name`: "string"
|
|
- `audio_sample`: file (WAV)
|
|
- **Response Body (Success):**
|
|
```json
|
|
{
|
|
"id": "string",
|
|
"name": "string",
|
|
"message": "Speaker added successfully"
|
|
}
|
|
```
|
|
|
|
## Frontend Components (Vanilla JS)
|
|
|
|
*(To be detailed as frontend development progresses.)*
|
|
|
|
- **DialogLine Component:** Manages input for a single line of dialog (speaker, text).
|
|
- **AudioPlayer Component:** Handles playback of generated audio.
|
|
- **ProjectManager Component:** Manages overall project state, dialog lines, and interaction with the backend.
|