mirror of
https://github.com/R0m1k3/EveFlow.git
synced 2026-10-11 17:29:03 +02:00
- Nouveau moteur « Microsoft Edge » (voix neuronales gratuites, sans clé) : Henri / Denise par défaut selon le genre, liste des voix fr-FR / fr-CA / fr-CH / fr-BE, WebSocket signé (Sec-MS-GEC) dans le processus principal, MP3 24 kHz. Moteur par défaut des nouvelles installations. - Supertonic 3 ajouté au catalogue local (31 langues, 5 voix masculines + 5 féminines, 44 kHz, 129 Mo) : langue transmise au worker, genres des voix vérifiés par mesure de F0. - Kokoro déclassé pour le français (une seule voix féminine, accent) ; le choix masculin/féminin bascule sur le meilleur modèle installé et conserve le genre quand on change de modèle ; Google Translate signalé comme voix féminine uniquement. - Deux préréglages JARVIS : en ligne (Edge Henri) et hors ligne (Supertonic 3). - Traitement du micro par Chromium (écho, bruit, gain) débrayable pour de meilleures transcriptions au casque. - Tests : protocole Edge (jeton, SSML, trames), sélection de voix ; README et feuille de route (mesures Supertonic, Parakeet vs Qwen3-ASR). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MMpgFriwxiBgurUVb21oCE
61 lines
3.9 KiB
TypeScript
61 lines
3.9 KiB
TypeScript
import { ipcMain } from 'electron';
|
|
import { VOICE_IPC, type EdgeSynthesizeRequest, type KwsStartRequest, type SynthesizeRequest, type TranscribeRequest, type VadStartRequest } from '../../shared/voice';
|
|
import { edgeSynthesize, edgeVoices } from './edgeTts';
|
|
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,
|
|
language: typeof req.language === 'string' ? req.language.slice(0, 8) : undefined
|
|
});
|
|
});
|
|
ipcMain.handle(VOICE_IPC.edgeSynthesize, (_e, req: EdgeSynthesizeRequest) => {
|
|
if (!req || typeof req.text !== 'string' || !req.text.trim() || req.text.length > 5000) throw new Error('Texte invalide');
|
|
if (typeof req.voice !== 'string' || !/^[a-z]{2,3}-[A-Za-z]{2,4}-[A-Za-z0-9]+$/.test(req.voice)) throw new Error('Voix Edge invalide');
|
|
return edgeSynthesize({ text: req.text, voice: req.voice, speed: Number.isFinite(req.speed) ? req.speed : 1 });
|
|
});
|
|
ipcMain.handle(VOICE_IPC.edgeVoices, () => edgeVoices());
|
|
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);
|
|
});
|
|
}
|