browser audio detection phase 3

This commit is contained in:
Joren de Graaf
2026-10-02 21:34:38 +02:00
parent ff0d78ccba
commit 9ff8bf8c26
50 changed files with 24755 additions and 144 deletions
@@ -0,0 +1,17 @@
export class BrowserSubmissionGate {
static evaluate(predictions, policy) {
console.log("[BoomCast][Gate] Evaluating browser classification.");
const relevant = new Set((policy.whitelist || []).map((name) => name.toLowerCase()));
const speechNames = new Set((policy.privacy_sensitive_speech || []).map((name) => name.toLowerCase()));
const matchThreshold = Number(policy.thresholds?.relevance ?? 0.5);
const speechThreshold = Number(policy.thresholds?.speech ?? 0.5);
const matches = predictions.filter((item) => relevant.has(item.class.toLowerCase()) && item.score >= matchThreshold);
const speechDetected = predictions.some((item) => speechNames.has(item.class.toLowerCase()) && item.score >= speechThreshold);
console.log("[BoomCast][Gate] Relevant whitelist matches:", matches);
console.log("[BoomCast][Gate] Speech detected:", speechDetected);
const result = matches.length ? "whitelist_match" : speechDetected ? "speech_only" : "no_match";
console.log(`[BoomCast][Gate] Decision: ${result.toUpperCase()}`);
if (result !== "whitelist_match") console.log("[BoomCast][Gate] Automatic upload suppressed.");
return { result, speechDetected, matches };
}
}