[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-116554":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":18,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":21,"hasPages":21,"topics":23,"createdAt":10,"pushedAt":32,"updatedAt":33,"readmeContent":34,"aiSummary":35,"trendingCount":16,"starSnapshotCount":16,"syncStatus":36,"lastSyncTime":37,"discoverSource":38},116554,"deepfake-detection-starter","modulate-ai\u002Fdeepfake-detection-starter","modulate-ai","Next.js starter that sends a voice clip to Modulate's Velma Deepfake Detection API and shows whether it sounds natural or synthetic. One-click deploy to Vercel.","https:\u002F\u002Fdocs.modulate.ai\u002Fget-started\u002Fdeepfake?utm_source=github&utm_medium=repo&utm_campaign=infrasity_m1_repo2&utm_content=repo_about_link",null,"TypeScript",76,1,51,20,0,23,10,54.7,"MIT License",false,"main",[24,25,26,27,28,29,30,31],"audio","deepfake-detection","nextjs","starter","typescript","velma","vercel","voice","2026-11-16 21:14:02","2026-11-23 16:15:06","\u003Cp align=\"center\">\n  \u003Cimg src=\"assets\u002Fbanner.png\" alt=\"Velma Deepfake Detection Starter\" width=\"100%\">\n\u003C\u002Fp>\n\n# Velma Deepfake Detection Starter\n\nA small Next.js app that sends a voice clip to Modulate's Velma Deepfake Detection API and shows what comes back. Upload a file, record from the microphone or pick a sample, press Analyse, and read the result on a meter with a plain label.\n\n**This version analyses the clip after you finish. It does not stream live audio.** See [Batch or streaming](#batch-or-streaming) for why.\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"docs\u002Fscreenshots\u002Fstep3-result-desktop-light.png\" alt=\"Step 3, result\" width=\"80%\">\n\u003C\u002Fp>\n\nThe result screenshots use a clip made with the macOS text-to-speech voice, so the clip is synthetic by construction. They come from a real call to Velma, not mock data.\n\n> Demo only. Scores are estimates and are not proof.\n\n## Table of contents\n\n- [Get started in three steps](#get-started-in-three-steps)\n- [Run locally](#run-locally)\n- [Environment variables](#environment-variables)\n- [How it works](#how-it-works)\n- [How a clip is split into windows](#how-a-clip-is-split-into-windows)\n- [How the key is protected](#how-the-key-is-protected)\n- [Metrics: natural, synthetic and confidence](#metrics-natural-synthetic-and-confidence)\n- [From windows to a label](#from-windows-to-a-label)\n- [Batch or streaming](#batch-or-streaming)\n- [Limits and rate limiting](#limits-and-rate-limiting)\n- [Add sample clips](#add-sample-clips)\n- [Screenshots](#screenshots)\n- [Project structure](#project-structure)\n\n## Get started in three steps\n\n1. **Get a key.** Request access at [platform.modulate.ai](https:\u002F\u002Fplatform.modulate.ai\u002Fsignup-request) and create an API key in the dashboard.\n2. **Deploy.**\n\n   [![Deploy with Vercel](https:\u002F\u002Fvercel.com\u002Fbutton)](https:\u002F\u002Fvercel.com\u002Fnew\u002Fclone?repository-url=https%3A%2F%2Fgithub.com%2Fmodulate-ai%2Fdeepfake-detection-starter&env=VELMA_API_KEY&envDescription=Your%20Modulate%20Velma%20API%20key&envLink=https%3A%2F%2Fplatform.modulate.ai%2Fsignin)\n\n3. **Open the app.** Choose a clip, press **Analyse clip**, read the result.\n\n## Run locally\n\nYou need Node 22 and pnpm.\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fmodulate-ai\u002Fdeepfake-detection-starter.git\ncd deepfake-detection-starter\npnpm install\ncp .env.example .env.local   # then paste your key after VELMA_API_KEY=\npnpm dev\n```\n\nOpen \u003Chttp:\u002F\u002Flocalhost:3000>.\n\nOther scripts: `pnpm lint`, `pnpm exec tsc --noEmit`, `pnpm build`, `pnpm start`.\n\n## Environment variables\n\n| Name | Required | Description |\n|---|---|---|\n| `VELMA_API_KEY` | Yes | Your Modulate API key. Read on the server only. |\n\n## How it works\n\n```mermaid\n%%{init: {\"flowchart\": {\"nodeSpacing\": 24, \"rankSpacing\": 36, \"padding\": 6, \"wrappingWidth\": 260, \"htmlLabels\": true}, \"themeVariables\": {\"fontSize\": \"13px\"}}}%%\nflowchart LR\n    classDef browser fill:#dbeafe,stroke:#2563eb,color:#0f172a\n    classDef server fill:#e5e7eb,stroke:#4b5563,color:#0f172a\n    classDef velma fill:#ede9fe,stroke:#7c3aed,color:#0f172a\n\n    A[\"\u003Cb>1. Browser\u003C\u002Fb>\u003Cbr\u002F>pick, drop or record\"]:::browser\n    B[\"\u003Cb>2. \u002Fapi\u002Fdetect\u003C\u002Fb>\u003Cbr\u002F>validate, rate limit\"]:::server\n    C[\"\u003Cb>3. Velma batch\u003C\u002Fb>\u003Cbr\u002F>4 s windows, score each\"]:::velma\n    D[\"\u003Cb>4. \u002Fapi\u002Fdetect\u003C\u002Fb>\u003Cbr\u002F>summarise frames\"]:::server\n    E[\"\u003Cb>5. Browser\u003C\u002Fb>\u003Cbr\u002F>verdict + timeline\"]:::browser\n\n    A -->|file| B\n    B -->|upload_file| C\n    C -->|frames| D\n    D -->|summary| E\n```\n\nBlue steps run in the browser, grey steps on your server, purple steps at Velma. The server checks file type and size (max 4 MB) and applies a rate limit of 6 requests per minute per IP, adds the `X-API-Key` header, then drops no-content windows and computes the natural share, confidence and label. The browser never sees the API key and never talks to Velma directly.\n\nThe route calls the batch endpoint documented at [docs.modulate.ai\u002Fapi-reference\u002Fsvd\u002Fbatch](https:\u002F\u002Fdocs.modulate.ai\u002Fapi-reference\u002Fsvd\u002Fbatch?utm_source=github&utm_medium=repo&utm_campaign=infrasity_m1_repo2):\n\n- [`POST https:\u002F\u002Fplatform.modulate.ai\u002Fapi\u002Fvelma-2-synthetic-voice-detection-batch`](https:\u002F\u002Fplatform.modulate.ai\u002Fapi\u002Fvelma-2-synthetic-voice-detection-batch?utm_source=github&utm_medium=repo&utm_campaign=infrasity_m1_repo2)\n- Header `X-API-Key`\n- Multipart field `upload_file`\n\nVelma accepts `webm`, `ogg`, `opus`, `wav`, `mp3`, `m4a` and many other containers directly. Browser recordings (`webm` or `ogg`, depending on the browser) are therefore sent as they are, with no transcoding step.\n\n## How the key is protected\n\n- `VELMA_API_KEY` is read from `process.env` inside `app\u002Fapi\u002Fdetect\u002Froute.ts` and nowhere else.\n- It has no `NEXT_PUBLIC_` prefix, so Next.js never bundles it for the browser.\n- The key is never logged and never included in a response.\n- `.env.local` is in `.gitignore`. Only `.env.example` with an empty value is committed.\n\n## How a clip is split into windows\n\nVelma does the splitting, not this app. The batch endpoint processes the file from start to finish in fixed **4 second windows** (its docs call them frames):\n\n```mermaid\nflowchart LR\n    A[\"Uploaded clip\"] --> B[\"Trim leading and\u003Cbr\u002F>trailing silence\"]\n    B --> C[\"Cut into contiguous\u003Cbr\u002F>4 s windows\"]\n    C --> D[\"Pad the last window\u003Cbr\u002F>if shorter than 4 s\"]\n    D --> E[\"Score each window:\u003Cbr\u002F>verdict + confidence\"]\n    E --> F[\"Frames returned\u003Cbr\u002F>with start and end ms\"]\n```\n\n- Windows are back to back: `0:00 – 0:04`, `0:04 – 0:08`, `0:08 – 0:12` and so on. Timestamps refer to the original file, so trimmed silence does not shift them.\n- Audio shorter than 4 seconds is padded before scoring. Velma needs at least 0.5 seconds, and 4 to 60 seconds is recommended.\n- A window with no usable speech gets the verdict `no-content` with confidence `1.0`. This is assigned before the model runs, so silence is never guessed at.\n- A 12 second clip of speech therefore yields about 3 windows. A 32 second clip with 16 seconds of speech can yield 8 windows, with the silent ones marked `no-content`.\n\nThe app shows one **window card** per frame (verdict, time range and confidence bar) and a **timeline** that lays the windows out in order. In the timeline each segment is as wide as its window, coloured by verdict, and brighter when Velma is more confident.\n\nSource: [Velma Deepfake Detection docs](https:\u002F\u002Fdocs.modulate.ai\u002Fget-started\u002Fdeepfake?utm_source=github&utm_medium=repo&utm_campaign=infrasity_m1_repo2).\n\n## Metrics: natural, synthetic and confidence\n\nVelma does not return a single fake score. Every window carries a **verdict** (`synthetic`, `non-synthetic` or `no-content`) and a **confidence** from 0 to 1 in that verdict. The app combines the windows into the metrics on the Verdict card.\n\n| Metric | What it means | How it is computed |\n|---|---|---|\n| **Window verdict** | Velma's call for one 4 s window | Returned by Velma |\n| **Window confidence** | How sure Velma is of *that verdict*, 0 to 1 | Returned by Velma |\n| **Natural** | Share of detected speech judged `non-synthetic` | Time-weighted share over speech windows |\n| **Synthetic** | Share of detected speech judged `synthetic` | `1 − Natural` |\n| **Avg confidence** | Typical certainty across the clip | Time-weighted mean of window confidence over speech windows |\n| **Speech seconds** | How much audio was actually scored | Sum of speech window lengths |\n\n```text\nspeech      = windows whose verdict is not \"no-content\"\nNatural     = Σ length(non-synthetic windows) \u002F Σ length(speech windows)\nSynthetic   = 1 − Natural\nAvgConf     = Σ confidence × length \u002F Σ length          (speech windows only)\n```\n\n### Confidence is not a fake score\n\nConfidence says how certain Velma is about the verdict it gave. It is **not** the probability that the audio is synthetic.\n\n- `non-synthetic` at `0.97` means Velma is 97% sure the speech is natural.\n- `synthetic` at `0.97` means Velma is 97% sure the speech is synthetic. It does not mean \"3% fake\".\n- That is why the first screenshot below reads **Natural 0.00, Synthetic 1.00, Avg confidence 0.97**: the clip is judged fully synthetic, and Velma is very sure about it.\n- Avg confidence says nothing about direction. Read it together with Natural and Synthetic.\n\n### Worked examples\n\n| Clip | Windows (verdict @ confidence) | Natural | Synthetic | Avg confidence |\n|---|---|---|---|---|\n| Text-to-speech voice, 12 s | 3 × synthetic @ 0.97 | 0.00 | 1.00 | 0.97 |\n| Real voice, 8 s | 2 × non-synthetic @ 0.92 | 1.00 | 0.00 | 0.92 |\n| Mixed, 8 s | non-synthetic @ 0.90, synthetic @ 0.70 | 0.50 | 0.50 | 0.80 |\n| 16 s of speech in a 32 s file | 4 × synthetic @ 0.97, 4 × no-content | 0.00 | 1.00 | 0.97 (silence excluded) |\n\nThe `no-content` windows never count towards Natural, Synthetic or Avg confidence. If every window is `no-content`, the app reports \"No speech detected\" instead of a score.\n\n## From windows to a label\n\nModulate does not publish a clip-level threshold and advises setting one against your own labelled recordings. The cut-offs in [`lib\u002Finterpret.ts`](lib\u002Finterpret.ts) are demo defaults chosen for this repo, not Modulate values:\n\n| Natural share of speech | Label |\n|---|---|\n| 75% or more | Likely real |\n| Between 25% and 75% | Unsure |\n| 25% or less | Likely synthetic |\n\nChange `LIKELY_REAL_MIN` and `LIKELY_SYNTHETIC_MAX` to suit your data. The label uses only the Natural share. Confidence does not move a clip between labels, it is shown so you can judge how firm each call is.\n\nModulate publishes accuracy results for the model on the [Deepfake Detection benchmark page](https:\u002F\u002Fdocs.modulate.ai\u002Fbenchmarks\u002Fdeepfake-detection?utm_source=github&utm_medium=repo&utm_campaign=infrasity_m1_repo2). This repo does not make accuracy claims of its own.\n\n## Batch or streaming\n\nVelma offers both a batch endpoint and a WebSocket streaming endpoint. This starter uses batch because:\n\n- The streaming endpoint takes the API key as a query parameter, so a browser connecting directly would expose the key.\n- Next.js route handlers on Vercel cannot hold a WebSocket open, so a server-side proxy needs a separate long-running service.\n\nIf you need live scoring, run a small WebSocket relay on a host that supports it and keep the key there. The streaming reference is at [docs.modulate.ai\u002Fapi-reference\u002Fsvd\u002Fstreaming](https:\u002F\u002Fdocs.modulate.ai\u002Fapi-reference\u002Fsvd\u002Fstreaming?utm_source=github&utm_medium=repo&utm_campaign=infrasity_m1_repo2).\n\n## Limits and rate limiting\n\n| Limit | Value | Where it comes from |\n|---|---|---|\n| Upload size in this demo | 4 MB | Vercel rejects request bodies over 4.5 MB. Velma itself allows 100 MB. |\n| Recording length | 30 seconds | Keeps recordings well under the size cap. |\n| Clip length | 0.5 seconds minimum, 4 to 60 seconds recommended | Velma docs |\n| Requests per IP | 6 per minute | `lib\u002Frate-limit.ts`, in memory |\n| Request timeout | 45 seconds | `lib\u002Fvelma.ts` |\n| Concurrent requests per key | 3 by default | Velma, per model, can be raised by Modulate |\n\nThe in-memory limiter keeps one counter per server instance. On serverless hosts each instance counts separately, so treat it as a courtesy limit. For production use a shared store such as Redis.\n\nErrors from Velma are mapped to plain messages: 401 and 403 (key problems), 413 (too large), 422 (too short), 429 (concurrency or credits), 504 (timeout).\n\n## Add sample clips\n\nThe sample picker reads `public\u002Fsamples\u002Fmanifest.json`. It ships as an empty array, so the picker is hidden until you add clips.\n\n1. Put audio files in `public\u002Fsamples\u002F`.\n2. Add an entry to `manifest.json` for each one:\n\n```json\n[\n  {\n    \"title\": \"Studio voice, real\",\n    \"file\": \"real-01.wav\",\n    \"label\": \"real\",\n    \"source\": \"https:\u002F\u002Fexample.com\u002Fwhere-it-came-from\",\n    \"licence\": \"CC BY 4.0\"\n  }\n]\n```\n\nOnly add clips you recorded yourself or whose licence allows public redistribution. Keep them under 15 seconds.\n\n## Screenshots\n\n| Desktop | Mobile |\n|---|---|\n| ![Home, desktop](docs\u002Fscreenshots\u002Fhome-desktop-light.png) | ![Home, mobile](docs\u002Fscreenshots\u002Fhome-mobile-light.png) |\n\nThe flow, from choosing a clip to the result list, and the error state for an unsupported file:\n\n![Step 1, choose a clip](docs\u002Fscreenshots\u002Fstep1-choose-ready.png)\n![Step 2, analysing](docs\u002Fscreenshots\u002Fstep2-analysing.png)\n![Result windows and the New clip pill](docs\u002Fscreenshots\u002Fresult-pill-above-footer.png)\n![Error, unsupported file](docs\u002Fscreenshots\u002Ferror-bad-file.png)\n\n## Project structure\n\n```text\ndeepfake-detection-starter\u002F\n├── app\u002F\n│   ├── api\u002Fdetect\u002Froute.ts     server route: validate, rate limit, call Velma, summarise\n│   ├── layout.tsx              fonts and theme\n│   ├── page.tsx                header, hero, detector, footer\n│   └── globals.css             Tailwind and colour tokens (light and dark)\n├── components\u002F\n│   ├── detector.tsx            upload\u002Frecord, control pill, verdict, timeline, window cards\n│   ├── waveform.tsx            SVG waveform and the dotted voice bar\n│   ├── theme-toggle.tsx        light and dark switch\n│   └── ui\u002F                     shadcn\u002Fui primitives (button, card, collapsible)\n├── lib\u002F\n│   ├── velma.ts                endpoint, allowed formats, limits, response types\n│   ├── interpret.ts            windows to Natural, Synthetic, confidence and label\n│   ├── rate-limit.ts           in-memory per-IP limiter\n│   ├── audio.ts                waveform decoding and recording helpers\n│   └── utils.ts                class name helper\n├── public\u002Fsamples\u002F             manifest.json and your sample clips\n├── docs\u002Fscreenshots\u002F           UI screenshots used in this README\n├── assets\u002Fbanner.png           README banner\n├── .env.example                VELMA_API_KEY placeholder\n└── LICENSE                     MIT\n```\n\n## Links\n\n- [Velma Deepfake Detection docs](https:\u002F\u002Fdocs.modulate.ai\u002Fget-started\u002Fdeepfake?utm_source=github&utm_medium=repo&utm_campaign=infrasity_m1_repo2)\n- [Authentication and rate limits](https:\u002F\u002Fdocs.modulate.ai\u002Fguides\u002Fauthentication?utm_source=github&utm_medium=repo&utm_campaign=infrasity_m1_repo2)\n\nReleased under the [MIT licence](LICENSE).\n","这是一个基于Next.js的深度伪造语音检测演示项目，用于调用Modulate公司Velma API对上传或录制的音频片段进行批量分析，并直观展示其为自然语音或合成语音的概率结果。项目采用TypeScript开发，支持一键部署至Vercel，具备本地运行能力；关键API密钥仅在服务端使用，保障安全性；分析流程为非实时批处理模式，适用于快速验证、原型开发与教育演示场景。",2,"2026-11-24 04:53:50","CREATED_QUERY"]