v60: чанки 30KB — обход DPI-порога ~48KB на WebSocket text-фреймы

This commit is contained in:
“Naeel”
2026-05-22 17:54:11 +04:00
parent 96f178b56e
commit 786b937acd
2 changed files with 84 additions and 4 deletions
+9 -4
View File
@@ -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 = 'v48';
const VERSION = 'v60';
document.getElementById('ver').textContent = VERSION;
// ---------- Перевод на русский (Groq) ----------
@@ -627,14 +627,19 @@ async function transcribe(blob) {
return new Promise((resolve) => {
try {
const CHUNK = 30000; // макс 30KB на фрейм (DPI режет >48KB)
const total = Math.ceil(base64.length / CHUNK);
const ws = new WebSocket('wss://proxy.kube5s.ru/ws');
const timeout = setTimeout(() => {
console.log('[WS] timeout'); ws.close(); resolve({ text: '', error: 'timeout' });
}, 60000);
}, 90000);
ws.onopen = () => {
ws.send(JSON.stringify({ token: GROQ_API_KEY, audio_b64: base64, mime: blob.type || 'audio/webm' }));
console.log('[WS] sent');
for (let i = 0; i < total; i++) {
ws.send(JSON.stringify({ c: i, n: total, t: GROQ_API_KEY, b: base64.slice(i * CHUNK, (i + 1) * CHUNK), m: blob.type || 'audio/webm' }));
}
ws.send(JSON.stringify({ c: -1 }));
console.log('[WS] sent ' + total + ' chunks');
};
ws.onmessage = (e) => {