Spaces:
Runtime error
Runtime error
File size: 2,314 Bytes
6c6428c e124ecc 6c6428c 7a7d9e7 b9f274b f5ec16f 10b0a14 7a7d9e7 10b0a14 7a7d9e7 f5ec16f 7a7d9e7 f5ec16f 7a7d9e7 10b0a14 7a7d9e7 10b0a14 7a7d9e7 4ea0a00 7a7d9e7 4ea0a00 7a7d9e7 4ea0a00 7a7d9e7 f5ec16f 7a7d9e7 f5ec16f 7a7d9e7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
---
title: Spell Recorder
emoji: ✨
sdk: gradio
sdk_version: "4.44.1"
app_file: app.py
pinned: false
---
# Spell Recorder (Gradio)
Collect microphone recordings for a small set of Harry Potter spells and store them in MongoDB for training a classifier.
Spells collected:
- Lumos
- Nox
- Alohomora
- Wingardium Leviosa
- Accio
- Reparo
## How it works
- Enter a username (used in metadata; sanitized to safe characters).
- Record with your microphone (preferred) or upload an audio file for any spell.
- Click Submit.
- Audio is resampled to 16 kHz mono and stored in MongoDB GridFS with metadata (username, spell, timestamp).
- A live counter shows how many spells are selected (recorded/uploaded) before submitting.
## Run locally
Requirements (see `requirements.txt`):
- gradio
- numpy
- soundfile
- scipy
On Windows PowerShell:
```powershell
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
python app.py
```
Then open the printed local URL in your browser.
1. Create a new Space (Gradio) in your account.
2. Upload `app.py`, `requirements.txt`, and optionally `README.md`.
3. Spaces will auto-build and run the app.
4. Submissions are stored directly in your MongoDB (GridFS), not in the Space filesystem.
Notes:
- Microphone recording is enabled in the browser; no need to upload.
- Ensure MongoDB secrets are configured; otherwise the app will display that DB is not configured.
## MongoDB configuration (Spaces secrets)
Set these in your Space → Settings → Variables and secrets:
- `MONGO_URI`: your MongoDB connection string (e.g., from MongoDB Atlas)
- `MONGO_DB`: database name (default: `spells`)
- `MONGO_BUCKET`: GridFS bucket/collection prefix (default: `recordings`)
Locally (PowerShell) you can set temporarily for a session:
```powershell
$env:MONGO_URI = "mongodb+srv://user:pass@cluster.mongodb.net/?retryWrites=true&w=majority"
$env:MONGO_DB = "spells"
$env:MONGO_BUCKET = "recordings"
python app.py
```
## Privacy and consent
- Only collect voices from people who consent to being recorded.
- Consider informing contributors how their audio will be used and stored.
- Do not collect sensitive information in the username.
## Why 16 kHz mono?
Standardizing sample rate and channels simplifies downstream model training and reduces storage.
|