Spaces:
Running on Zero
Running on Zero
Download static/js/debug.js from Mati83moni/kos-pl: direct link, hf CLI and curl.
- Browser
- Download file 2.8 kB
-
https://huggingface.co/spaces/Mati83moni/kos-pl/resolve/main/static/js/debug.js
- Command line
-
hf download hf://spaces/Mati83moni/kos-pl/static/js/debug.js
-
curl -L -o debug.js https://huggingface.co/spaces/Mati83moni/kos-pl/resolve/main/static/js/debug.js
2.8 kB
| // Lists the last STT inputs with audio players. All text is inserted with textContent. | |
| const $ = (id) => document.getElementById(id); | |
| function dl(rows) { | |
| const el = document.createElement("dl"); | |
| for (const [k, v] of rows) { | |
| if (v === undefined || v === null || v === "") continue; | |
| const dt = document.createElement("dt"); | |
| dt.textContent = k; | |
| const dd = document.createElement("dd"); | |
| dd.textContent = typeof v === "object" ? JSON.stringify(v) : String(v); | |
| el.append(dt, dd); | |
| } | |
| return el; | |
| } | |
| function render(entry) { | |
| const li = document.createElement("li"); | |
| li.className = "card"; | |
| const head = document.createElement("div"); | |
| head.className = "row"; | |
| const title = document.createElement("strong"); | |
| title.textContent = entry.transcript ? `„${entry.transcript}”` : "(brak transkryptu)"; | |
| const when = document.createElement("span"); | |
| when.className = "muted"; | |
| when.textContent = `${entry.name} · ${entry.created_at}`; | |
| head.append(title, when); | |
| const audio = document.createElement("audio"); | |
| audio.controls = true; | |
| audio.preload = "none"; | |
| audio.src = `/api/debug/stt/${entry.name}.wav`; | |
| const d = entry.decode || {}; | |
| const g = entry.gate || {}; | |
| const vad = entry.vad || {}; | |
| li.append(head, audio, dl([ | |
| ["Czas audio [s]", `${entry.seconds} (mowa ${entry.speech_seconds}, cisza dodana z każdej strony ${entry.pad_seconds})`], | |
| ["Poziom / szczyt", `${entry.rms_dbfs} dBFS / ${entry.peak}`], | |
| ["STT [ms]", entry.stt_ms], | |
| ["Język / zadanie do Whispera", d.forced_language ? `${d.forced_language} / ${d.task}` : null], | |
| ["Tokeny dekodera", (d.decoder_prompt || []).join(" ")], | |
| ["Język bez wymuszenia", d.detected_language ? `${d.detected_language} (${d.detected_prob}); pl: ${d.forced_prob}` : null], | |
| ["avg logprob / brak mowy", d.avg_logprob !== undefined ? `${d.avg_logprob} / ${d.no_speech_prob}` : null], | |
| ["Bramka", g.action ? `${g.action}: ${g.reason}; usłyszano „${g.heard}”${g.matched ? `, dopasowano „${g.matched}” (${g.score})` : ""}` : null], | |
| ["VAD", vad], | |
| ["Ścieżka", entry.route], | |
| ["Błąd", entry.error], | |
| ])); | |
| return li; | |
| } | |
| async function load() { | |
| const list = $("entries"); | |
| list.replaceChildren(); | |
| try { | |
| const r = await fetch("/api/debug/stt", { cache: "no-store" }); | |
| if (!r.ok) throw new Error(`HTTP ${r.status}`); | |
| const data = await r.json(); | |
| $("count").textContent = `${data.entries.length} z ${data.keep} wpisów`; | |
| for (const e of data.entries) list.append(render(e)); | |
| if (!data.entries.length) $("count").textContent = "Brak wpisów: powiedz coś do Kosa."; | |
| } catch (err) { | |
| $("count").textContent = `Błąd odczytu: ${err.message}`; | |
| $("count").className = "bad"; | |
| } | |
| } | |
| $("reload").addEventListener("click", load); | |
| load(); | |