@chatpanel/events 0.456.0 → 0.457.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/voice-signature.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatpanel/events",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.457.0",
|
|
4
4
|
"description": "The canonical ChatPanel event-log and capability contracts — typed durable facts, clock-free deterministic linearization, schema upcasting, and the invariants the replay harness asserts. Pure, dependency-free ESM shared by the ChatPanel extension, gateway and bridge.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
package/voice-signature.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cosine as
|
|
1
|
+
import{cosine as f,speakerThreshold as g}from"./speaker-cluster.js";const w=Object.freeze(["Hey Chap, what is on my calendar for tomorrow morning?","Remind me to call the dentist when I get home tonight.","Summarize my notes from the meeting about the new design.","What is the weather going to be like this weekend?","Read me the last message from my team, and then play some music."]),c=3,i=8,m=1,a=e=>{const t=Math.sqrt(e.reduce((r,n)=>r+n*n,0));return t?e.map(r=>r/t):e};function y(e=[]){const t=(Array.isArray(e)?e:[]).filter(o=>Array.isArray(o?.vec)&&o.vec.length&&(Number(o.seconds)||0)>=m),r=t.reduce((o,l)=>o+Number(l.seconds),0);if(t.length<c||r<i)return{error:`Read at least ${c} sentences (${Math.round(r)} of ${i} seconds so far).`};const n=t[0].vec.length,s=new Array(n).fill(0);for(const o of t){if(o.vec.length!==n)continue;const l=a(o.vec.map(Number));for(let h=0;h<n;h++)s[h]+=l[h]}return{vec:a(s).map(o=>Math.round(o*1e5)/1e5),n:t.length,seconds:Math.round(r*10)/10}}function M(e,t,{threshold:r=g()}={}){if(!t?.vec?.length||!Array.isArray(e)||e.length!==t.vec.length)return{me:null,score:null};const n=f(e,t.vec);return{me:n>=r,score:Math.round(n*1e3)/1e3}}const u=e=>String(e||"").toLowerCase().replace(/[’']/g,"").match(/[\p{L}\p{N}]+/gu)||[];function d(e,t){if(e===t)return!0;if(e.length<4||t.length<4||Math.abs(e.length-t.length)>1)return!1;let r=0,n=0,s=0;for(;r<e.length&&n<t.length;){if(e[r]===t[n]){r++,n++;continue}if(++s>1)return!1;e.length>t.length?r++:(t.length>e.length||r++,n++)}return s+(e.length-r)+(t.length-n)<=1}function N(e,t){const r=u(e);let n=0;for(const s of u(t))for(let o=n;o<Math.min(r.length,n+3);o++)if(d(r[o],s)){n=o+1;break}return{read:n,total:r.length}}export{w as ENROLL_PHRASES,c as MIN_ENROLL_SAMPLES,i as MIN_ENROLL_SECONDS,m as MIN_SAMPLE_SECONDS,y as enrollPrint,M as matchPrint,N as readThrough};
|