Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Whisper Transcription Backend

A FastAPI-based backend service for audio transcription using OpenAI's Whisper model with API key authentication.

Features

  • Admin Authentication: Single admin user with JWT-based authentication
  • API Key Management: Admin can create/revoke API keys for clients
  • Audio Transcription: Upload audio files or stream audio for transcription
  • Whisper Integration: Uses OpenAI Whisper for accurate transcription
  • RESTful API: Clean API design for easy integration

Setup

  1. Create virtual environment:
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. Install dependencies:
uv pip install -e .
  1. Create .env file:
cp .env.example .env
# Edit .env with your settings
  1. Generate a secret key:
openssl rand -hex 32
# Add to .env as SECRET_KEY
  1. Run the server:
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

API Endpoints

Admin Endpoints

  • POST /api/admin/login - Admin login (returns JWT token)
  • POST /api/admin/api-keys - Create new API key
  • GET /api/admin/api-keys - List all API keys
  • DELETE /api/admin/api-keys/{key_id} - Revoke API key
  • GET /api/admin/transcriptions - List all transcriptions

Client Endpoints (Require API Key)

  • POST /api/transcribe/upload - Upload audio file for transcription
  • POST /api/transcribe/stream - Stream audio for real-time transcription
  • GET /api/transcribe/{transcription_id} - Get transcription result
  • GET /api/transcribe - List user's transcriptions

Usage Examples

Admin Login

curl -X POST http://localhost:8000/api/admin/login \
  -H "Content-Type: application/json" \
  -d '{"username": "admin", "password": "your_password"}'

Create API Key

curl -X POST http://localhost:8000/api/admin/api-keys \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "Client App", "description": "Mobile app API key"}'

Transcribe Audio

curl -X POST http://localhost:8000/api/transcribe/upload \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "file=@audio.mp3"

Project Structure

py-whisper-be/
├── app/
│   ├── __init__.py
│   ├── main.py              # FastAPI application
│   ├── config.py            # Configuration settings
│   ├── database.py          # Database setup
│   ├── models.py            # SQLAlchemy models
│   ├── schemas.py           # Pydantic schemas
│   ├── auth.py              # Authentication logic
│   ├── dependencies.py      # FastAPI dependencies
│   └── routers/
│       ├── __init__.py
│       ├── admin.py         # Admin endpoints
│       └── transcribe.py    # Transcription endpoints
├── .env                     # Environment variables (not in git)
├── .env.example            # Environment template
├── .gitignore
├── pyproject.toml
└── README.md

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages