OpenAI-compatible Whisper API service using whisper.cpp for local audio transcription and translation
OpenAI-compatible Whisper API service that runs locally using whisper.cpp for audio transcription and translation. Provides a drop-in replacement for OpenAI's Whisper API endpoints.
The project follows a clean architecture with separation of concerns:
```
whisper-rest/
├── src/
│ ├── api/ # API route handlers
│ ├── services/ # Core business logic
│ ├── types/ # TypeScript definitions
│ └── config/ # Configuration management
├── models/ # Whisper model files
├── temp/ # Temporary audio processing
└── main.ts # Application entry point
```
1. Start development server with hot reload:
```bash
deno task dev
```
2. Start production server:
```bash
deno task start
```
3. Run tests:
```bash
deno test
```
**Required Permissions**: `--allow-net --allow-read --allow-write --allow-run --allow-env`
Set these environment variables for configuration:
```bash
PORT=8000 # Server port
HOST=localhost # Server host
WHISPER_BINARY_PATH=./whisper # Path to whisper executable
WHISPER_MODEL_PATH=./models/ggml-base.bin # Path to model file
TEMP_DIR=./temp # Temporary files directory
```
When handling audio requests, the service follows this workflow:
1. Receive multipart/form-data with audio file
2. Save to temp directory with UUID
3. Convert to 16kHz WAV using FFmpeg subprocess
4. Process with whisper.cpp via Deno.Command
5. Clean up temp files after processing
The API supports multiple response formats:
Implement proper error handling:
Test the API using curl:
```bash
curl -X POST http://localhost:8000/v1/audio/transcriptions \
-F "[email protected]" \
-F "response_format=json"
```
Before running this service, ensure you have:
Key files and their responsibilities:
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/whisper-rest/raw