From d4aebf4b2c6f18bf40c96307365f5b96b7c6a557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Fri, 22 May 2026 16:31:35 +0400 Subject: [PATCH] =?UTF-8?q?v45:=20WebSocket=20=E2=80=94=20=D0=B2=D0=B5?= =?UTF-8?q?=D1=81=D1=8C=20=D0=B1=D0=BB=D0=BE=D0=B1=20=D0=BE=D0=B4=D0=BD?= =?UTF-8?q?=D0=B8=D0=BC=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=D0=BC,=20=D0=B1=D0=B5=D0=B7=20=D1=87=D0=B0=D0=BD=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/index.html b/index.html index 67cf52f..32e420b 100644 --- a/index.html +++ b/index.html @@ -53,7 +53,7 @@ let mediaRecorder, audioChunks = [], userAudioBlob = null, ttsText = ''; let isRecording = false, isAnalyzing = false, micAnalyser = null, micAnimId = null; let recordStartTime = 0, recordDuration = 0; // ---------- Версия ---------- -const VERSION = 'v44'; +const VERSION = 'v45'; document.getElementById('ver').textContent = VERSION; // ---------- Перевод на русский (Groq) ---------- @@ -608,8 +608,6 @@ document.getElementById('btnPlayUser').onclick = async () => { } }; -const CHUNK_SIZE = 4096; - async function transcribe(blob) { if (!GROQ_API_KEY) return { text: '', error: 'no_key' }; const tStart = performance.now(); @@ -637,33 +635,31 @@ async function transcribe(blob) { } } - // Large file: WebSocket - const total = Math.ceil(blob.size / CHUNK_SIZE); + // Large file: WebSocket (entire blob, no chunks) + console.log('[WS] opening, blob=' + (blob.size/1024).toFixed(1) + 'KB'); return new Promise((resolve) => { try { const ws = new WebSocket('wss://proxy.kube5s.ru/ws'); - const timeout = setTimeout(() => { ws.close(); resolve({ text: '', error: 'timeout' }); }, 60000); + const timeout = setTimeout(() => { console.log('[WS] timeout'); ws.close(); resolve({ text: '', error: 'timeout' }); }, 60000); - ws.onopen = () => { - ws.send(JSON.stringify({ token: GROQ_API_KEY, chunks: total })); - (async () => { - for (let i = 0; i < total; i++) { - const chunk = blob.slice(i * CHUNK_SIZE, Math.min((i + 1) * CHUNK_SIZE, blob.size)); - ws.send(await chunk.arrayBuffer()); - } - })(); + ws.onopen = async () => { + console.log('[WS] connected'); + ws.send(JSON.stringify({ token: GROQ_API_KEY })); + ws.send(await blob.arrayBuffer()); + console.log('[WS] blob sent'); }; ws.onmessage = (e) => { clearTimeout(timeout); ws.close(); const data = JSON.parse(e.data); - console.log('[WHISPER] ' + (blob.size/1024).toFixed(1) + 'KB ws/' + total + 'chunks ' + ((performance.now()-tStart)/1000).toFixed(2) + 's → ' + (data.text||'(empty)')); + console.log('[WHISPER] ' + (blob.size/1024).toFixed(1) + 'KB ws ' + ((performance.now()-tStart)/1000).toFixed(2) + 's → ' + (data.text||'(empty)')); if (data.error) resolve({ text: '', error: data.error }); else resolve({ text: data.text || '', error: null }); }; ws.onerror = () => { + console.log('[WS] error'); clearTimeout(timeout); resolve({ text: '', error: 'network' }); };