mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-09-16 21:30:39 -07:00
Add .npmrc for bun usage and update dependencies
- Created a new .npmrc file to enforce bun usage. - Bumped version numbers for multiple packages to 0.1.9 in bun.lock. - Added react-sound-visualizer dependency to enhance audio visualization features. - Introduced convert:assets script in package.json for asset optimization. - Updated CONTRIBUTING.md with instructions for converting assets to web formats. - Added documentation files for API endpoints and developer guidelines in the docs directory.
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
---
|
||||
title: "Authentication"
|
||||
description: "API authentication and security"
|
||||
---
|
||||
|
||||
## Current Status
|
||||
|
||||
<Warning>
|
||||
Authentication is not currently implemented in Voicebox. The API is intended for local use only.
|
||||
</Warning>
|
||||
|
||||
## Local Usage
|
||||
|
||||
For local development and usage:
|
||||
- API runs on `localhost:17493`
|
||||
- No authentication required
|
||||
- Access restricted to local machine
|
||||
|
||||
## Future Implementation
|
||||
|
||||
Authentication will be added in a future release for:
|
||||
- Remote deployments
|
||||
- Multi-user access
|
||||
- Production environments
|
||||
|
||||
Planned authentication methods:
|
||||
- API keys
|
||||
- OAuth 2.0
|
||||
- JWT tokens
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
Until authentication is implemented:
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Use VPN" icon="shield">
|
||||
Use WireGuard or Tailscale for remote access
|
||||
</Card>
|
||||
<Card title="Reverse Proxy" icon="server">
|
||||
Run behind nginx with basic auth
|
||||
</Card>
|
||||
<Card title="Firewall" icon="fire">
|
||||
Restrict access to trusted IPs only
|
||||
</Card>
|
||||
<Card title="Local Only" icon="laptop">
|
||||
Don't expose to public internet
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Coming Soon
|
||||
|
||||
- API key management
|
||||
- User accounts
|
||||
- Rate limiting
|
||||
- Access control
|
||||
@@ -0,0 +1,119 @@
|
||||
---
|
||||
title: "Generation API"
|
||||
description: "Generate speech from text"
|
||||
---
|
||||
|
||||
## Generate Speech
|
||||
|
||||
```http
|
||||
POST /generate
|
||||
```
|
||||
|
||||
**Request:**
|
||||
```json
|
||||
{
|
||||
"text": "Hello world",
|
||||
"profile_id": "abc123",
|
||||
"language": "en"
|
||||
}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"id": "gen123",
|
||||
"text": "Hello world",
|
||||
"profile_id": "abc123",
|
||||
"language": "en",
|
||||
"audio_url": "/audio/gen123.wav",
|
||||
"duration": 2.3,
|
||||
"created_at": "2024-01-29T12:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
## List History
|
||||
|
||||
```http
|
||||
GET /history
|
||||
```
|
||||
|
||||
**Query Parameters:**
|
||||
- `profile_id` (optional) - Filter by voice profile
|
||||
- `limit` (optional) - Number of results (default: 50)
|
||||
- `offset` (optional) - Pagination offset
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"generations": [
|
||||
{
|
||||
"id": "gen123",
|
||||
"text": "Hello world",
|
||||
"profile_id": "abc123",
|
||||
"duration": 2.3,
|
||||
"created_at": "2024-01-29T12:00:00Z"
|
||||
}
|
||||
],
|
||||
"total": 100
|
||||
}
|
||||
```
|
||||
|
||||
## Get Generation
|
||||
|
||||
```http
|
||||
GET /history/{id}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"id": "gen123",
|
||||
"text": "Hello world",
|
||||
"profile_id": "abc123",
|
||||
"language": "en",
|
||||
"audio_url": "/audio/gen123.wav",
|
||||
"duration": 2.3,
|
||||
"created_at": "2024-01-29T12:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
## Delete Generation
|
||||
|
||||
```http
|
||||
DELETE /history/{id}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"success": true
|
||||
}
|
||||
```
|
||||
|
||||
## TypeScript Example
|
||||
|
||||
```typescript
|
||||
import { VoiceboxClient } from '@/lib/api'
|
||||
|
||||
const client = new VoiceboxClient({
|
||||
baseUrl: 'http://localhost:17493'
|
||||
})
|
||||
|
||||
// Generate speech
|
||||
const generation = await client.generate({
|
||||
text: 'Hello world',
|
||||
profile_id: 'abc123',
|
||||
language: 'en'
|
||||
})
|
||||
|
||||
// Get audio URL
|
||||
const audioUrl = generation.audio_url
|
||||
|
||||
// List history
|
||||
const history = await client.listHistory({
|
||||
profile_id: 'abc123',
|
||||
limit: 20
|
||||
})
|
||||
```
|
||||
|
||||
For full API documentation, visit `http://localhost:17493/docs` when the server is running.
|
||||
@@ -0,0 +1,219 @@
|
||||
---
|
||||
title: "API Overview"
|
||||
description: "Integrate voice synthesis into your applications with the Voicebox REST API"
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
Voicebox exposes a full REST API that allows you to integrate voice synthesis into your own applications. The API runs on `http://localhost:17493` by default.
|
||||
|
||||
<Card title="Interactive API Docs" icon="book" href="http://localhost:17493/docs">
|
||||
When Voicebox is running, visit the auto-generated API documentation at `http://localhost:17493/docs`
|
||||
</Card>
|
||||
|
||||
## Base URL
|
||||
|
||||
```
|
||||
http://localhost:17493
|
||||
```
|
||||
|
||||
For remote deployments, replace `localhost` with your server's IP or hostname.
|
||||
|
||||
## Authentication
|
||||
|
||||
<Note>
|
||||
Currently, the API does not require authentication for local development. Authentication will be added in a future release for production deployments.
|
||||
</Note>
|
||||
|
||||
## Quick Example
|
||||
|
||||
Here's a simple example of generating speech:
|
||||
|
||||
```bash
|
||||
# Generate speech
|
||||
curl -X POST http://localhost:17493/generate \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"text": "Hello world",
|
||||
"profile_id": "abc123",
|
||||
"language": "en"
|
||||
}'
|
||||
```
|
||||
|
||||
## API Endpoints
|
||||
|
||||
The Voicebox API is organized into several categories:
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Voice Profiles" icon="user" href="/api/voice-profiles">
|
||||
Create, list, update, and delete voice profiles
|
||||
</Card>
|
||||
<Card title="Generation" icon="waveform" href="/api/generation">
|
||||
Generate speech from text using voice profiles
|
||||
</Card>
|
||||
<Card title="Recordings" icon="microphone" href="/api/recordings">
|
||||
Record and transcribe audio
|
||||
</Card>
|
||||
<Card title="Stories" icon="film">
|
||||
Create and manage multi-voice stories (coming soon)
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Core Endpoints
|
||||
|
||||
### Voice Profiles
|
||||
|
||||
```http
|
||||
GET /profiles # List all profiles
|
||||
POST /profiles # Create a new profile
|
||||
GET /profiles/{id} # Get profile details
|
||||
PUT /profiles/{id} # Update a profile
|
||||
DELETE /profiles/{id} # Delete a profile
|
||||
POST /profiles/{id}/samples # Add voice sample
|
||||
```
|
||||
|
||||
### Generation
|
||||
|
||||
```http
|
||||
POST /generate # Generate speech
|
||||
GET /history # List generation history
|
||||
GET /history/{id} # Get generation details
|
||||
DELETE /history/{id} # Delete from history
|
||||
```
|
||||
|
||||
### Recordings
|
||||
|
||||
```http
|
||||
POST /recordings # Start recording
|
||||
POST /recordings/stop # Stop recording
|
||||
POST /transcribe # Transcribe audio
|
||||
```
|
||||
|
||||
## Response Format
|
||||
|
||||
All API responses follow a consistent JSON format:
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
// Response data
|
||||
},
|
||||
"error": null
|
||||
}
|
||||
```
|
||||
|
||||
Error responses:
|
||||
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"data": null,
|
||||
"error": {
|
||||
"message": "Error description",
|
||||
"code": "ERROR_CODE"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Data Models
|
||||
|
||||
### Voice Profile
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "abc123",
|
||||
"name": "John Smith",
|
||||
"language": "en",
|
||||
"description": "Professional narrator voice",
|
||||
"created_at": "2024-01-29T12:00:00Z",
|
||||
"samples": [
|
||||
{
|
||||
"id": "sample123",
|
||||
"audio_path": "/path/to/sample.wav",
|
||||
"duration": 15.5
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Generation
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "gen123",
|
||||
"text": "Hello world",
|
||||
"profile_id": "abc123",
|
||||
"language": "en",
|
||||
"audio_path": "/path/to/output.wav",
|
||||
"duration": 2.3,
|
||||
"created_at": "2024-01-29T12:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
## TypeScript Client
|
||||
|
||||
Voicebox provides an auto-generated TypeScript client with full type safety:
|
||||
|
||||
```typescript
|
||||
import { VoiceboxClient } from '@/lib/api'
|
||||
|
||||
const client = new VoiceboxClient({
|
||||
baseUrl: 'http://localhost:17493'
|
||||
})
|
||||
|
||||
// Create a profile
|
||||
const profile = await client.createProfile({
|
||||
name: 'John Smith',
|
||||
language: 'en'
|
||||
})
|
||||
|
||||
// Generate speech
|
||||
const generation = await client.generate({
|
||||
text: 'Hello world',
|
||||
profile_id: profile.id,
|
||||
language: 'en'
|
||||
})
|
||||
```
|
||||
|
||||
The client is automatically generated from the OpenAPI schema. See [Development Setup](/development/setup#generate-openapi-client) for details.
|
||||
|
||||
## Rate Limiting
|
||||
|
||||
<Info>
|
||||
Currently, there are no rate limits for local usage. Rate limiting will be added in a future release for production deployments.
|
||||
</Info>
|
||||
|
||||
## WebSocket Support
|
||||
|
||||
<Note>
|
||||
Real-time streaming generation via WebSockets is planned for a future release.
|
||||
</Note>
|
||||
|
||||
## Use Cases
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Game Development" icon="gamepad">
|
||||
Generate dynamic dialogue for NPCs and characters
|
||||
</Card>
|
||||
<Card title="Content Creation" icon="video">
|
||||
Automate voiceovers for videos and podcasts
|
||||
</Card>
|
||||
<Card title="Accessibility" icon="universal-access">
|
||||
Build text-to-speech tools for visually impaired users
|
||||
</Card>
|
||||
<Card title="Voice Assistants" icon="robot">
|
||||
Create custom voice interfaces
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Next Steps
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Voice Profiles API" icon="user" href="/api/voice-profiles">
|
||||
Learn how to manage voice profiles
|
||||
</Card>
|
||||
<Card title="Generation API" icon="waveform" href="/api/generation">
|
||||
Generate speech from text
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -0,0 +1,95 @@
|
||||
---
|
||||
title: "Recordings API"
|
||||
description: "Record and transcribe audio"
|
||||
---
|
||||
|
||||
## Start Recording
|
||||
|
||||
```http
|
||||
POST /recordings/start
|
||||
```
|
||||
|
||||
**Request:**
|
||||
```json
|
||||
{
|
||||
"source": "microphone"
|
||||
}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"recording_id": "rec123",
|
||||
"status": "recording"
|
||||
}
|
||||
```
|
||||
|
||||
## Stop Recording
|
||||
|
||||
```http
|
||||
POST /recordings/stop
|
||||
```
|
||||
|
||||
**Request:**
|
||||
```json
|
||||
{
|
||||
"recording_id": "rec123"
|
||||
}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"recording_id": "rec123",
|
||||
"audio_url": "/audio/rec123.wav",
|
||||
"duration": 15.5
|
||||
}
|
||||
```
|
||||
|
||||
## Transcribe Audio
|
||||
|
||||
```http
|
||||
POST /transcribe
|
||||
```
|
||||
|
||||
**Request:** (multipart/form-data)
|
||||
```
|
||||
audio: <file>
|
||||
language: "en" (optional)
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"text": "Transcribed speech text here",
|
||||
"language": "en",
|
||||
"duration": 15.5,
|
||||
"confidence": 0.95
|
||||
}
|
||||
```
|
||||
|
||||
## TypeScript Example
|
||||
|
||||
```typescript
|
||||
import { VoiceboxClient } from '@/lib/api'
|
||||
|
||||
const client = new VoiceboxClient({
|
||||
baseUrl: 'http://localhost:17493'
|
||||
})
|
||||
|
||||
// Start recording
|
||||
const recording = await client.startRecording({
|
||||
source: 'microphone'
|
||||
})
|
||||
|
||||
// ... record audio ...
|
||||
|
||||
// Stop recording
|
||||
const result = await client.stopRecording(recording.id)
|
||||
|
||||
// Transcribe
|
||||
const transcription = await client.transcribe(audioFile, 'en')
|
||||
console.log(transcription.text)
|
||||
```
|
||||
|
||||
For full API documentation, visit `http://localhost:17493/docs` when the server is running.
|
||||
@@ -0,0 +1,149 @@
|
||||
---
|
||||
title: "Voice Profiles API"
|
||||
description: "Manage voice profiles programmatically"
|
||||
---
|
||||
|
||||
## Endpoints
|
||||
|
||||
### List Profiles
|
||||
|
||||
```http
|
||||
GET /profiles
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"profiles": [
|
||||
{
|
||||
"id": "abc123",
|
||||
"name": "John Smith",
|
||||
"language": "en",
|
||||
"description": "Professional narrator",
|
||||
"created_at": "2024-01-29T12:00:00Z",
|
||||
"sample_count": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Get Profile
|
||||
|
||||
```http
|
||||
GET /profiles/{id}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"id": "abc123",
|
||||
"name": "John Smith",
|
||||
"language": "en",
|
||||
"description": "Professional narrator",
|
||||
"created_at": "2024-01-29T12:00:00Z",
|
||||
"samples": [
|
||||
{
|
||||
"id": "sample123",
|
||||
"duration": 15.5,
|
||||
"created_at": "2024-01-29T12:00:00Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Create Profile
|
||||
|
||||
```http
|
||||
POST /profiles
|
||||
```
|
||||
|
||||
**Request:**
|
||||
```json
|
||||
{
|
||||
"name": "John Smith",
|
||||
"language": "en",
|
||||
"description": "Professional narrator"
|
||||
}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"id": "abc123",
|
||||
"name": "John Smith",
|
||||
"language": "en",
|
||||
"description": "Professional narrator",
|
||||
"created_at": "2024-01-29T12:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
### Update Profile
|
||||
|
||||
```http
|
||||
PUT /profiles/{id}
|
||||
```
|
||||
|
||||
**Request:**
|
||||
```json
|
||||
{
|
||||
"name": "Updated Name",
|
||||
"description": "Updated description"
|
||||
}
|
||||
```
|
||||
|
||||
### Delete Profile
|
||||
|
||||
```http
|
||||
DELETE /profiles/{id}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"success": true
|
||||
}
|
||||
```
|
||||
|
||||
### Add Voice Sample
|
||||
|
||||
```http
|
||||
POST /profiles/{id}/samples
|
||||
```
|
||||
|
||||
**Request:** (multipart/form-data)
|
||||
```
|
||||
audio: <file>
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"sample_id": "sample123",
|
||||
"duration": 15.5
|
||||
}
|
||||
```
|
||||
|
||||
## TypeScript Example
|
||||
|
||||
```typescript
|
||||
import { VoiceboxClient } from '@/lib/api'
|
||||
|
||||
const client = new VoiceboxClient({
|
||||
baseUrl: 'http://localhost:17493'
|
||||
})
|
||||
|
||||
// Create profile
|
||||
const profile = await client.createProfile({
|
||||
name: 'John Smith',
|
||||
language: 'en',
|
||||
description: 'Professional narrator'
|
||||
})
|
||||
|
||||
// Add sample
|
||||
await client.addSample(profile.id, audioFile)
|
||||
|
||||
// List all profiles
|
||||
const profiles = await client.listProfiles()
|
||||
```
|
||||
|
||||
For full API documentation, visit `http://localhost:17493/docs` when the server is running.
|
||||
Reference in New Issue
Block a user