mirror of
https://github.com/R0m1k3/EveFlow.git
synced 2026-10-11 17:29:03 +02:00
Écoute permanente - Silero VAD dans le worker sherpa-onnx (vad.start/audio/stop) ; le renderer envoie des trames de 128 ms pendant la commande et reçoit le segment WAV complet (speech-start / segment). Repli sur le VAD énergétique si le modèle n'est pas installé ou si l'option est désactivée. - Modèle « silero-vad » (0,6 Mo) dans le catalogue, section « Fin de phrase » dans Modèles locaux, réglage dans Paramètres → Micro. Vision d'écran - IPC system:screen-capture (desktopCapturer, JPEG 1600 px) ; bouton dans la barre de commande ; « regarde mon écran… » joint la capture à la question envoyée à Hermes (transport chat completions pour les images). Actions locales - IPC system:action à liste blanche : verrouiller la session, touches média (volume, mute, lecture, piste), ouvrir une application connue ou une URL http(s), presse-papiers, recherche de fichiers dans les dossiers utilisateur. - Routeur d'intentions FR/EN exécuté avant Hermes (« coupe le son », « ouvre Spotify », « verrouille la session »…), résultat affiché et lu ; désactivable. Correctif - Chat completions : les premiers fragments SSE arrivés avant l'événement de démarrage étaient perdus (premier mot manquant) ; ils sont maintenant rejoués. Tests : 26 tests unitaires (intentions locales ajoutées), e2e Electron sous Xvfb avec les vrais modèles (Silero : un segment par phrase, 6,7 s d'audio traités en 190 ms ; capture 109 ko reçue par Hermes ; intention locale traitée sans Hermes). Claude-Session: https://claude.ai/code/session_017Wn5VX9HNbJ7N54hR24u9Y Co-authored-by: Claude <noreply@anthropic.com>
49 lines
3.1 KiB
TypeScript
49 lines
3.1 KiB
TypeScript
import { ipcMain } from 'electron';
|
|
import { VOICE_IPC, type KwsStartRequest, type SynthesizeRequest, type TranscribeRequest, type VadStartRequest } from '../../shared/voice';
|
|
import { engineStatus, kwsFeed, kwsStart, kwsStop, synthesize, transcribe, unload, vadFeed, vadStart, vadStop } from './engine';
|
|
import { cancelDownload, downloadModel, listModels, removeModel } from './models';
|
|
|
|
export function registerVoiceIpc(): void {
|
|
ipcMain.handle(VOICE_IPC.status, () => engineStatus());
|
|
ipcMain.handle(VOICE_IPC.modelsList, () => listModels());
|
|
ipcMain.handle(VOICE_IPC.modelsDownload, (event, id: string) => downloadModel(id, event.sender));
|
|
ipcMain.handle(VOICE_IPC.modelsCancel, (_e, id: string) => {
|
|
cancelDownload(id);
|
|
return true;
|
|
});
|
|
ipcMain.handle(VOICE_IPC.modelsRemove, async (_e, id: string) => {
|
|
await unload(id).catch(() => undefined);
|
|
await removeModel(id);
|
|
return listModels();
|
|
});
|
|
ipcMain.handle(VOICE_IPC.transcribe, (_e, req: TranscribeRequest) => {
|
|
if (!req || !(req.wav instanceof Uint8Array) || req.wav.byteLength < 44 || req.wav.byteLength > 64 * 1024 * 1024) throw new Error('Audio invalide');
|
|
if (typeof req.modelId !== 'string') throw new Error('Modèle invalide');
|
|
return transcribe({ ...req, language: typeof req.language === 'string' ? req.language.slice(0, 8) : 'auto' });
|
|
});
|
|
ipcMain.handle(VOICE_IPC.synthesize, (_e, req: SynthesizeRequest) => {
|
|
if (!req || typeof req.text !== 'string' || !req.text.trim() || req.text.length > 5000) throw new Error('Texte invalide');
|
|
if (typeof req.modelId !== 'string') throw new Error('Modèle invalide');
|
|
return synthesize({ ...req, speaker: Number.isFinite(req.speaker) ? req.speaker : 0, speed: Number.isFinite(req.speed) ? req.speed : 1 });
|
|
});
|
|
ipcMain.handle(VOICE_IPC.unload, (_e, id?: string) => unload(id));
|
|
ipcMain.handle(VOICE_IPC.kwsStart, (event, req: KwsStartRequest) => {
|
|
if (!req || !Array.isArray(req.keywords) || typeof req.modelId !== 'string') throw new Error('Requête invalide');
|
|
return kwsStart({ ...req, keywords: req.keywords.filter((k) => typeof k === 'string'), sensitivity: Number(req.sensitivity) || 3 }, event.sender);
|
|
});
|
|
ipcMain.handle(VOICE_IPC.kwsStop, () => kwsStop());
|
|
ipcMain.handle(VOICE_IPC.vadStart, (event, req: VadStartRequest) => {
|
|
if (!req || typeof req.modelId !== 'string') throw new Error('Requête invalide');
|
|
return vadStart({ modelId: req.modelId, silenceMs: Number(req.silenceMs) || 700, threshold: Number(req.threshold) || 0.5, maxUtteranceSec: Number(req.maxUtteranceSec) || 30 }, event.sender);
|
|
});
|
|
ipcMain.handle(VOICE_IPC.vadStop, () => vadStop());
|
|
ipcMain.on(VOICE_IPC.vadAudio, (_e, pcm: unknown, sampleRate: unknown) => {
|
|
if (!(pcm instanceof Uint8Array) || pcm.byteLength === 0 || pcm.byteLength > 1024 * 1024) return;
|
|
vadFeed(pcm, typeof sampleRate === 'number' && sampleRate > 0 ? sampleRate : 16000);
|
|
});
|
|
ipcMain.on(VOICE_IPC.kwsAudio, (_e, pcm: unknown, sampleRate: unknown) => {
|
|
if (!(pcm instanceof Uint8Array) || pcm.byteLength === 0 || pcm.byteLength > 1024 * 1024) return;
|
|
kwsFeed(pcm, typeof sampleRate === 'number' && sampleRate > 0 ? sampleRate : 16000);
|
|
});
|
|
}
|