A Python web app for building a Darija speech dataset — runs on PC but streams to any device over a Cloudflare Tunnel, so you can record straight from your iPhone's high-quality mic instead of being stuck with a mediocre laptop microphone. Sentences are served one by one and audio is saved automatically to the PC.
# BLANI Darija Recorder
A small mobile-first web tool to record Darija audio for fine-tuning
your Whisper-Darija model. You see a sentence, tap record, speak, tap
stop, save. Audio + transcript metadata get written to disk as a
HuggingFace-ready dataset.
## What you'll need
- Python 3.10+
- `ffmpeg` installed and on your PATH
(you already have it from the BLANI backend work)
- A `GEMINI_API_KEY` (only used **once**, to generate the script list)
- An **ngrok** free account, if you want to record from your iPhone
## Setup
```bash
# from this folder
pip install -r requirements.txt
cp .env.example .env
# edit .env, paste your GEMINI_API_KEY
```
## Step 1 — Generate the script list
This calls Gemini once to produce 30 Darija sentences (focused on
hotels, apartments, and trip planning per your scope), in Arabic
script + Latin transliteration + English translation. Writes
`scripts.json` in the same folder.
```bash
python generate_scripts.py
```
You can re-run this any time to refresh the script set. The server
reads `scripts.json` on every request, so changes are picked up live.
**Review `scripts.json` before recording.** If any sentence looks
weird or wrong, edit the file by hand — the file is plain JSON.
## Step 2 — Start the server
```bash
python server.py
```
You'll see:
```
open:
localhost
ngrok: ngrok http 5050 (for iPhone access)
```
Open `
localhost` in your browser to test on your PC.
Allow microphone access when prompted.
## Step 3 — Record from your iPhone (HTTPS via ngrok)
iPhone Safari requires HTTPS to use the microphone. `localhost`
doesn't qualify — you need a public HTTPS URL pointing at your PC.
ngrok provides this for free.
1. Sign up at
ngrok.com (free tier is fine)
2. Install ngrok, run `ngrok config add-authtoken ` once
3. In a **second terminal**, while `server.py` is running:
```bash
ngrok http 5050
```
4. ngrok prints something like `Forwarding
abc123.ngrok-free.app ->
localho …