From 084401624bbdcb5f1348b758d301892be2719092 Mon Sep 17 00:00:00 2001 From: sascha Date: Fri, 7 Aug 2026 15:56:21 +0200 Subject: [PATCH] =?UTF-8?q?lab:=20vpcos.mjs=20=E2=80=94=20Kosinus=20zwisch?= =?UTF-8?q?en=20gespeicherten=20Stimmabdruecken=20messen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/lab/vpcos.mjs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 app/lab/vpcos.mjs diff --git a/app/lab/vpcos.mjs b/app/lab/vpcos.mjs new file mode 100644 index 0000000..63bd4b1 --- /dev/null +++ b/app/lab/vpcos.mjs @@ -0,0 +1,13 @@ +import { pool } from "/opt/callrec/db.js"; +const [rows] = await pool.query("SELECT id,name,vec FROM voiceprints"); +const V = rows.map(r => ({ id: r.id, name: r.name, v: typeof r.vec === "string" ? JSON.parse(r.vec) : r.vec })); +const cos = (a,b) => { let d=0,na=0,nb=0; for (let i=0;i n.toLowerCase().split(/\s+/)[0]; +const pairs = []; +for (let i=0;i= 0.6) pairs.push({ a: V[i].name, b: V[j].name, c: +c.toFixed(3), sameFirst: first(V[i].name)===first(V[j].name) }); +} +pairs.sort((x,y)=>y.c-x.c); +for (const p of pairs) console.log(`${p.c} ${p.sameFirst ? "gleicher Vorname" : "nur Kosinus "} ${p.a} <-> ${p.b}`); +process.exit(0);