Spaces:
Running

Shenava-Rizeh-Live / index.html
Reza2kn's picture
Phone layout, measured accuracy in README
41e0beb verified
Raw History Blame Contribute Delete
9.96 kB
<!doctype html>
<html lang="fa" dir="rtl">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>شنوا ریزه ۱.۵ · Live Persian ASR</title>
<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@300;400;600;800&family=Inter:wght@400;600&display=swap" rel="stylesheet">
<style>
:root{--bg:#07070d;--ink:#f4f1ea;--dim:#8e8aa3;--live:#7dd3fc;--fix:#fbbf24;--rec:#ff4d6d;--card:rgba(255,255,255,.04);--line:rgba(255,255,255,.08);--lvl:0}
*{box-sizing:border-box}
html,body{margin:0;height:100%;background:var(--bg);color:var(--ink);font-family:Vazirmatn,Inter,system-ui,sans-serif;-webkit-font-smoothing:antialiased}
body{display:flex;flex-direction:column;overflow:hidden}
.aurora{position:fixed;inset:-20%;z-index:0;filter:blur(100px);opacity:.75;pointer-events:none}
header,main,footer{position:relative;z-index:1}
.aurora i{position:absolute;border-radius:50%;animation:drift 22s ease-in-out infinite alternate}
.aurora i:nth-child(1){width:46vw;height:46vw;background:#4338ca;top:5%;right:8%}
.aurora i:nth-child(2){width:38vw;height:38vw;background:#0e7490;bottom:2%;left:10%;animation-delay:-7s}
.aurora i:nth-child(3){width:30vw;height:30vw;background:#9d174d;top:40%;left:40%;animation-delay:-13s;opacity:.6}
body.recording .aurora i:nth-child(3){background:#e11d48;opacity:calc(.5 + var(--lvl)*.5)}
@keyframes drift{to{transform:translate(6vw,-4vh) scale(1.15)}}
header{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:22px clamp(16px,4vw,48px) 0}
.brand h1{margin:0;font-weight:800;font-size:clamp(26px,3.4vw,44px);letter-spacing:-.5px}
.brand h1 b{background:linear-gradient(90deg,#c4b5fd,#7dd3fc);-webkit-background-clip:text;background-clip:text;color:transparent}
.brand p{margin:4px 0 0;color:var(--dim);font:400 14px/1.4 Inter,system-ui;direction:ltr;text-align:right}
.pill{font:600 14px Vazirmatn,Inter;padding:8px 14px;border-radius:999px;border:1px solid var(--line);background:var(--card);white-space:nowrap}
.pill.ok{color:#86efac;border-color:rgba(134,239,172,.35)} .pill.err{color:#fca5a5;border-color:rgba(252,165,165,.4);white-space:normal;max-width:50vw}
main{flex:1;display:flex;flex-direction:column;min-height:0;padding:18px clamp(16px,4vw,48px) 0}
#scroller{position:relative;flex:1;min-height:0;overflow-y:auto;border-radius:28px;background:var(--card);border:1px solid var(--line);padding:clamp(20px,4vw,56px);scroll-behavior:smooth;backdrop-filter:blur(6px)}
#scroller.drag{outline:3px dashed var(--live);outline-offset:-10px}
#transcript{font-size:clamp(30px,4.6vw,68px);line-height:1.75;font-weight:600;word-spacing:.04em}
#placeholder{color:var(--dim);font-weight:300;font-size:clamp(26px,3.6vw,52px);line-height:1.6}
#placeholder small{display:block;font-size:.42em;margin-top:.8em;font-family:Inter,Vazirmatn;direction:ltr;text-align:right;opacity:.8}
.w{transition:color .6s ease,opacity .6s ease}
.w.live{color:var(--live);opacity:.92}
.w.pending{color:#cbd5e1}
.w.fixed,.w.final{color:var(--ink)}
.w.new{animation:pop .35s ease-out}
.w.changed{animation:fixflash 1.6s ease-out}
@keyframes pop{from{opacity:0;filter:blur(6px);transform:translateY(.15em)}}
@keyframes fixflash{0%{color:var(--fix);text-shadow:0 0 .4em rgba(251,191,36,.7)}100%{color:var(--ink);text-shadow:none}}
#loader{position:absolute;inset:auto 0 0 0;height:4px;background:rgba(255,255,255,.06);border-radius:0 0 28px 28px;overflow:hidden;transition:opacity .6s}
#loader.done,#loader.done+#loadtxt{opacity:0} #bar{height:100%;width:0;background:linear-gradient(90deg,#818cf8,#7dd3fc);transition:width .2s}
#loadtxt{transition:opacity .6s;position:absolute;left:20px;bottom:12px;color:var(--dim);font:13px Inter;direction:ltr}
.dock{display:flex;align-items:center;justify-content:center;gap:clamp(12px,3vw,28px);padding:22px 0 14px;flex-wrap:wrap}
#rec{--s:clamp(84px,11vw,112px);width:var(--s);height:var(--s);border-radius:50%;border:0;cursor:pointer;position:relative;
background:radial-gradient(circle at 35% 30%,#ff8aa0,var(--rec) 55%,#9f1239);box-shadow:0 12px 40px rgba(255,77,109,.35),inset 0 -6px 18px rgba(0,0,0,.25);transition:transform .15s,filter .3s}
#rec:hover{transform:scale(1.04)} #rec:active{transform:scale(.97)}
body:not(.ready) #rec{filter:grayscale(1) brightness(.6);cursor:wait}
#rec::before{content:"";position:absolute;inset:calc(-10px - var(--lvl)*26px);border-radius:50%;border:3px solid rgba(255,77,109,calc(.15 + var(--lvl)*.6));transition:inset .08s linear}
#rec svg{width:42%;height:42%;fill:#fff}
#rec .stop{display:none} body.recording #rec .mic{display:none} body.recording #rec .stop{display:inline}
#rec.busy{animation:spin 1.2s linear infinite;background:conic-gradient(from 0deg,#7dd3fc,#818cf8,#ff4d6d,#7dd3fc)}
@keyframes spin{to{filter:hue-rotate(360deg)}}
.btn{display:inline-flex;align-items:center;gap:10px;height:56px;padding:0 22px;border-radius:18px;border:1px solid var(--line);background:var(--card);color:var(--ink);font:600 18px Vazirmatn;cursor:pointer;transition:background .2s}
.btn:hover{background:rgba(255,255,255,.09)} .btn svg{width:22px;height:22px;fill:currentColor}
.toggles{display:flex;gap:18px;color:var(--dim);font-size:16px}
.toggles label{display:flex;align-items:center;gap:8px;cursor:pointer}
.toggles input{appearance:none;width:42px;height:24px;border-radius:999px;background:rgba(255,255,255,.12);position:relative;cursor:pointer;transition:background .2s}
.toggles input::after{content:"";position:absolute;top:3px;right:3px;width:18px;height:18px;border-radius:50%;background:#fff;transition:right .2s}
.toggles input:checked{background:#6366f1} .toggles input:checked::after{right:21px}
.stats{display:flex;justify-content:center;gap:clamp(14px,3vw,34px);flex-wrap:wrap;color:var(--dim);font:13px Inter,Vazirmatn;padding:0 0 18px;direction:ltr}
.stats b{color:var(--ink);font-weight:600;margin-left:6px}
.legend{display:flex;gap:18px;justify-content:center;color:var(--dim);font-size:14px;padding-bottom:6px}
.legend span::before{content:"";display:inline-block;width:10px;height:10px;border-radius:50%;margin-left:6px;vertical-align:middle}
.legend .l1::before{background:var(--live)} .legend .l2::before{background:var(--fix)} .legend .l3::before{background:var(--ink)}
footer{color:var(--dim);font:12.5px Inter;text-align:center;padding:0 16px 14px;direction:ltr}
footer a{color:#a5b4fc;text-decoration:none}
#filename{color:var(--dim);font-size:14px;max-width:22ch;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
@media (max-width:640px){.toggles{width:100%;justify-content:center}.brand p{display:none}.pill{font-size:11px;padding:6px 10px}.brand h1{white-space:nowrap;font-size:24px}}
</style>
</head>
<body>
<div class="aurora"><i></i><i></i><i></i></div>
<header>
<div class="brand"><h1><b>شنوا</b> ریزه ۱.۵</h1><p>Shenava Rizeh v1.5 · live Persian speech recognition, running entirely in your browser</p></div>
<span id="status" class="pill">…</span>
</header>
<main>
<section id="scroller" aria-live="polite">
<div id="placeholder">دکمه را بزنید و صحبت کنید، یا یک فایل صوتی اینجا بیندازید.<small>Tap the mic and speak Persian, or drop an audio file. Words appear as they are spoken; a second, full-context pass with a word n-gram LM then corrects each phrase.</small></div>
<div id="transcript"></div>
<div id="loader"><div id="bar"></div></div><div id="loadtxt"></div>
</section>
<div class="legend"><span class="l1">زنده</span><span class="l2">اصلاح‌شده</span><span class="l3">نهایی</span></div>
<div class="dock">
<label class="btn" title="Upload audio"><svg viewBox="0 0 24 24"><path d="M5 20h14v-2H5v2zm7-16-5 5h3v6h4V9h3l-5-5z"/></svg>فایل<input id="file" type="file" accept="audio/*,video/*" hidden></label>
<button id="rec" aria-pressed="false" title="Record (Space)"><svg class="mic" viewBox="0 0 24 24"><path d="M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3zm5-3a5 5 0 0 1-10 0H5a7 7 0 0 0 6 6.92V21h2v-3.08A7 7 0 0 0 19 11h-2z"/></svg><svg class="stop" viewBox="0 0 24 24"><rect x="6" y="6" width="12" height="12" rx="2"/></svg></button>
<button id="sample" class="btn" title="Try a sample (6 FLEURS sentences, 2 min)"><svg viewBox="0 0 24 24"><path d="M12 3v10.55A4 4 0 1 0 14 17V7h4V3h-6z"/></svg>نمونه</button>
<button id="clear" class="btn" title="Clear"><svg viewBox="0 0 24 24"><path d="M6 19a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg>پاک</button>
<button id="copy" class="btn" title="Copy"><svg viewBox="0 0 24 24"><path d="M16 1H4a2 2 0 0 0-2 2v14h2V3h12V1zm3 4H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2zm0 16H8V7h11v14z"/></svg>کپی</button>
<div class="toggles"><label><input id="fix" type="checkbox" checked>اصلاح با بافت کامل</label><label><input id="lm" type="checkbox" checked>مدل زبانی</label><span id="filename"></span></div>
</div>
<div class="stats"><span>backend<b id="backend">–</b></span><span>chunk (320 ms)<b id="st-chunk">–</b></span><span>speed<b id="st-rtf">–</b></span><span>correction<b id="st-corr">–</b></span><span>audio<b id="st-audio">0 s</b></span><span>wall<b id="st-wall">–</b></span></div>
</main>
<footer>60M-param Zipformer2 RNN-T (int4) · streaming encoder 320 ms chunks + full-context rescoring with a 3-gram LM · nothing leaves your device ·
<a href="https://huggingface.co/Reza2kn/Shenava-Rizeh-v1.5" target="_blank">model</a> · <a href="https://huggingface.co/Reza2kn/Shenava-Rizeh-v1.5-sherpa-onnx" target="_blank">ONNX</a> · <a href="https://huggingface.co/spaces/Reza2kn/PersianASR-TrippleThreat" target="_blank">leaderboard</a> · GPL-3.0</footer>
<script type="module" src="./app.js"></script>
</body>
</html>