v82: trimStartBlob через AudioContext+OfflineRenderer — обрезка 0.2с для Whisper

This commit is contained in:
“Naeel”
2026-05-23 06:26:07 +04:00
parent 6b62ec8dd5
commit dababcf466
4 changed files with 60 additions and 24 deletions
+5 -2
View File
@@ -4,12 +4,15 @@ async function transcribe(blob) {
if (!GROQ_API_KEY) return { text: '', error: 'no_key' };
const tStart = performance.now();
// Обрезаем 0.2с в начале (щелчок)
const sendBlob = await trimStartBlob(blob);
const form = new FormData();
form.append('file', blob, 'audio.webm');
form.append('file', sendBlob, sendBlob.type === 'audio/wav' ? 'audio.wav' : 'audio.webm');
form.append('model', 'whisper-large-v3');
form.append('language', 'it');
console.log('[HTTP] blob ' + (blob.size/1024).toFixed(1) + 'KB → multipart POST');
console.log('[HTTP] blob ' + (sendBlob.size/1024).toFixed(1) + 'KB → multipart POST');
try {
const r = await fetch('https://lang.kube5s.ru/openai/v1/audio/transcriptions', {