Spaces:
Running
Running
Auto-download evidence capture JSON
Browse files
README.md
CHANGED
|
@@ -45,7 +45,7 @@ The first load downloads model files and the selected Supertonic voice embedding
|
|
| 45 |
|
| 46 |
The Runtime panel shows the browser's WebGPU adapter status before loading. **Auto** uses hardware WebGPU when it is exposed, falls back to WASM when WebGPU is missing, and also falls back to WASM for software adapters such as SwiftShader unless **WebGPU** is selected explicitly for an experiment.
|
| 47 |
|
| 48 |
-
The Latency panel includes validation cards for the two external evidence gates: three real microphone rows and at least one hardware WebGPU row. The hardware card uses the same adapter classification as the Runtime panel and updates to ready once a completed benchmark row records real WebGPU execution. On a browser with a real adapter, **Run WebGPU evidence row** loads the default WebGPU evidence stack when needed and captures a fast identity row for the downloaded JSON. **Run evidence capture** is the one-button browser path: it records a hardware WebGPU row when possible, switches from an already-loaded non-WebGPU stack to the default WebGPU evidence stack while preserving existing benchmark rows, runs the 3-row real-mic series, then leaves **Download JSON** enabled for saving
|
| 49 |
|
| 50 |
## Chosen Stack
|
| 51 |
|
|
@@ -104,11 +104,11 @@ Candidate comparisons to run:
|
|
| 104 |
|
| 105 |
For model comparisons, choose the candidate model before **Load models**, run **Run benchmark suite**, add at least three real microphone rows with **Run 3 real-mic series**, then click **Unload models** and choose the next candidate. The benchmark table is preserved across unloads, so **Copy JSON** can export the summary and all rows after the comparison set. For TTS voice/step comparisons, change the voice or step slider after loading and rerun **Run TTS benchmark** plus the text/loopback benchmarks; those values are captured per row.
|
| 106 |
|
| 107 |
-
Use **Download JSON** after benchmark or real-mic runs on the hosted Space to save a timestamped evidence file with the same payload as **Copy JSON** and `window.browserSpeakBench.exportResults()`. The export includes `generatedAt`, `hostMetadata` with the hosted Space commit when the static host exposes it, the current `runtime`, an `evidence` summary for real-mic/hardware-WebGPU/hosted-build readiness, aggregate `summary`, and raw `results`. Benchmark rows are also autosaved in browser storage for the current host and Space commit, so a reload during manual evidence capture can restore rows from the same deployed build; **Clear** removes both the visible rows and the saved copy.
|
| 108 |
|
| 109 |
Use `node tools/audit-browser-evidence.mjs path/to/browser-speak-benchmarks.json` to audit a JSON file downloaded from the hosted browser UI. This checks that the export came from the static Space revision, reports the page-generated `evidence` summary, verifies that at least three real-mic rows meet the WER/identity/latency gates from raw rows, and verifies that at least one completed row reports hardware WebGPU rather than a software adapter. Browser-downloaded JSON cannot prove no-server network behavior or Chrome launch flags by itself, so pair it with `node tools/run-hosted-smoke.mjs` for network evidence or `node tools/run-real-mic-series.mjs` for harness-collected real-mic provenance.
|
| 110 |
|
| 111 |
-
When served from localhost or the hosted Hugging Face Space, the page installs `window.browserSpeakBench` for browser automation. It exposes `loadStack(options)`, `setRuntimeOptions(options)`, `preloadVoice(options)`, `runSuite()`, `runMicSeries()`, `runEvidenceCapture()`, one-off runners such as `runTts()`, `runLoopback()`, and `runWebGpuEvidence()`, `exportResults()`, `clearResults()`, `webgpuInfo()`, and `state()`. This lets a Playwright, Puppeteer, or DevTools Protocol harness drive the same UI-backed benchmark paths and collect the same JSON as **Copy JSON**. `setRuntimeOptions()` and `loadStack()` also accept `ttsChunking` so first-response chunk thresholds can be benchmarked without editing source; the exported stack records the active chunk profile. The helper `node tools/run-fake-mic-benchmark.mjs` synthesizes the scripted prompt with local Supertonic, relaunches Chrome with that WAV as `--use-file-for-fake-audio-capture`, and runs three scripted mic rows through getUserMedia, the audio worklet, VAD, STT, LLM, and TTS. Set `BROWSER_SPEAK_REUSE_FAKE_MIC_WAV=true` to reuse an existing fixture WAV and skip the synthesis/load pass during regression checks; row timeouts can be adjusted with `BROWSER_SPEAK_FAKE_MIC_TURN_TIMEOUT_MS` and `BROWSER_SPEAK_FAKE_MIC_ROW_TIMEOUT_MS`. The CDP harnesses use a 60-second protocol watchdog by default, configurable with `BROWSER_SPEAK_CDP_TIMEOUT_MS`, short 5-second status-poll watchdogs, configurable with `BROWSER_SPEAK_CDP_POLL_TIMEOUT_MS`, and a page-unresponsive watchdog, configurable with `BROWSER_SPEAK_PAGE_UNRESPONSIVE_TIMEOUT_MS`, so a slow or wedged browser target produces a controlled failure and cleanup instead of blocking indefinitely. A fake capture file is useful for regression testing the mic pipeline, but real microphone rows are still required before judging conversational quality.
|
| 112 |
|
| 113 |
Use `node tools/run-ui-smoke.mjs` for a fast desktop/mobile UI check before or after model benchmarks. It loads the static page in Chrome, waits for the runtime/WebGPU status to settle, verifies the automation API and key controls, checks for body or visible element overflow outside the intentionally scrollable benchmark table, and writes `/tmp/browser-speak-ui-smoke.json` plus screenshots in `/tmp/browser-speak-ui-smoke`. Override with `BROWSER_SPEAK_UI_VIEWPORTS`, `BROWSER_SPEAK_UI_JSON`, `BROWSER_SPEAK_UI_SCREENSHOT_DIR`, `BROWSER_SPEAK_URL`, `BROWSER_SPEAK_HEADLESS=false`, `BROWSER_SPEAK_CHROME_ARGS`, or `CHROME_BIN`.
|
| 114 |
|
|
|
|
| 45 |
|
| 46 |
The Runtime panel shows the browser's WebGPU adapter status before loading. **Auto** uses hardware WebGPU when it is exposed, falls back to WASM when WebGPU is missing, and also falls back to WASM for software adapters such as SwiftShader unless **WebGPU** is selected explicitly for an experiment.
|
| 47 |
|
| 48 |
+
The Latency panel includes validation cards for the two external evidence gates: three real microphone rows and at least one hardware WebGPU row. The hardware card uses the same adapter classification as the Runtime panel and updates to ready once a completed benchmark row records real WebGPU execution. On a browser with a real adapter, **Run WebGPU evidence row** loads the default WebGPU evidence stack when needed and captures a fast identity row for the downloaded JSON. **Run evidence capture** is the one-button browser path: it records a hardware WebGPU row when possible, switches from an already-loaded non-WebGPU stack to the default WebGPU evidence stack while preserving existing benchmark rows, runs the 3-row real-mic series, then starts a JSON download and leaves **Download JSON** enabled for saving another copy.
|
| 49 |
|
| 50 |
## Chosen Stack
|
| 51 |
|
|
|
|
| 104 |
|
| 105 |
For model comparisons, choose the candidate model before **Load models**, run **Run benchmark suite**, add at least three real microphone rows with **Run 3 real-mic series**, then click **Unload models** and choose the next candidate. The benchmark table is preserved across unloads, so **Copy JSON** can export the summary and all rows after the comparison set. For TTS voice/step comparisons, change the voice or step slider after loading and rerun **Run TTS benchmark** plus the text/loopback benchmarks; those values are captured per row.
|
| 106 |
|
| 107 |
+
Use **Download JSON** after benchmark or real-mic runs on the hosted Space to save a timestamped evidence file with the same payload as **Copy JSON** and `window.browserSpeakBench.exportResults()`. The export includes `generatedAt`, `hostMetadata` with the hosted Space commit when the static host exposes it, the current `runtime`, an `evidence` summary for real-mic/hardware-WebGPU/hosted-build readiness, aggregate `summary`, and raw `results`. The **Run evidence capture** button starts a timestamped `browser-speak-evidence-*.json` download when the capture sequence finishes; if the browser blocks the automatic download, **Download JSON** saves the same payload manually. Benchmark rows are also autosaved in browser storage for the current host and Space commit, so a reload during manual evidence capture can restore rows from the same deployed build; **Clear** removes both the visible rows and the saved copy.
|
| 108 |
|
| 109 |
Use `node tools/audit-browser-evidence.mjs path/to/browser-speak-benchmarks.json` to audit a JSON file downloaded from the hosted browser UI. This checks that the export came from the static Space revision, reports the page-generated `evidence` summary, verifies that at least three real-mic rows meet the WER/identity/latency gates from raw rows, and verifies that at least one completed row reports hardware WebGPU rather than a software adapter. Browser-downloaded JSON cannot prove no-server network behavior or Chrome launch flags by itself, so pair it with `node tools/run-hosted-smoke.mjs` for network evidence or `node tools/run-real-mic-series.mjs` for harness-collected real-mic provenance.
|
| 110 |
|
| 111 |
+
When served from localhost or the hosted Hugging Face Space, the page installs `window.browserSpeakBench` for browser automation. It exposes `loadStack(options)`, `setRuntimeOptions(options)`, `preloadVoice(options)`, `runSuite()`, `runMicSeries()`, `runEvidenceCapture()`, one-off runners such as `runTts()`, `runLoopback()`, and `runWebGpuEvidence()`, `exportResults()`, `downloadResults(options)`, `clearResults()`, `webgpuInfo()`, and `state()`. This lets a Playwright, Puppeteer, or DevTools Protocol harness drive the same UI-backed benchmark paths and collect the same JSON as **Copy JSON**. `setRuntimeOptions()` and `loadStack()` also accept `ttsChunking` so first-response chunk thresholds can be benchmarked without editing source; the exported stack records the active chunk profile. The helper `node tools/run-fake-mic-benchmark.mjs` synthesizes the scripted prompt with local Supertonic, relaunches Chrome with that WAV as `--use-file-for-fake-audio-capture`, and runs three scripted mic rows through getUserMedia, the audio worklet, VAD, STT, LLM, and TTS. Set `BROWSER_SPEAK_REUSE_FAKE_MIC_WAV=true` to reuse an existing fixture WAV and skip the synthesis/load pass during regression checks; row timeouts can be adjusted with `BROWSER_SPEAK_FAKE_MIC_TURN_TIMEOUT_MS` and `BROWSER_SPEAK_FAKE_MIC_ROW_TIMEOUT_MS`. The CDP harnesses use a 60-second protocol watchdog by default, configurable with `BROWSER_SPEAK_CDP_TIMEOUT_MS`, short 5-second status-poll watchdogs, configurable with `BROWSER_SPEAK_CDP_POLL_TIMEOUT_MS`, and a page-unresponsive watchdog, configurable with `BROWSER_SPEAK_PAGE_UNRESPONSIVE_TIMEOUT_MS`, so a slow or wedged browser target produces a controlled failure and cleanup instead of blocking indefinitely. A fake capture file is useful for regression testing the mic pipeline, but real microphone rows are still required before judging conversational quality.
|
| 112 |
|
| 113 |
Use `node tools/run-ui-smoke.mjs` for a fast desktop/mobile UI check before or after model benchmarks. It loads the static page in Chrome, waits for the runtime/WebGPU status to settle, verifies the automation API and key controls, checks for body or visible element overflow outside the intentionally scrollable benchmark table, and writes `/tmp/browser-speak-ui-smoke.json` plus screenshots in `/tmp/browser-speak-ui-smoke`. Override with `BROWSER_SPEAK_UI_VIEWPORTS`, `BROWSER_SPEAK_UI_JSON`, `BROWSER_SPEAK_UI_SCREENSHOT_DIR`, `BROWSER_SPEAK_URL`, `BROWSER_SPEAK_HEADLESS=false`, `BROWSER_SPEAK_CHROME_ARGS`, or `CHROME_BIN`.
|
| 114 |
|
app.js
CHANGED
|
@@ -1853,18 +1853,21 @@ function benchmarkExportPayload() {
|
|
| 1853 |
};
|
| 1854 |
}
|
| 1855 |
|
| 1856 |
-
function downloadBenchmarkJson(
|
|
|
|
|
|
|
|
|
|
| 1857 |
const payload = JSON.stringify(benchmarkExportPayload(), null, 2);
|
| 1858 |
const blob = new Blob([`${payload}\n`], { type: "application/json" });
|
| 1859 |
const url = URL.createObjectURL(blob);
|
| 1860 |
const anchor = document.createElement("a");
|
| 1861 |
anchor.href = url;
|
| 1862 |
-
anchor.download = `
|
| 1863 |
document.body.append(anchor);
|
| 1864 |
anchor.click();
|
| 1865 |
anchor.remove();
|
| 1866 |
window.setTimeout(() => URL.revokeObjectURL(url), 1000);
|
| 1867 |
-
logEvent(
|
| 1868 |
}
|
| 1869 |
|
| 1870 |
function benchmarkSummariesByStack() {
|
|
@@ -2461,7 +2464,7 @@ async function runHardwareWebGpuEvidenceBenchmark() {
|
|
| 2461 |
return runBenchmark();
|
| 2462 |
}
|
| 2463 |
|
| 2464 |
-
async function runEvidenceCaptureSequence() {
|
| 2465 |
if (evidenceCaptureBusy()) {
|
| 2466 |
logEvent("Finish the current run before starting evidence capture.");
|
| 2467 |
return false;
|
|
@@ -2516,9 +2519,19 @@ async function runEvidenceCaptureSequence() {
|
|
| 2516 |
if (!evidence.hardwareWebgpu.passed) missing.push("hardware WebGPU");
|
| 2517 |
logEvent(
|
| 2518 |
missing.length === 0
|
| 2519 |
-
?
|
| 2520 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2521 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2522 |
return true;
|
| 2523 |
} catch (error) {
|
| 2524 |
if (state.micSeries.active) cancelMicSeries();
|
|
@@ -2954,11 +2967,20 @@ function installAutomationApi() {
|
|
| 2954 |
runLoopback: (options) => runSingleAutomationBenchmark(runLoopbackBenchmark, options),
|
| 2955 |
runBargeIn: (options) => runSingleAutomationBenchmark(runBargeInBenchmark, options),
|
| 2956 |
runWebGpuEvidence: (options) => runSingleAutomationBenchmark(runHardwareWebGpuEvidenceBenchmark, options),
|
| 2957 |
-
async runEvidenceCapture() {
|
| 2958 |
-
const started = await runEvidenceCaptureSequence(
|
|
|
|
|
|
|
| 2959 |
if (!started) throw new Error("Evidence capture did not start.");
|
| 2960 |
return automationSnapshot();
|
| 2961 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2962 |
runMic: (options) => runSingleAutomationBenchmark(runMicBenchmark, options),
|
| 2963 |
runMicSeries: runAutomationMicSeries,
|
| 2964 |
synthesizeAudio: synthesizeAutomationAudio,
|
|
@@ -3011,7 +3033,9 @@ elements.gpuBenchmarkButton.addEventListener("click", () => {
|
|
| 3011 |
runHardwareWebGpuEvidenceBenchmark().catch((error) => logEvent(`WebGPU evidence failed: ${error.message}`));
|
| 3012 |
});
|
| 3013 |
elements.evidenceCaptureButton.addEventListener("click", () => {
|
| 3014 |
-
runEvidenceCaptureSequence().catch((error) =>
|
|
|
|
|
|
|
| 3015 |
});
|
| 3016 |
elements.micBenchmarkButton.addEventListener("click", runMicBenchmark);
|
| 3017 |
elements.micSeriesButton.addEventListener("click", runMicSeriesBenchmark);
|
|
|
|
| 1853 |
};
|
| 1854 |
}
|
| 1855 |
|
| 1856 |
+
function downloadBenchmarkJson({
|
| 1857 |
+
prefix = "browser-speak-benchmarks",
|
| 1858 |
+
message = "Benchmark JSON download started.",
|
| 1859 |
+
} = {}) {
|
| 1860 |
const payload = JSON.stringify(benchmarkExportPayload(), null, 2);
|
| 1861 |
const blob = new Blob([`${payload}\n`], { type: "application/json" });
|
| 1862 |
const url = URL.createObjectURL(blob);
|
| 1863 |
const anchor = document.createElement("a");
|
| 1864 |
anchor.href = url;
|
| 1865 |
+
anchor.download = `${prefix}-${new Date().toISOString().replace(/[:.]/g, "-")}.json`;
|
| 1866 |
document.body.append(anchor);
|
| 1867 |
anchor.click();
|
| 1868 |
anchor.remove();
|
| 1869 |
window.setTimeout(() => URL.revokeObjectURL(url), 1000);
|
| 1870 |
+
logEvent(message);
|
| 1871 |
}
|
| 1872 |
|
| 1873 |
function benchmarkSummariesByStack() {
|
|
|
|
| 2464 |
return runBenchmark();
|
| 2465 |
}
|
| 2466 |
|
| 2467 |
+
async function runEvidenceCaptureSequence({ autoDownload = false } = {}) {
|
| 2468 |
if (evidenceCaptureBusy()) {
|
| 2469 |
logEvent("Finish the current run before starting evidence capture.");
|
| 2470 |
return false;
|
|
|
|
| 2519 |
if (!evidence.hardwareWebgpu.passed) missing.push("hardware WebGPU");
|
| 2520 |
logEvent(
|
| 2521 |
missing.length === 0
|
| 2522 |
+
? autoDownload
|
| 2523 |
+
? "Evidence capture complete; starting JSON download."
|
| 2524 |
+
: "Evidence capture complete; use Download JSON to save the proof."
|
| 2525 |
+
: autoDownload
|
| 2526 |
+
? `Evidence capture finished; still missing ${missing.join(" and ")} evidence. Starting JSON download with current rows.`
|
| 2527 |
+
: `Evidence capture finished; still missing ${missing.join(" and ")} evidence. Use Download JSON to save current rows.`,
|
| 2528 |
);
|
| 2529 |
+
if (autoDownload && state.benchmarkResults.length > 0) {
|
| 2530 |
+
downloadBenchmarkJson({
|
| 2531 |
+
prefix: "browser-speak-evidence",
|
| 2532 |
+
message: "Evidence JSON download started.",
|
| 2533 |
+
});
|
| 2534 |
+
}
|
| 2535 |
return true;
|
| 2536 |
} catch (error) {
|
| 2537 |
if (state.micSeries.active) cancelMicSeries();
|
|
|
|
| 2967 |
runLoopback: (options) => runSingleAutomationBenchmark(runLoopbackBenchmark, options),
|
| 2968 |
runBargeIn: (options) => runSingleAutomationBenchmark(runBargeInBenchmark, options),
|
| 2969 |
runWebGpuEvidence: (options) => runSingleAutomationBenchmark(runHardwareWebGpuEvidenceBenchmark, options),
|
| 2970 |
+
async runEvidenceCapture(options = {}) {
|
| 2971 |
+
const started = await runEvidenceCaptureSequence({
|
| 2972 |
+
autoDownload: options.autoDownload === true,
|
| 2973 |
+
});
|
| 2974 |
if (!started) throw new Error("Evidence capture did not start.");
|
| 2975 |
return automationSnapshot();
|
| 2976 |
},
|
| 2977 |
+
downloadResults(options = {}) {
|
| 2978 |
+
downloadBenchmarkJson({
|
| 2979 |
+
prefix: options.prefix ?? "browser-speak-benchmarks",
|
| 2980 |
+
message: options.message ?? "Benchmark JSON download started.",
|
| 2981 |
+
});
|
| 2982 |
+
return automationSnapshot();
|
| 2983 |
+
},
|
| 2984 |
runMic: (options) => runSingleAutomationBenchmark(runMicBenchmark, options),
|
| 2985 |
runMicSeries: runAutomationMicSeries,
|
| 2986 |
synthesizeAudio: synthesizeAutomationAudio,
|
|
|
|
| 3033 |
runHardwareWebGpuEvidenceBenchmark().catch((error) => logEvent(`WebGPU evidence failed: ${error.message}`));
|
| 3034 |
});
|
| 3035 |
elements.evidenceCaptureButton.addEventListener("click", () => {
|
| 3036 |
+
runEvidenceCaptureSequence({ autoDownload: true }).catch((error) =>
|
| 3037 |
+
logEvent(`Evidence capture failed: ${error.message}`),
|
| 3038 |
+
);
|
| 3039 |
});
|
| 3040 |
elements.micBenchmarkButton.addEventListener("click", runMicBenchmark);
|
| 3041 |
elements.micSeriesButton.addEventListener("click", runMicSeriesBenchmark);
|