# 🎙 Darija Caption Studio
**Hybrid Whisper + AI Moroccan Darija caption generator**
Upload any audio or video file to get AI-generated Moroccan Darija captions with timestamps, improved by GPT-4o-mini (or Gemini 2.0 Flash), with optional translation to English, French, or Arabic and export to SRT/VTT/TXT/JSON.
---
## 🏗️ Architecture
```
Audio/Video Upload
↓
Flask Server
↓
ffmpeg (→ /tmp audio extraction)
↓
OpenAI Whisper-1 (raw Darija timestamps)
↓
GPT-4o-mini OR Gemini 2.0 Flash
(Darija language refinement)
↓
JSON: { segments: [{id, start, end, text, whisper_text, refine_engine}] }
↓
Frontend editor + translation + export
```
---
## 🚀 Deploy to Vercel (Recommended)
### Prerequisites
- Vercel account (free, no credit card for hobby tier)
- OpenAI API key
- Optional: Gemini API key
### Step 1 — Push to GitHub
```bash
git clone
github.com
cd darija-caption-studio
git init
git add .
git commit -m "Darija Caption Studio v2"
git push -u origin main
```
### Step 2 — Deploy on Vercel
```bash
npm i -g vercel
vercel --prod
```
Or via the dashboard: vercel.com → Import → connect GitHub repo → Add Environment Variables → Deploy.
### Step 3 — Set Environment Variables
In Vercel dashboard → Settings → Environment Variables:
| Variable | Required | Description |
|---|---|---|
| `OPENAI_API_KEY` | ✅ | Your OpenAI API key |
| `OPENAI_BASE_URL` | ❌ | Proxy base URL (optional) |
| `GEMINI_API_KEY` | ❌ | Gemini API key (GPT fallback used if omitted) |
| `CF_AIG_TOKEN` | ❌ | Proxy auth token (optional) |
### Step 4 — Done! 🎉
Your app will be live at: `
darija-caption-studio.verce…`
---
## 🐳 Deploy to Fly.io
```bash
# Install flyctl
curl -fsSL
fly.io | sh
export PATH="$HOME/.fly/bin:$PATH"
# Login
flyctl auth login
# Set secrets
flyctl secrets set OPENAI_API_KEY___="sk-..." --app darija-caption-studio
flyctl secrets set GEMINI_API_KEY___="..." --app darija-caption-studio
# Deploy
flyc …