# xEARSDROPx

Live browser audio recognition. Four categories, honest about what works.

**Live URL:** https://xearsdropx.thebdapp.com/

## What actually works vs. what's stubbed

| Category | Status | Notes |
|---|---|---|
| **Music** | Works | Local constellation fingerprint (deterministic) + AudD `/recognize` for cloud lookup. Free tier caps at ~10 IDs / IP / day; drop an API key in `config.js` to lift the cap. |
| **Voice** | Works — demo-grade | 13-dim MFCC average-pooled centroid + cosine similarity. Sensitive to mic/channel and confuses similar-spectrum speakers. **Not** for authentication. Production voice ID needs an x-vector / ECAPA network. |
| **Animal / env** | Works | `@tensorflow-models/speech-commands` (18 classes). YAMNet (521 AudioSet classes) is a follow-up — see roadmap. |
| **Electromagnetic** | Stub only | Physically impossible from a microphone. Requires an SDR (RTL-SDR, ~$30) wired via WebSerial or a local HTTP daemon. Stub `POST /api/em-observation` schema shown in-app. |

## Files

```
sites/xearsdropx/
├─ index.html                        landing + 4-tab listener UI
├─ nginx.conf                        vhost for scripts/domain-attach.sh
├─ robots.txt / sitemap.xml / llms.txt
├─ lib/
│   ├─ app.js                        entry point — mic, tabs, wiring
│   ├─ audio-fingerprint.js          Shazam-style constellation hashing
│   ├─ mfcc.js                       13-coeff MFCC (25ms/10ms)
│   ├─ speaker-embedding.js          avg-pooled MFCC + cosine sim
│   └─ yamnet-loader.js              dynamic TF.js + speech-commands loader
├─ api/
│   └─ audd.js                       AudD /recognize wrapper (+ PCM→WAV)
└─ test/
    └─ fingerprint.mjs               Playwright determinism smoke
```

Plus one Supabase migration:
- `supabase/migrations/*_earsdrop_voice_profiles.sql` — `public.voice_profiles` table with own-row RLS + `is_master_admin()` bypass.

## Configuration

`sites/xearsdropx/config.js` is **gitignored**. To enable the AudD paid tier:

```js
// sites/xearsdropx/config.js
export const AUDD_API_KEY = 'your-key-here';
```

Without a key the app falls back to the AudD free tier (~10 IDs / IP / day).

## Deploy

```bash
# 1. Auto-attach domain (DNS via Namecheap API → nginx → certbot)
sudo bash /opt/biz-dev-app/scripts/domain-attach.sh xearsdropx.thebdapp.com --slug xearsdropx

# 2. Apply migration
supabase db push --include-all --project-ref kwxdkuljhwdbwqvzdgpw

# 3. Verify
curl -sSf https://xearsdropx.thebdapp.com/ | grep -q Earsdrop && echo OK
```

## Test

Deterministic fingerprint smoke (Playwright, no external services):

```bash
cd /opt/biz-dev-app
node sites/xearsdropx/test/fingerprint.mjs
```

## Roadmap

- **YAMNet upgrade** — swap speech-commands (18 classes) for YAMNet (521 AudioSet classes: dog, cat, glass_break, engine, siren, etc.). ~15 MB model + custom 0.96s mel-spectrogram preprocessing.
- **Server-side voice profiles** — currently voices persist to `localStorage`. Wire to `public.voice_profiles` via Supabase REST once the user is signed into the main Biz Dev App.
- **x-vector speaker model** — replace naive MFCC centroid with a proper ECAPA-TDNN network for real speaker verification.
- **SDR integration** — WebSerial adapter for RTL-SDR dongles, waterfall visualization, known-signal ontology (LoRa 915 MHz, ADS-B 1090 MHz, ISM bands). Local daemon POSTs to `/api/em-observation`.
- **Continuous music ID** — background 15-second rolling window with debounce, not one-shot.

## License / attribution

Powered by [Biz Dev App](https://thebdapp.com). MIT-style — copy the file layout for any tenant that needs live audio recognition.
