Elffuss BraidHub

utopia-ia/elffuss-translator public

Live audio skills with their own surface, and an English README

- Skill picker: sales copilot, customer card, meeting facilitator, summary.
  Each one listens to the conversation and works while you talk.
- A skill's view is projected from Claw and rendered inside the translator in
  a sandboxed iframe, next to the subtitles — a real split screen instead of
  two disconnected windows.
- The customer card and the facilitator export what they captured as CSV.
- Never pause the audio while a live skill is running: opening the skill
  window made the browser mark the tab as hidden, which suspended capture and
  left the app deaf.
- README rewritten in English, and the demo is labelled for what it is: a
  staged recreation of the flow, not a screen recording.
Changesetd086819343903ac6569a7eea338dafc6289fddeff30c5ea92e461283c844b5d9
AuthorKikoCis <kikocisneros@gmail.com> · 2026-08-14 16:52 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-08-14 16:52 +02:00
Parents97412e6712c4

Browse the files at this changeset

2 files changed

modified README.md +81 −45
@@ -2,95 +2,131 @@
22
33 # Elffuss Translator
44
5-**Traducción de conversaciones en tiempo real, 100 % en tu navegador.**
5+**Real-time conversation translation, 100% in your browser.**
66
7-Escucha, distingue quién habla, traduce y responde por voz.
8-Sin servidor, sin cuenta, sin API de pago — nada de lo que digas sale de tu máquina.
7+It listens, tells speakers apart, translates and speaks back.
8+No server, no account, no paid API — nothing you say ever leaves your machine.
99
10-[**▶ Abrir la app**](https://translator.elffuss.utopiaia.com) · [Elffuss](https://elffuss.utopiaia.com) · Apache-2.0
10+[**▶ Open the app**](https://translator.elffuss.utopiaia.com) · [Elffuss](https://elffuss.utopiaia.com) · Apache-2.0
1111
1212 </div>
1313
1414 ---
1515
16-## El copiloto en vivo
16+## Live skills: a meeting facilitator that costs nothing
1717
18-El translator no solo traduce: puede **pasarle la conversación a [Elffuss Claw](https://github.com/KikoCis/elffuss-claw)**, que actúa de copiloto y te va soplando qué decir mientras hablas. Un vendedor habla español, el cliente inglés, y en la otra ventana los objetivos de la llamada se van cumpliendo solos.
18+The translator does more than translate. It can hand the conversation to
19+[Elffuss Claw](https://github.com/KikoCis/elffuss-claw), which runs a **live audio skill**
20+and works while you talk. Pick one when you hit **Skills en vivo**:
1921
20-![Demo: llamada de ventas con traducción en vivo y copiloto](docs/demo.gif)
22+| | Skill | What it does |
23+|---|---|---|
24+| 🎯 | **Sales copilot** | Feeds you the exact line to say and tracks the call's objectives. |
25+| 📇 | **Customer card** | Fills a customer record by itself from what the client says. Exports to Excel. |
26+| 🧑‍🏫 | **Meeting facilitator** | Topics, decisions and action items, live. Exports. |
27+| 📝 | **Summary & ideas** | A running summary plus the ideas that come up. |
28+
29+Each skill paints its own **surface**: a live view that renders *inside the translator*,
30+next to the subtitles — not just a notification. It updates as the conversation goes on
31+and, where it makes sense, exports what it captured as a spreadsheet.
32+
33+![Demo: sales call with live translation and the copilot surface](docs/demo.gif)
2134
2235 <div align="center"><sub>
2336
24-Demo guionizada para enseñar el flujo · [vídeo completo con audio](docs/demo.mp4)
37+**Staged recreation** of the flow (scripted dialogue and timings), not a screen recording of a live run ·
38+[full video with audio](docs/demo.mp4)
2539
2640 </sub></div>
2741
28-Los dos dominios son distintos, así que la tubería va por `postMessage` con validación de origen: el translator manda cada intervención (`[Hablante N] …`), Claw responde con una línea accionable y el estado de los objetivos, y el consejo vuelve a aparecer sobre los subtítulos.
42+Skills are defined as plain `SKILL.md` files and are **self-editing**: ask in Claw's chat for
43+"add an email field" or "keep the advice shorter" and the skill rewrites itself.
44+
45+## How the surface gets there
46+
47+The two apps live on different origins, so the pipe is `postMessage` with origin checks on
48+both ends. The skill's view is **projected** from Claw into the translator and rendered in a
49+sandboxed iframe (`allow-scripts` only — never `allow-same-origin`, so it can't reach back
50+into the page that hosts it):
2951
30-## Qué hace
52+```
53+translator ──[hablante + texto]──▶ Claw ──▶ model ──▶ CONSEJO / DATOS
54+ ▲ │
55+ └───[surface html + state]────────┘ (rendered sandboxed, right-hand panel)
56+```
3157
32-- **Modo conversación**: un solo micrófono, manos libres. Detecta los turnos por energía, separa **quién habla** por su voz y enruta cada turno al idioma del otro.
33-- **Subtítulos** con el original y la traducción debajo, creciendo hacia abajo como en una llamada real.
34-- **Voz**: lee la traducción en alto — o la silencias con un botón y sigue traduciendo y subtitulando igual.
35-- **Medio dúplex**: mientras habla, no se escucha a sí mismo. Sin esto, entra en bucle traduciendo su propia voz.
36-- **Ahorro de batería**: en segundo plano se pausa; al volver, se recupera solo.
37-- **Offline de verdad**: descargas los modelos una vez, quedan cacheados y luego funciona sin red.
58+This is written up as a small spec — see **[Skill Surface Protocol](https://github.com/KikoCis/elffuss-claw)**.
3859
39-## El stack, todo ONNX en el navegador
60+## What it does
4061
41-| Pieza | Modelo |
62+- **Conversation mode**: one microphone, hands free. It finds the turns by energy, tells
63+ **who is speaking** from their voice, and routes each turn into the other language.
64+- **Subtitles** with the original and the translation underneath, growing downward like a real call.
65+- **Voice**: reads the translation out loud — or mute it and keep translating and subtitling.
66+- **Half duplex**: it doesn't listen to itself while speaking. Without this it loops, translating its own voice.
67+- **Battery aware**: pauses in the background and recovers on its own (and never pauses while a live skill is running).
68+- **Actually offline**: download the models once, they stay cached, and it works with no network.
69+
70+## The stack, all ONNX in the browser
71+
72+| Piece | Model |
4273 |---|---|
43-| **ASR** | `whisper-base` (WebGPU con caída a WASM) |
44-| **Diarización** | `pyannote-segmentation-3.0` (habla/silencio) + `wespeaker-voxceleb-resnet34-LM` (embeddings de hablante) |
45-| **Traducción** | Translator API on-device del navegador, con `opus-mt` (transformers.js) de reserva |
46-| **Voz** | `speechSynthesis` del sistema |
74+| **ASR** | `whisper-base` (WebGPU, falls back to WASM) |
75+| **Diarization** | `pyannote-segmentation-3.0` (speech/silence) + `wespeaker-voxceleb-resnet34-LM` (speaker embeddings) |
76+| **Translation** | The browser's on-device Translator API, with `opus-mt` (transformers.js) as fallback |
77+| **Voice** | The system's `speechSynthesis` |
4778
48-Corre sobre [transformers.js](https://github.com/huggingface/transformers.js) y ONNX Runtime Web. Sin framework y sin *build*: HTML y ES modules, se sirve como ficheros estáticos.
79+Runs on [transformers.js](https://github.com/huggingface/transformers.js) and ONNX Runtime Web.
80+No framework and no build step: HTML and ES modules, served as static files.
4981
50-## Cómo funciona la diarización
82+## Using the diarizer on its own
5183
52-`diarize.mjs` es autónomo y se puede usar suelto:
84+`diarize.mjs` is standalone:
5385
5486 ```js
55-import { loadDiarizer, diarize, makeSpeakerBook } from './diarize.mjs';
87+import { loadDiarizer, diarize, makeSpeakerBook, speakerVec } from './diarize.mjs';
5688
5789 const D = await loadDiarizer(transformers, { device: 'webgpu' });
5890
59-// (a) troceado por turnos de un audio ya grabado
60-const turns = await diarize(D, audio16k); // [{ start, end, speaker }]
91+// (a) split a recorded clip into turns
92+const turns = await diarize(D, audio16k); // [{ start, end, speaker }]
6193
62-// (b) en vivo: asigna cada fragmento a un hablante estable
94+// (b) live: assign each chunk to a stable speaker
6395 const book = makeSpeakerBook({ tau: 0.5, maxSpeakers: 2 });
64-const { label } = book.assign(await speakerVec(D, fragmento16k)); // 'S1' | 'S2'
96+const { label } = book.assign(await speakerVec(D, chunk16k)); // 'S1' | 'S2'
6597 ```
6698
67-Segmentación → embeddings por sub-ventana → agrupación por coseno. Dos fragmentos del mismo hablante rondan 0.8 de similitud; de hablantes distintos, ~0.15.
68-
69-## Bordes honestos
99+Segmentation → per-window embeddings → cosine clustering. Two chunks from the same speaker
100+land around 0.8 similarity; different speakers, about 0.15.
70101
71-- **La primera carga son megas.** Le mandas el modelo al usuario una vez; después vive en caché.
72-- **Separar voces simultáneas en un micro mono no es fiable**: el hablante más fuerte domina el embedding. La diarización **por turnos** sí funciona; para solapamiento real hace falta una captura por interlocutor.
73-- **Whisper alucina con el silencio.** Hay un umbral de energía y un filtro de muletillas típicas ("Subtítulos por…"), pero alguna se cuela.
74-- **Chrome/Edge** para WebGPU. Sin él cae a CPU y va más lento.
75-- La calidad de la voz es la del sistema operativo, que varía bastante entre idiomas.
102+## Honest edges
76103
77-## Ficheros
104+- **The first load is a download.** You ship the model to the user once; after that it lives in cache.
105+- **Separating simultaneous voices on a mono mic is not reliable** — the louder speaker dominates the
106+ embedding. Turn-by-turn diarization does work; real overlap needs one capture per speaker.
107+- **Whisper hallucinates on silence.** There's an energy gate and a filter for the usual filler
108+ ("Subtitles by…"), but some still slips through.
109+- **Chrome/Edge** for WebGPU. Without it, it falls back to CPU and gets slower.
110+- Voice quality is whatever the operating system provides, which varies a lot by language.
111+
112+## Files
78113
79114 | | |
80115 |---|---|
81-| `index.html` | La app completa: UI, captura, pipeline y tubería con Claw. |
82-| `diarize.mjs` | Motor de diarización (segmentación + embeddings + clustering). |
116+| `index.html` | The whole app: UI, capture, pipeline, live-skill picker and the pipe to Claw. |
117+| `diarize.mjs` | Diarization engine (segmentation + embeddings + clustering). |
83118
84-## Servirlo tú mismo
119+## Hosting it yourself
85120
86-Son ficheros estáticos; cualquier servidor vale. Un único cuidado: **los `.mjs` deben servirse como JavaScript**, o el navegador bloquea el módulo. En nginx:
121+Static files; any server works. One catch: **`.mjs` must be served as JavaScript**, or the
122+browser refuses the module. In nginx:
87123
88124 ```nginx
89125 location ~ \.mjs$ { default_type text/javascript; }
90126 ```
91127
92-Y conviene servirlo por HTTPS: el micrófono y WebGPU lo exigen fuera de `localhost`.
128+Serve it over HTTPS — the microphone and WebGPU require it outside `localhost`.
93129
94-## Licencia
130+## License
95131
96132 Apache-2.0.
modified index.html +85 −13
@@ -91,6 +91,28 @@
9191 .dlsub{font-size:.72rem;color:var(--ok);margin-bottom:10px;text-transform:uppercase;letter-spacing:.08em}
9292 .dlfile{font-size:.7rem;color:var(--mut);font-family:ui-monospace,monospace;min-height:1.1em;word-break:break-all}
9393 .dlbytes{font-size:.82rem;color:#c3c9d0;margin-top:2px}
94+
95+ /* superficie proyectada (pantalla partida real) */
96+ body.withsurface #convo{flex-direction:row}
97+ .convmain{display:flex;flex-direction:column;min-width:0;flex:1}
98+ #surface{flex:0 0 40%;max-width:520px;border-left:1px solid var(--line);display:none;position:relative}
99+ body.withsurface #surface{display:block}
100+ #surface iframe{width:100%;height:100%;border:0;display:block;background:var(--bg)}
101+ #surfClose{position:absolute;top:8px;right:10px;z-index:3;background:rgba(9,10,17,.7);color:var(--mut);border:1px solid var(--line);border-radius:5px;font-size:.68rem;padding:3px 8px;cursor:pointer}
102+ #surfClose:hover{color:var(--fg)}
103+ @media(max-width:900px){ body.withsurface #convo{flex-direction:column} #surface{flex:0 0 46%;max-width:none;border-left:0;border-top:1px solid var(--line)} }
104+ .skpick{position:fixed;inset:0;background:rgba(6,8,11,.86);display:flex;align-items:center;justify-content:center;padding:20px;z-index:60}
105+ .skpick[hidden]{display:none}
106+ .skpick .card{background:var(--panel);border:1px solid var(--line);border-radius:16px;max-width:560px;width:100%;padding:28px}
107+ .skpick h2{font-family:var(--serif);font-size:1.4rem;margin-bottom:6px}
108+ .skpick .lead{color:var(--mut);font-size:.86rem;margin-bottom:20px;line-height:1.5}
109+ .skgrid{display:grid;gap:10px}
110+ .skitem{display:flex;gap:13px;align-items:flex-start;text-align:left;padding:14px;border:1px solid var(--line);border-radius:11px;background:transparent;color:var(--fg);cursor:pointer;font:inherit;transition:border-color .3s,transform .3s,background .3s}
111+ .skitem:hover{border-color:var(--accent);transform:translateY(-2px);background:rgba(200,160,106,.05)}
112+ .skitem .ico{font-size:1.3rem;line-height:1}
113+ .skitem b{display:block;font-size:.95rem;margin-bottom:3px}
114+ .skitem span{color:var(--mut);font-size:.79rem;line-height:1.4}
115+ .skpick .cancel{margin-top:16px;width:100%;background:transparent;color:var(--mut);border:1px solid var(--line);border-radius:8px;padding:10px;font:inherit;font-size:.82rem;cursor:pointer}
94116 </style>
95117 </head>
96118 <body>
@@ -120,9 +142,10 @@
120142
121143 <!-- CONVERSACIÓN -->
122144 <main id="convo" class="screen" hidden>
145+ <div class="convmain">
123146 <div class="convtop">
124147 <span class="pair" id="pairLabel">—</span>
125- <button id="copilot" class="toggle paused" title="Abre Claw y te sopla argumentos de venta en vivo">Copiloto</button>
148+ <button id="copilot" class="toggle paused" title="Skills que escuchan la conversación y trabajan mientras hablas">Skills en vivo</button>
126149 <button id="mute" class="toggle" title="Silenciar la voz: sigue traduciendo y mostrando subtítulos, pero sin hablar">🔊 Voz</button>
127150 <button id="toggle" class="toggle">Parar</button>
128151 </div>
@@ -130,6 +153,8 @@
130153 <div class="status" id="status">Escuchando…</div>
131154 <div class="advice" id="advice" hidden><div class="box"><span class="k">Copiloto</span><span class="t"></span></div></div>
132155 <div class="subs" id="log"><div class="empty" id="emptyMsg">Habla y aparecerá aquí, con la traducción debajo.</div></div>
156+ </div>
157+ <aside id="surface"><button id="surfClose" title="Cerrar la vista">✕ vista</button><iframe id="surfFrame" sandbox="allow-scripts allow-downloads" title="Vista de la skill"></iframe></aside>
133158 </main>
134159
135160 <footer>La versión navegador de la Gemma Translator: local, offline, sin cuenta. · Código abierto en <a href="https://github.com/KikoCis/elffuss-translator" target="_blank" rel="noopener">GitHub</a> · <a href="https://elffuss.utopiaia.com" target="_blank" rel="noopener">elffuss</a></footer>
@@ -160,6 +185,14 @@
160185 </div>
161186 </div>
162187
188+
189+<!-- selector de skills de audio en vivo -->
190+<div class="skpick" id="skPick" hidden><div class="card">
191+ <h2>Skills en vivo</h2>
192+ <p class="lead">Elffuss escucha la conversación y trabaja mientras hablas. Elige qué quieres que haga — todo en tu navegador, sin cuota.</p>
193+ <div class="skgrid" id="skGrid"></div>
194+ <button class="cancel" id="skCancel">Ahora no</button>
195+</div></div>
163196 <script type="module">
164197 import { loadDiarizer, speakerVec, makeSpeakerBook } from './diarize.mjs';
165198 const LANGS=[['es','Español'],['en','English'],['fr','Français'],['de','Deutsch'],['it','Italiano'],['pt','Português'],['ca','Català'],['nl','Nederlands'],['ru','Русский'],['uk','Українська']];
@@ -321,7 +354,9 @@
321354 lastAudioTs=Date.now();
322355 clearInterval(convWatch);
323356 convWatch=setInterval(()=>{
324- if(!convOn||document.hidden) return;
357+ if(!convOn) return;
358+ const copilotOpen = !!(copilotWin && !copilotWin.closed);
359+ if(document.hidden && !copilotOpen) return; // en 2º plano de verdad: no tocar
325360 // Quedó marcado como pausado pero la ventana YA se ve (pasa al abrir el
326361 // copiloto: Chrome oculta la ventana tapada y luego no siempre reanuda):
327362 // reconstruir en vez de quedarse mudo para siempre.
@@ -373,8 +408,10 @@
373408 addEventListener('message', e=>{ if(e.origin!==CLAW || !e.data) return;
374409 if(e.data.kind==='copilot-ready'){ copilotReady=true;
375410 const sc=$('langA').value, sn=(LANGS.find(l=>l[0]===sc)||[])[1]||sc, oc=$('langB').value, on=(LANGS.find(l=>l[0]===oc)||[])[1]||oc;
376- try{ copilotWin.postMessage({kind:'copilot-init', sellerLangName:sn, sellerCode:sc, clientLangName:on},CLAW); }catch{}
411+ try{ copilotWin.postMessage({kind:'copilot-init', skill:pickedSkill, sellerLangName:sn, sellerCode:sc, clientLangName:on},CLAW); }catch{}
377412 copilotBuf.forEach(t=>{ try{copilotWin.postMessage(t,CLAW);}catch{} }); copilotBuf=[]; }
413+ else if(e.data.kind==='surface' && typeof e.data.html==='string'){ showSurface(e.data.html); }
414+ else if(e.data.kind==='surface-state'){ try{ $('surfFrame').contentWindow?.postMessage({type:'surface-state',id:e.data.id,data:e.data.data,advice:e.data.advice},'*'); }catch{} }
378415 else if(e.data.kind==='copilot-advice'){
379416 // El modelo suele devolver el guion ENTRE COMILLAS ("—"), y así se colaba
380417 // como si fuera un consejo. Limpiar comillas/espacios y descartar si queda vacío.
@@ -383,21 +420,52 @@
383420 });
384421 function copilotSend(speaker,text){ if(!copilotWin||copilotWin.closed) return; const msg={kind:'transcript',speaker,text};
385422 if(copilotReady){ try{copilotWin.postMessage(msg,CLAW);}catch{} } else copilotBuf.push(msg); }
386-function copilotReset(){ copilotWin=null; copilotReady=false; copilotBuf=[]; $('copilot').classList.remove('on'); $('copilot').textContent='Copiloto'; }
387-$('copilot').onclick=()=>{
388- if(copilotWin && !copilotWin.closed){ try{copilotWin.close();}catch{} copilotReset(); return; } // toggle: si está abierto, ciérralo
423+function copilotReset(){ copilotWin=null; copilotReady=false; copilotBuf=[]; $('copilot').classList.remove('on'); $('copilot').textContent='Skills en vivo'; }
424+// Catálogo de skills de audio en vivo (el «facilitador», pero local y gratis).
425+const AUDIO_SKILLS=[
426+ {id:'ventas',icon:'🎯',name:'Copiloto de ventas',desc:'Te sopla el argumento exacto y marca los objetivos de la llamada.'},
427+ {id:'ficha',icon:'📇',name:'Ficha de cliente',desc:'Rellena la ficha sola con lo que dice el cliente. Se exporta a Excel.'},
428+ {id:'facilitador',icon:'🧑‍🏫',name:'Facilitador de reunión',desc:'Temas, decisiones y tareas en vivo. Se exporta.'},
429+ {id:'resumen',icon:'📝',name:'Resumen e ideas',desc:'Resumen progresivo y las ideas que van saliendo.'},
430+];
431+let pickedSkill='ventas';
432+function openSkillPicker(){
433+ const g=$('skGrid'); g.replaceChildren();
434+ for(const sk of AUDIO_SKILLS){
435+ const b=document.createElement('button'); b.className='skitem'; b.type='button';
436+ b.innerHTML='<span class="ico"></span><span class="txt"><b></b><span class="d"></span></span>';
437+ b.querySelector('.ico').textContent=sk.icon;
438+ b.querySelector('b').textContent=sk.name;
439+ b.querySelector('.d').textContent=sk.desc;
440+ b.onclick=()=>{ $('skPick').hidden=true; pickedSkill=sk.id; launchCopilot(sk.id); };
441+ g.appendChild(b);
442+ }
443+ $('skPick').hidden=false;
444+}
445+$('skCancel').onclick=()=>{ $('skPick').hidden=true; };
446+
447+function launchCopilot(skill){
389448 copilotReady=false; copilotBuf=[];
390- // Media pantalla derecha: el copiloto queda al lado sin taparte los subtítulos.
391- // (No podemos mover ESTA ventana —el navegador solo deja recolocar las que
392- // abre el propio script—, pero sí colocar la del copiloto donde toca.)
393449 const sw=screen.availWidth||1280, sh=screen.availHeight||800, sl=screen.availLeft||0, st=screen.availTop||0;
394450 const w=Math.max(420,Math.floor(sw/2)), h=sh;
395- copilotWin=window.open(CLAW+'/?copilot=1','elffuss-copilot',
451+ copilotWin=window.open(CLAW+'/?copilot=1&skill='+encodeURIComponent(skill),'elffuss-copilot',
396452 `popup=yes,width=${w},height=${h},left=${sl+sw-w},top=${st}`);
397- if(copilotWin){ $('copilot').classList.add('on'); $('copilot').textContent='Cerrar copiloto'; }
453+ if(copilotWin){ $('copilot').classList.add('on'); $('copilot').textContent='Cerrar skill'; }
454+}
455+$('copilot').onclick=()=>{
456+ if(copilotWin && !copilotWin.closed){ try{copilotWin.close();}catch{} copilotReset(); closeSurface(); return; }
457+ openSkillPicker();
398458 };
399-// si cierras la ventana del copiloto a mano, el botón vuelve a su estado
400459 setInterval(()=>{ if(copilotWin && copilotWin.closed) copilotReset(); }, 1500);
460+
461+// ── superficie proyectada: la vista de la skill, DENTRO del translator ──
462+let surfaceOn=false;
463+function showSurface(html){
464+ $('surfFrame').srcdoc=html; document.body.classList.add('withsurface'); surfaceOn=true;
465+}
466+function closeSurface(){ document.body.classList.remove('withsurface'); $('surfFrame').srcdoc=''; surfaceOn=false; }
467+$('surfClose').onclick=closeSurface;
468+
401469 window.__copilot={ ready:()=>copilotReady, send:copilotSend, open:()=>$('copilot').click() };
402470
403471 // ── flujo de arranque: elegir idiomas → consentir → descargar todo → conversar ──
@@ -429,7 +497,11 @@
429497 // Al ocultarse, SIEMPRE soltar el TTS: si se queda hablando, su onend no
430498 // llega nunca y el medio-dúplex deja la app sorda al volver.
431499 ttsRelease();
432- if(convOn && convCtx && convCtx.state==='running'){ try{convCtx.suspend();}catch{} convPaused=true; setStatus('Pausado en segundo plano — ahorro de batería.','work'); }
500+ // OJO: con el copiloto abierto NO se pausa. Su ventana tapa al translator y
501+ // Chrome lo marca «oculto», pero es uso normal: si pausáramos, dejaría de
502+ // escuchar justo cuando más falta hace.
503+ const copilotOpen = !!(copilotWin && !copilotWin.closed);
504+ if(!copilotOpen && convOn && convCtx && convCtx.state==='running'){ try{convCtx.suspend();}catch{} convPaused=true; setStatus('Pausado en segundo plano — ahorro de batería.','work'); }
433505 } else if(convOn && convPaused){
434506 ttsRelease(); convBusy=false; // volver siempre en limpio
435507 convPaused=false;