From ff6eb0486c0da4a704eba1c3feb3112c1363eee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Fri, 22 May 2026 17:23:32 +0400 Subject: [PATCH] =?UTF-8?q?v52:=20=D1=82=D1=80=D0=B0=D0=BD=D1=81=D0=BA?= =?UTF-8?q?=D1=80=D0=B8=D0=BF=D1=86=D0=B8=D1=8F=20=E2=86=92=20=D1=84=D0=BE?= =?UTF-8?q?=D0=BD=D0=B5=D1=82=D0=B8=D0=BA=D0=B0=20=D0=BF=D0=BE=D1=81=D0=BB?= =?UTF-8?q?=D0=B5=D0=B4=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D0=BE,=20=D1=84=D0=BE=D0=BD=D0=B5=D1=82=D0=B8=D0=BA=D0=B0=20?= =?UTF-8?q?=D1=81=20=D1=82=D0=B0=D0=B9=D0=BC=D0=B0=D1=83=D1=82=D0=BE=D0=BC?= =?UTF-8?q?=2010=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index 25daf9d..0d5993f 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 = 'v51'; +const VERSION = 'v52'; document.getElementById('ver').textContent = VERSION; // ---------- Перевод на русский (Groq) ---------- @@ -221,19 +221,28 @@ async function doCompare(blob, originalText, duration) { const elapsed = ((Date.now() - startTime) / 1000).toFixed(1); setStatus('Анализ... ' + elapsed + 'с'); }, 150); - let whisperResult, phon; + + // Шаг 1: транскрипция (быстро, ~0.5с) + let whisperResult = { text: '', error: null }; + try { whisperResult = await transcribe(blob); } + catch(e) { console.log('[COMPARE] transcribe failed:', e); } + + // Шаг 2: фонетика (может виснуть на decodeAudioData, таймаут 10с) + let phon = { pitchHz: 0, pitchStability: 0, voiceClarity: 0, phonScore: 0 }; try { - [whisperResult, phon] = await Promise.all([ - transcribe(blob), - phoneticAnalysis(blob) + phon = await Promise.race([ + phoneticAnalysis(blob), + new Promise(r => setTimeout(() => r({ pitchHz: 0, pitchStability: 0, voiceClarity: 0, phonScore: 0 }), 10000)) ]); - } catch(e) { - clearInterval(timerId); - isAnalyzing = false; - setStatus('Ошибка анализа.'); + } catch(e) { console.log('[COMPARE] phonetics failed:', e); } + + clearInterval(timerId); + isAnalyzing = false; + + if (whisperResult.error && !whisperResult.text) { + setStatus('Ошибка: ' + (whisperResult.error || 'сеть')); return ''; } - clearInterval(timerId); const phonEmoji = phon.phonScore >= 85 ? '🟢' : phon.phonScore >= 60 ? '🟡' : '🔴'; let recHTML = '', diffHTML = ''; @@ -264,7 +273,6 @@ async function doCompare(blob, originalText, duration) { ''; setStatus('Готово.'); - isAnalyzing = false; return whisperResult.text || ''; }