diff --git a/js/main.js b/js/main.js index b3a4a57..fe68feb 100644 --- a/js/main.js +++ b/js/main.js @@ -1,6 +1,6 @@ // ---------- Глобальные переменные и инициализация ---------- const GROQ_API_KEY = ''; -const VERSION = 'v87'; +const VERSION = 'v88'; let mediaRecorder, audioChunks = [], userAudioBlob = null, ttsText = ''; let isRecording = false, isAnalyzing = false, micAnalyser = null, micAnimId = null; diff --git a/js/transcribe.js b/js/transcribe.js index 0bbd79a..a120f37 100644 --- a/js/transcribe.js +++ b/js/transcribe.js @@ -24,7 +24,7 @@ async function transcribe(blob) { console.log('[WS] timeout'); ws.close(); resolve({ text: '', error: 'timeout' }); }, 60000); - ws.onopen = () => { + ws.onopen = async () => { console.log('[WS] connected, sending ' + total + ' chunks'); for (let i = 0; i < base64.length; i += CHUNK) { ws.send(JSON.stringify({ @@ -34,6 +34,8 @@ async function transcribe(blob) { m: mime, n: total })); + // Даём браузеру протолкнуть буфер — Chrome может терять фреймы без этого + await new Promise(r => setTimeout(r, 10)); } ws.send(JSON.stringify({ c: -1 })); console.log('[WS] all sent');