Files
Abolfazl Ranjbaran 4821d812dc feat(accuracy): Persian accuracy stack v2 — measured -24.3 WER points on the default stack
Every decision below is measured on the 12-clip Common Voice fa fixture
with a reproducible harness; no number is hand-written.

- fa_polish module: orthographic-only repair (ZWNJ fusion, split
  imperatives like 'بی پوش' -> 'بپوش', Arabic code points, digits).
  Wired into the pipeline (FA_POLISH=true) and ported 1:1 to the browser
  demo (16-case parity test vs Python). -3.6 WER points.
- Persian orthography initial_prompt as the default: whisper copies the
  prompt's script style. -1.3 points (small), -4.8 (fine-tuned).
- Default engine small -> medium: 56.2% WER vs 75.0% (v2 harness) at
  ~1.1x realtime on 2 CPU cores. small stays the speed-first profile.
- Browser demo: default model base -> small (90.2% -> 75.0% under v2),
  polished output identical to the server's shape.
- benchmarks/tune_decode.py: the sweep harness behind every decision
  (prompt x beam x VAD x condition_on_previous_text).
- training/export_web_onnx.py: LoRA merge -> ONNX -> int8 -> HF Hub so
  the next fine-tune can run inside the browser demo.
- baseline.json regenerated for the v2 harness; weekly benchmark now
  guards small AND medium; gate test updated.

Fixture: small 80.5% -> 75.0%, fine-tuned 79.3% -> 75.0%, medium 56.2%.
2026-11-26 09:44:41 +00:00

163 lines
8.7 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>سخن · تبدیل گفتار فارسی به نوشتار</title>
<meta name="description" content="دموی زنده‌ی Sokhan — مدل Whisper کاملاً داخل مرورگر شما اجرا می‌شود؛ هیچ صدایی به هیچ سروری فرستاده نمی‌شود.">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;600;800&display=swap" rel="stylesheet">
<style>
:root {
--ink: #1c2333; --muted: #5b6472; --line: #e3e7ee;
--bg: #f6f7fa; --card: #ffffff; --accent: #4f46e5; --accent-2: #7c3aed;
--ok: #0e9f6e; --err: #cf2440;
}
* { box-sizing: border-box; }
body {
margin: 0; background: var(--bg); color: var(--ink);
font-family: 'Vazirmatn', 'Noto Sans Arabic', sans-serif;
line-height: 1.9;
}
.wrap { max-width: 860px; margin: 0 auto; padding: 24px 16px 64px; }
header h1 { font-size: 1.7rem; font-weight: 800; margin: 8px 0 2px; }
header h1 .brand { color: var(--accent); }
header p.sub { margin: 0 0 18px; color: var(--muted); font-size: 0.95rem; }
.card {
background: var(--card); border: 1px solid var(--line); border-radius: 14px;
padding: 18px 20px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
label.field { font-size: 0.85rem; color: var(--muted); display: block; margin-bottom: 4px; }
select {
font-family: inherit; font-size: 0.95rem; padding: 8px 12px; border-radius: 10px;
border: 1px solid var(--line); background: #fff; color: var(--ink);
}
button {
font-family: inherit; font-size: 1rem; font-weight: 600; padding: 10px 18px;
border-radius: 10px; border: 1px solid var(--line); background: #fff;
color: var(--ink); cursor: pointer; transition: all .15s ease;
}
button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary {
background: linear-gradient(135deg, var(--accent), var(--accent-2));
border: none; color: #fff; font-size: 1.05rem;
}
button.primary:hover:not(:disabled) { color: #fff; filter: brightness(1.07); }
button.recording { background: var(--err); border: none; color: #fff; }
#status { font-size: 0.92rem; color: var(--muted); min-height: 1.6em; margin: 14px 0 6px; }
.stages { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 4px; }
.stages span { font-size: 0.78rem; color: var(--muted); border: 1px solid var(--line);
border-radius: 99px; padding: 3px 10px; background: #fff; opacity: .55; }
.stages span.active { opacity: 1; color: #fff; font-weight: 600; border-color: transparent;
background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.stages span.done { opacity: .9; color: var(--ok); border-color: #a7f3d0; background: #ecfdf5; }
.badge { display: inline-block; font-size: 0.75rem; border-radius: 99px; padding: 2px 9px;
background: #eef2ff; color: var(--accent); font-weight: 600; }
#cancel { display: none; border-color: var(--err); color: var(--err); font-size: 0.85rem;
padding: 5px 12px; }
#cancel:hover:not(:disabled) { background: var(--err); color: #fff; }
.trow { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
gap: 8px; margin-bottom: 8px; }
label.chk { font-size: 0.82rem; color: var(--muted); display: flex; gap: 6px; align-items: center;
cursor: pointer; }
button.mini { font-size: 0.82rem; padding: 5px 12px; }
.bar { height: 8px; background: #eef0f5; border-radius: 99px; overflow: hidden; display: none; }
.bar > div { height: 100%; width: 0%; border-radius: 99px;
background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .2s ease; }
#transcript {
min-height: 120px; font-size: 1.08rem; padding: 12px 14px; border-radius: 10px;
border: 1px dashed var(--line); background: #fcfcfd; white-space: pre-wrap;
}
#meta { font-size: 0.85rem; color: var(--muted); margin-top: 8px; min-height: 1.4em; }
#ref { font-size: 0.85rem; color: var(--muted); margin-top: 6px; display: none; }
#ref b { color: var(--ok); font-weight: 600; }
.note { font-size: 0.88rem; color: var(--muted); }
.note a { color: var(--accent); text-decoration: none; font-weight: 600; }
.privacy { display: flex; gap: 8px; align-items: center; font-size: 0.9rem;
color: var(--ok); background: #ecfdf5; border: 1px solid #a7f3d0;
border-radius: 10px; padding: 8px 12px; margin-bottom: 16px; }
footer { margin-top: 26px; font-size: 0.85rem; color: var(--muted); text-align: center; }
footer a { color: var(--accent); text-decoration: none; }
</style>
</head>
<body>
<div class="wrap">
<header>
<h1>سخن <span class="brand">·</span> تبدیل گفتار فارسی به نوشتار</h1>
<p class="sub">دموی زنده‌ی موتور Sokhan — مدل Whisper روی دستگاهِ خودِ شما اجرا می‌شود.</p>
</header>
<div class="privacy">🔒 حریم خصوصی کامل: صدا فقط در مرورگر شما پردازش می‌شود — به هیچ سروری ارسال نمی‌شود.</div>
<div class="card">
<div class="stages" id="stages">
<span>۱ · آماده‌سازی صدا</span>
<span>۲ · دانلود مدل</span>
<span>۳ · پیاده‌سازی</span>
<span>۴ · پایان</span>
</div>
<div class="row">
<div>
<label class="field" for="model">کدام مدل؟ (اولین بار دانلود می‌شود)</label>
<select id="model">
<option value="Xenova/whisper-small" selected>کوچک (small) — دقیق‌تر، دانلود ~۲۵۰ مگابایت (پیشنهادی)</option>
<option value="Xenova/whisper-base">پایه (base) — سریع‌تر، دانلود ~۷۵ مگابایت</option>
</select>
</div>
<div style="flex:1"></div>
<button id="sample">نمونه‌ی آماده</button>
<button id="mic">ضبط با میکروفن</button>
</div>
<div class="row" style="margin-top:12px">
<input type="file" id="file" accept="audio/*,.wav,.mp3,.m4a,.ogg,.webm"
style="font-family:inherit;font-size:.9rem;color:var(--muted)">
</div>
<div id="status">برای شروع، «نمونه‌ی آماده» را بزنید یا صدا ضبط/انتخاب کنید.</div>
<div class="bar" id="bar"><div></div></div>
<div class="row" style="margin-top:8px">
<span class="badge" id="badge" style="display:none"></span>
<div style="flex:1"></div>
<button id="cancel">لغو پردازش</button>
</div>
</div>
<div class="card">
<div class="trow">
<label class="field">متن پیاده‌شده</label>
<div class="row" style="gap:10px">
<label class="chk"><input type="checkbox" id="stamp"> خط‌به‌خط با زمان</label>
<button class="mini" id="copy" style="display:none">کپی متن</button>
</div>
</div>
<div id="transcript" dir="rtl">(اینجا نوشته می‌شود…)</div>
<div id="meta"></div>
<div id="ref"></div>
</div>
<p class="note">
صادقانه: دقت Whisper روی Common Voice فارسی (محاوره‌ای و پرنویز) محدود است.
متن خروجی با پولیش ارتوگرافی فارسی (نیم‌فاصله، حروف عربی، فعل‌های شکسته) تمیز می‌شود —
همان پست‌پروسس نسخهٔ سرور.
در Chrome و Edge با WebGPU خیلی سریع‌تر است؛ سایر مرورگرها روی WASM با سقف مدت اجرا می‌کنند.
چک‌پوینت ریزتنظیم‌شده‌ی Sokhan روی <a href="https://huggingface.co/Abol0pati/whisper-small-fa-sokhan">Hub</a>
موجود است و اپ Gradio آن برای اجرای روی سرور خودتان در
<a href="https://github.com/Abolfazlrwm/sokhan/tree/main/space/gradio">space/gradio/</a>
قرار دارد — HF از ۲۰۲۶ میزبانی Spaceهای Gradio را پشت اشتراک PRO گذاشته و
Spaceهای Static مثل همین صفحه رایگان مانده‌اند.
</p>
<footer>
کد کامل: <a href="https://github.com/Abolfazlrwm/sokhan">github.com/Abolfazlrwm/sokhan</a>
· اندازه‌گیری‌ها: <a href="https://github.com/Abolfazlrwm/sokhan/tree/main/benchmarks">benchmarks/</a>
· اجرا با <a href="https://huggingface.co/docs/transformers.js">transformers.js</a>
</footer>
</div>
<script type="module" src="demo.js?v=4"></script>
</body>
</html>