From cc3be616a9543b89dffe61991912c15121f9291c Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 26 May 2025 02:49:01 +0200 Subject: [PATCH] auto-git: [change] renderer.js --- renderer.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/renderer.js b/renderer.js index 4465695..065ec19 100644 --- a/renderer.js +++ b/renderer.js @@ -653,6 +653,26 @@ folders.forEach(folderObj => { ipcRenderer.on('cat-begin', () => window.cat && window.cat.begin()); ipcRenderer.on('cat-chunk', (_e, chunk) => window.cat && window.cat.streamText(chunk)); ipcRenderer.on('cat-end', () => window.cat && window.cat.end()); + const speakToCat = msg => { + window.cat.beginSpeech(); + // Zeig Nachricht Zeichen für Zeichen: + let i = 0; + function nextChar() { + if (i < msg.length) { + window.cat.appendSpeech(msg[i++]); + setTimeout(nextChar, 50); + } else { + window.cat.endSpeech(); + } + } + nextChar(); + }; + + window.electronAPI && window.electronAPI.onCatSay && + window.electronAPI.onCatSay((_, msg) => speakToCat(msg)); + + // oder mit + window.require && require('electron').ipcRenderer.on('cat-say', (_, msg) => speakToCat(msg)); /* const slot = document.getElementById('catSlot');